NJsonSchema: Missing schema properties in models from interfaces

When a controller specifies its return type as an interface, NSwag generates an empty model for it. The following is an interface, IFixtureData:

public interface IFixtureData
{
    ushort Address { get; set; }
    FixtureDefinitionSkeleton Type { get; set; }
    FixtureOptions Options { get; set; }
    string Group { get; set; }
}

In the swagger.json file, the following is generated:

"IFixtureDefinition": {
  "type": "object",
  "x-abstract": true,
  "additionalProperties": false
}

All of my concrete classes are generated properly, but the interfaces are all like this.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 32 (31 by maintainers)

Commits related to this issue

Most upvoted comments

Just added it.

Can I currently set the new Property of JsonSchemaGeneratorSettings from NSwag, or should I create a PR there to include this?

Yes, should be available

Also I cannot add the new Attribute to Interfaces, because it has a [AttributeUsage(AttributeTargets.Class)] Attribute. Is that on purpose?

That’s bad, we need to add that