-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Media type application/problem+json lost in combination with ProducesAttribute #19510
Copy link
Copy link
Closed
Labels
DoneThis issue has been fixedThis issue has been fixedaffected-mediumThis issue impacts approximately half of our customersThis issue impacts approximately half of our customersarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.feature-mvc-execution-pipelineFeatures related to how MVC executes a controller or razor pageFeatures related to how MVC executes a controller or razor pageinvestigateseverity-majorThis label is used by an internal toolThis label is used by an internal tool
Milestone
Metadata
Metadata
Assignees
Labels
DoneThis issue has been fixedThis issue has been fixedaffected-mediumThis issue impacts approximately half of our customersThis issue impacts approximately half of our customersarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.feature-mvc-execution-pipelineFeatures related to how MVC executes a controller or razor pageFeatures related to how MVC executes a controller or razor pageinvestigateseverity-majorThis label is used by an internal toolThis label is used by an internal tool
Type
Fields
Give feedbackNo fields configured for issues without a type.
Describe the bug
I decorate a controller (action method) with the
ProducesAttributeto limit the response media type toapplication/json. If I return aProblemDetailsinstance from the controller (or the framework returns aValidationProblemDetailsinstance), the returned media type isapplication/json. If I leave out theProducesAttribute, the response has media typeapplication/problem+json.I am unsure if this is a bug or is by design.
What I am finally trying to achieve is to have a generated OpenAPI spec (using Swashbuckle.AspNetCore) indicating
application/problem+jsonfor my 400 responses, andapplication/jsonfor my 200 responses. Swashbuckle gets its information from the API Explorer from ASP.NET Core itself, this led me to this issue (or question).Similar issue found in this SO question (unanswered).
To Reproduce
See minimalistic repo with contrived example: https://github.com/ralphhendriks/aspnet-core-problem-details-media-type-issue
Further technical details
I am using ASP.NET Core version 3.1
Output of
dotnet --info:IDE used seems irrelevant (using both VS 2019 Enterprise Edition and VS Code with OmniSharp plugin).