Skip to content

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

Closed

Description

@mikekistler

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.

Activity

  1. added
    area-minimal
    on May 15, 2025
  2. added this to the Backlog milestone on Jul 29, 2025
  3. mikekistler commented on Jul 29, 2025

    @mikekistler
    Author

    @captainsafia If we choose not to fix this in .NET 10, will it be considered a breaking change if we fix it in .NET 11 or later?

  4. added a commit that references this issue on Jul 29, 2025
    4f0673b
  5. martincostello commented on Jul 29, 2025

    @martincostello
    Member

    I picked up where Copilot got to, fixed it up and opened #62988 to make this change (correctly I hope...).

  6. added a commit that references this issue on Aug 1, 2025
    9720579
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-minimal

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions