dotnet / dotnet/AspNetCore.Docs

Swagger - Polymorphic model binding

Open
#26,921 3 comments 1 reaction 1 assignee Claimed by @rafikiassumani-msft View on GitHub
re-Safia Source - Docs.ms support-request
Dominant language
C#
Stars
13.1k
Forks
24.6k
Avg merge
1d 3h
Merged PRs (30d)
97

Description

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.*

* ID: cfb00531-4ac6-8bf6-9bd8-1eed6446397f
* Version Independent ID: ed418d09-6c33-699a-0d48-9aabc99457be
* Content: [Custom Model Binding in ASP.NET Core](https://docs.microsoft.com/en-us/aspnet/core/mvc/advanced/custom-model-binding?view=aspnetcore-5.0)
* Content Source: [aspnetcore/mvc/advanced/custom-model-binding.md](https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/mvc/advanced/custom-model-binding.md)
* Product: **aspnet-core**
* Technology: **aspnetcore-mvc**
* GitHub Login: @ardalis
* Microsoft Alias: **riande**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.