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

Incorrect schema generated for PATCH requests when using Microsoft.AspNetCore.JsonPatch library #657

Open
geetikaPaul opened this issue May 27, 2024 · 0 comments

Comments

@geetikaPaul
Copy link

Describe the issue
Incorrect schema generated for PATCH requests when using Microsoft.AspNetCore.JsonPatch library

Steps to reproduce the behavior:

  1. Create a PATCH endpoint with request body type as JsonPatchDocument
  2. Run the application and open Swagger UI
  3. Go to PATCH endpoint
  4. The expected schema is
    [
    {
    "op": "string",
    "value": {},
    "path": "string"
    }
    ]
    but generated is
    {
    "operations": [
    {
    "op": "string",
    "value": {},
    "path": "string"
    }
    ]
    }

If we send request with the generated schema the JsonPatch libaray throws the following error: "The JSON patch document was malformed and could not be parsed."

test from jsonpatch library stating "operations" property is unexpected : https://github.com/dotnet/aspnetcore/blob/13a7e9d7223e2041fa4efa0aebf1a7c375a5670f/src/Features/JsonPatch/test/JsonPatchDocumentTest.cs#L129

This issue has been reported in https://michael-mckenna.com/swagger-with-asp-net-core-3-1-json-patch/ and a workaround is suggested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant