dotnet / dotnet/aspnetcore

Unable to set different content-types for different response types for an endpoint

Open
#19,029 1 comment 1 reaction 0 assignees View on GitHub
affected-very-few area-mvc enhancement feature-openapi severity-major
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

In my OpenAPI document, I would like to be able to set different content-types for different response types.

For e.g for a GET request, I would like to set `application/json` for a _200_ object result and `application/problem+json` for _404_ problem details result. So `ProducesResponseType `should take content-type as an optional parameter in the constructor or `Produces` should take status code.

Currently, I can only set the content-type(s) in the `Produces` filter. But this applies the content-types to all the response types.

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.