The Wayback Machine - https://web.archive.org/web/20220127050444/https://github.com/dotnet/aspnetcore/issues/39802
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Media type application/problem+json still lost in combination with ProducesAttribute #39802

Open
1 task done
dsun1 opened this issue Jan 27, 2022 · 0 comments
Open
1 task done

Comments

@dsun1
Copy link

@dsun1 dsun1 commented Jan 27, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

This issue is the same as reported and resolved here: #19510

Having tested with the project that is the previous issue's minimal repro (in .NET 6 instead of .NET core 3.1), I've found the same issue still persists.

That is, a controller with ProducesAttribute set to application/json will set the response header media-type to application/json when it's returning a ProblemDetails or ValidationProblemDetails. It's supposed to return application/problem+json.

Expected Behavior

When the controller or framework returns a ProblemDetails or ValidationProblemDetails, the response header media type should be application/problem+json as per https://datatracker.ietf.org/doc/html/rfc7807#section-3

Steps To Reproduce

Minimalistic repro project: https://github.com/dsun1/ProblemMediaTypeIssue

Attribute a controller class or method with ProducesAttribute("application/json"). If that controller returns a problem, or if the framework returns a validation problem, the response media type will be application/json instead of application/problem+json.

Exceptions (if any)

No response

.NET Version

6.0.101

Anything else?

dotnet --info

.NET SDK (reflecting any global.json):
 Version:   6.0.101
 Commit:    ef49f6213a

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  11.0
 OS Platform: Darwin
 RID:         osx.10.16-x64
 Base Path:   /usr/local/share/dotnet/sdk/6.0.101/

Host (useful for support):
  Version: 6.0.1
  Commit:  3a25a7f1cc

.NET SDKs installed:
  2.1.818 [/usr/local/share/dotnet/sdk]
  3.1.416 [/usr/local/share/dotnet/sdk]
  5.0.404 [/usr/local/share/dotnet/sdk]
  6.0.101 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.30 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.30 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.22 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.13 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.30 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.22 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.13 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants