https://github.com/angularsen/repro-aspnetcore-19510
Reproduce https://github.com/dotnet/aspnetcore/issues/19510
https://github.com/angularsen/repro-aspnetcore-19510
Last synced: 4 months ago
JSON representation
Reproduce https://github.com/dotnet/aspnetcore/issues/19510
- Host: GitHub
- URL: https://github.com/angularsen/repro-aspnetcore-19510
- Owner: angularsen
- License: mit
- Created: 2022-01-27T09:00:12.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-01-27T09:15:38.000Z (over 3 years ago)
- Last Synced: 2025-01-11T10:37:33.598Z (6 months ago)
- Language: C#
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Repro dotnet/aspnetcore/issues/19510
[Media type application/problem+json lost in combination with ProducesAttribute - PR 19510 - dotnet/aspnetcore](https://github.com/dotnet/aspnetcore/issues/19510)
```shell
dotnet run
```### ✅ Test 1 - Problem() without [Produces]
Returns `application/problem+json` as expected.```shell
curl -i http://localhost:5106/test/1
``````http request
HTTP/1.1 500 Internal Server Error
Content-Type: application/problem+json; charset=utf-8
Date: Thu, 27 Jan 2022 07:53:16 GMT
Server: Kestrel
Transfer-Encoding: chunked{"type":"https://tools.ietf.org/html/rfc7231#section-6.6.1","title":"An error occurred while processing your request.","status":500,"detail":"Test1 ✅ - Problem(string) without ProducesAttribute => returns application/problem+json. Assembly: C:\\Program Files\\dotnet\\shared\\Microsoft.AspNetCore.App\\6.0.1\\Microsoft.AspNetCore.Mvc.Core.dll","traceId":"00-f837e61b4f3fe38e1326d4b736ce4b1b-5f42df452447a45b-00"}
```### ❌ Test 2 - Problem() with [Produces("application/json")]
Returns `application/json` instead of expected `application/problem+json`.```shell
curl -i http://localhost:5106/test/2
``````http request
HTTP/1.1 500 Internal Server Error
Content-Type: application/json; charset=utf-8
Date: Thu, 27 Jan 2022 07:54:47 GMT
Server: Kestrel
Transfer-Encoding: chunked{"type":"https://tools.ietf.org/html/rfc7231#section-6.6.1","title":"An error occurred while processing your request.","status":500,"detail":"Test2 ❌ - Problem(string) with [Produces(\"application/json\")] => incorrectly returns application/json instead of application/problem+json. Assembly: C:\\Program Files\\dotnet\\shared\\Microsoft.AspNetCore.App\\6.0.1\\Microsoft.AspNetCore.Mvc.Core.dll","traceId":"00-7898b5db7c72df8b1589c0776c857321-1145d480210ea6e5-00"}
```### ❌ Test 3 - Problem() with [Produces("application/json", "application/problem+json")]
Returns `application/json` instead of expected `application/problem+json`.```shell
curl -i http://localhost:5106/test/3
``````http request
HTTP/1.1 500 Internal Server Error
Content-Type: application/json; charset=utf-8
Date: Thu, 27 Jan 2022 08:50:00 GMT
Server: Kestrel
Transfer-Encoding: chunked{"type":"https://tools.ietf.org/html/rfc7231#section-6.6.1","title":"An error occurred while processing your request.","status":500,"detail":"Test3 ❌ - Problem(string) with [Produces(\"application/json\", \"application/problem+json\")] => incorrectly returns application/json instead of application/problem+json. Assembly: C:\\Program Files\\dotnet\\shared\\Microsoft.AspNetCore.App\\6.0.1\\Microsoft.AspNetCore.Mvc.Core.dll","traceId":"00-4e825df690029941d19792a19b6e1346-1e417b4f47ca76cf-00"}
```### ❌ Test 4 - Problem() with [Produces("application/problem+json", "application/json")]
Returns `application/problem+json`, but then `Ok(object)` also returns `application/problem+json` instead of expected `application/json`.```shell
curl -i http://localhost:5106/test/4
``````http request
HTTP/1.1 500 Internal Server Error
Content-Type: application/problem+json; charset=utf-8
Date: Thu, 27 Jan 2022 07:55:05 GMT
Server: Kestrel
Transfer-Encoding: chunked{"type":"https://tools.ietf.org/html/rfc7231#section-6.6.1","title":"An error occurred while processing your request.","status":500,"detail":"Test4 ❌ - Problem(string) with [Produces(\"application/problem+json\", \"application/json\")] => returns content-type application/problem+json, but then Ok(string) also returns application/problem+json. Assembly: C:\\Program Files\\dotnet\\shared\\Microsoft.AspNetCore.App\\6.0.1\\Microsoft.AspNetCore.Mvc.Core.dll","traceId":"00-cb867abbe8d88fbced809ff7764199fe-bb8a5378a54e6789-00"}
```