JSON Patch Support with Swagger and ASP.NET Core 3.1

Getting Swagger and JsonPatchDocument to play nice

Introduction .NET Core has great support for JsonPatch which looks a little something like this public async Task<ActionResult> UpdateUser(string id,[FromBody] JsonPatchDocument<UserUpdateModel> patchDoc) { ... } And we expect a request to come in with a body like [{ "value": "Gordon", "path": "/name", "op": "replace" }, { "value": "Freeman", "path": "/surname", "op": "replace" }] However if you’re using the Swashbuckle.AspNetCore.Swagger library it will generate a description for the parameter type which is normally fine, but in this case it’s JsonPatchDocument<UserUpdateModel> which doesn’t represent the expected patch request doument. [Read More]