Azure / Azure/azure-functions-openapi-extension

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

Open
#657 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
388
Forks
202
PR merge metrics
No merged PRs in 30d

Description

**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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.