I am creating a Rest API using C# and WebAPI. I am using Swashbuckle to add a Swagger UI to the API and AutoRest to generate a client. This all works fine, until I introduce polymorphism / inheritance to my model. Swagger UI is only creating definitions for the base classes, which results in my AutoRest client only having base types in the interface.
Are there attributes needed on my model to allow Swashbuckle / Swagger to recognize the derived types?
Swagger / OpenAPI
specification does support polymorphism.
SwashBuckle, which generates a Swagger document dynamically, as stated on Swashbuckle versions feature comparision, does not support polymorphism from version 5.0.
The only way you could handle polymorphism here would be to build your own code once Swagger model has been completely generated, using the IDocumentFilter
interface to modify generated definitions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With