Open sannyjacobsson opened 1 year ago
In backlog
@Rick-Anderson I am not sure if this person is using Swashbuckle and we should point them to the docs on polymorphism and inheritance that supports allOf
or anyOf
to express the schema relationships. @captainsafia is this something that we should document? Did we investigate how inheritance works for Minimal APIs when it comes to openApi doc generation?
Additional information.
Packages
`
We enabled polymorphism and added explicit annotations. List Known Subtypes for Inheritance and Polymorphism and Enrich Polymorphic Base Classes with Discriminator Metadata
The rest Api Endpoints worked as intended fine using Postman. However, we could not get it to work with the Swagger UI. Since one of the requirements where that external developers where to be able to use Swagger UI we used a different approach.
I still think it would be interesting to know if it is possible to configure Swagger and Swagger UI to work with polymorphism and request parameters.
I have followed the instructions regarding polymorphic model binding here (https://docs.microsoft.com/en-us/aspnet/core/mvc/advanced/custom-model-binding?view=aspnetcore-6.0#polymorphic-model-binding). Which works great.
However, I'm missing information on how to get this to work with Swagger. I have configured Swagger to support polymorphic model behaviour according to the Swagger documentation. Unfortunately I have not figured out any way to include parameters from derived classes. Is there any way to configure Swagger to display the correct input fields depending on the "kind" type? If not, is there any way to configure Swagger to only display an input field so that I can manually add the form data (application/x-www-form-urlencoded encoded) to the request?
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.