I'm making a Core 3.1 web API and using JsonPatch to create a PATCH action. I have an action named Patch
which has a JsonPatchDocument
parameter. Here is the action's signature:
[HttpPatch("{id}")]
public ActionResult<FileRecordDto> Patch(int id, [FromBody] JsonPatchDocument<FileRecordQueryParams> patchDoc)
As I understand, the parameter needs to receive JSON data in the following structure, which I've successfully tested with the action:
[
{
"op": "operationName",
"path": "/propertyName",
"value": "newPropertyValue"
}
]
However, the action's documentation generated by Swagger has a different structure:
I'm not familiar with this structure and even "value"
property is missing from it, which a JsonPatchDocument
object has. Every example of patching with the replace
operation I've seen has had the first structure.
Why is Swagger generating an alternate structure for a JsonPatchDocument
object in the request body for the PATCH endpoint? How do I fix this?