Skip to content

JSON Patch request body should use content-type application/json-patch+json #61956

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

Open
1 task done
mikekistler opened this issue May 15, 2025 · 0 comments · May be fixed by #62057
Open
1 task done

JSON Patch request body should use content-type application/json-patch+json #61956

mikekistler opened this issue May 15, 2025 · 0 comments · May be fixed by #62057
Assignees
Labels
area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc

Comments

@mikekistler
Copy link
Contributor

mikekistler commented May 15, 2025

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

A patch operation that accepts a JsonPatchDocument<T> that was added as part of the JSON Patch with System.Text.Json feature in .NET 10 preview 4 is shown in the generated OpenAPI document as accepting the media type "application/json". According to RFC 6902, the media type should be "application/json-patch+json".

Expected Behavior

A patch operation that accepts a JsonPatchDocument<T> should have a request body with media type "application/json-patch+json" in the generated OpenAPI document.

Steps To Reproduce

A minimal repro for this problem is in the "json-patch-media-type" directory of this repo:

https://github.com/mikekistler/dotnet10-issue-repros

Exceptions (if any)

No response

.NET Version

10.0.100-preview.4.25258.110

Implementation Plan

The JsonPatchDocument type should implement the IEndpointParameterMetadataProvider interface and add the appropriate AcceptsMetadata with the "application/json-patch+json" content-type. Test coverage should be added to assert the correct behavior of the type when used in an OpenAPI document by adding an endpoint that takes a JsonPatchDocument to this test file (https://github.com/dotnet/aspnetcore/blob/c5d6996bd22e916b04aa792185b2fd2214ae22fe/src/OpenApi/sample/Endpoints/MapSchemasEndpoints.cs) and updating the snapshot tests.

@mikekistler mikekistler added the area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc label May 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant