Support multiple response types with the same status code in ApiExplorer #55412
Labels
area-minimal
Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc
area-mvc
Includes: MVC, Actions and Controllers, Localization, CORS, most templates
feature-openapi
Milestone
Is there an existing issue for this?
Is your feature request related to a problem? Please describe the problem.
When using the
ProducesResponseType
attribute to specify multiple response types with the same status code only the last specified status code will be exposed. This limitation affects scenarios where an endpoint might return different types for the same HTTP status code based on business logic. For example in the following theFoo
type would not be included in the response metadata.This is due to the status code being used as the key in the results dictionary when reading the response metadata https://github.com/dotnet/aspnetcore/blob/main/src/Mvc/Mvc.ApiExplorer/src/ApiResponseTypeProvider.cs#L210.
Describe the solution you'd like
All specified response types to be included in
SupportedResponseTypes
when there are multiple response types with the same status code.Additional context
Related to domaindrivendev/Swashbuckle.AspNetCore#2743.
The text was updated successfully, but these errors were encountered: