Azure / azure-functions-openapi-extension

This extension provides an Azure Functions app with Open API capability for better discoverability to consuming parties
https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.OpenApi/
MIT License
370 stars 194 forks source link

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

Open geetikaPaul opened 4 months ago

geetikaPaul commented 4 months ago

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.