dotnet / dotnet/aspnetcore

ProducesResponseTypeAttribute should set content-type for 4xx status codes to application/problem+json

Open
#58,137 0 comments 0 reactions 0 assignees View on GitHub
area-mvc feature-openapi
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Is your feature request related to a problem? Please describe the problem.

In a controller-based app, the ProducesResponseTypeAttribute will default the response body type to `ProblemDetails` when the status code specified in the issue is in the range 400-499. However, it uses the same default content type of ["text/plain", "application/json", "text/json"] as for 2xx responses. This seems inconsistent.

related: #39802

### Describe the solution you'd like

The default content type should be "application/problem+json" for 4xx status codes.

### Additional context

_No response_

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.