While I cannot get a proper example right now, the base class properties are included in both the base class schema and the actual schema.
While Swagger UI handles duplicate properties just fine, NSwag does not. Using Poco for generated DTOs, this results in properties that hide the inherited properties, which causes the base class properties to be null. I tried using Record instead, but the generated constructor contains duplicate parameters, causing compilation errors.
I resolved my issue by filtering out the duplicate properties while generating the Swagger document, but I think NSwag could improve on this area as well. I'm not too familiar with the intricacies of Swagger so I don't know what would be most appropriate, but I suggest simply skipping properties declared in the base class.
I have a Swagger document that contains schemas that use
allOf
to include the base class schema (I used Swashbuckle.AspNetCore.Polymorphism):While I cannot get a proper example right now, the base class properties are included in both the base class schema and the actual schema.
While Swagger UI handles duplicate properties just fine, NSwag does not. Using Poco for generated DTOs, this results in properties that hide the inherited properties, which causes the base class properties to be
null
. I tried using Record instead, but the generated constructor contains duplicate parameters, causing compilation errors.I resolved my issue by filtering out the duplicate properties while generating the Swagger document, but I think NSwag could improve on this area as well. I'm not too familiar with the intricacies of Swagger so I don't know what would be most appropriate, but I suggest simply skipping properties declared in the base class.