@@ -1153,6 +1153,8 @@ await VerifyOpenApiDocument(builder, document =>
11531153 Assert . NotNull ( operation . RequestBody . Content ) ;
11541154 var content = Assert . Single ( operation . RequestBody . Content ) ;
11551155 Assert . Equal ( "application/json-patch+json" , content . Key ) ;
1156+ var schema = Assert . IsType < OpenApiSchemaReference > ( content . Value . Schema ) ;
1157+ Assert . Equal ( "JsonPatchDocument" , schema . Reference . Id ) ;
11561158 } ) ;
11571159 }
11581160
@@ -1206,6 +1208,8 @@ await VerifyOpenApiDocument(builder, document =>
12061208 Assert . NotNull ( operation . RequestBody . Content ) ;
12071209 var content = Assert . Single ( operation . RequestBody . Content ) ;
12081210 Assert . Equal ( "application/json-patch+json" , content . Key ) ;
1211+ var schema = Assert . IsType < OpenApiSchemaReference > ( content . Value . Schema ) ;
1212+ Assert . Equal ( "JsonPatchDocument" , schema . Reference . Id ) ;
12091213 } ) ;
12101214 }
12111215
@@ -1227,6 +1231,8 @@ await VerifyOpenApiDocument(builder, document =>
12271231 Assert . NotNull ( operation . RequestBody . Content ) ;
12281232 var content = Assert . Single ( operation . RequestBody . Content ) ;
12291233 Assert . Equal ( "application/vnd.github.patch+json" , content . Key ) ;
1234+ var schema = Assert . IsType < OpenApiSchemaReference > ( content . Value . Schema ) ;
1235+ Assert . Equal ( "JsonPatchDocument" , schema . Reference . Id ) ;
12301236 } ) ;
12311237 }
12321238
@@ -1248,6 +1254,8 @@ await VerifyOpenApiDocument(builder, document =>
12481254 Assert . NotNull ( operation . RequestBody . Content ) ;
12491255 var content = Assert . Single ( operation . RequestBody . Content ) ;
12501256 Assert . Equal ( "application/vnd.github.patch+json" , content . Key ) ;
1257+ var schema = Assert . IsType < OpenApiSchemaReference > ( content . Value . Schema ) ;
1258+ Assert . Equal ( "JsonPatchDocument" , schema . Reference . Id ) ;
12511259 } ) ;
12521260 }
12531261
@@ -1270,6 +1278,8 @@ await VerifyOpenApiDocument(builder, document =>
12701278 Assert . NotNull ( operation . RequestBody . Content ) ;
12711279 var content = Assert . Single ( operation . RequestBody . Content ) ;
12721280 Assert . Equal ( "application/json-patch+json" , content . Key ) ;
1281+ var schema = Assert . IsType < OpenApiSchemaReference > ( content . Value . Schema ) ;
1282+ Assert . Equal ( "JsonPatchDocument" , schema . Reference . Id ) ;
12731283 } ) ;
12741284 }
12751285
@@ -1323,6 +1333,8 @@ await VerifyOpenApiDocument(builder, document =>
13231333 Assert . NotNull ( operation . RequestBody . Content ) ;
13241334 var content = Assert . Single ( operation . RequestBody . Content ) ;
13251335 Assert . Equal ( "application/json-patch+json" , content . Key ) ;
1336+ var schema = Assert . IsType < OpenApiSchemaReference > ( content . Value . Schema ) ;
1337+ Assert . Equal ( "JsonPatchDocument" , schema . Reference . Id ) ;
13261338 } ) ;
13271339 }
13281340
@@ -1345,6 +1357,8 @@ await VerifyOpenApiDocument(builder, document =>
13451357 Assert . NotNull ( operation . RequestBody . Content ) ;
13461358 var content = Assert . Single ( operation . RequestBody . Content ) ;
13471359 Assert . Equal ( "application/vnd.github.patch+json" , content . Key ) ;
1360+ var schema = Assert . IsType < OpenApiSchemaReference > ( content . Value . Schema ) ;
1361+ Assert . Equal ( "JsonPatchDocument" , schema . Reference . Id ) ;
13481362 } ) ;
13491363 }
13501364
@@ -1366,6 +1380,8 @@ await VerifyOpenApiDocument(builder, document =>
13661380 Assert . NotNull ( operation . RequestBody . Content ) ;
13671381 var content = Assert . Single ( operation . RequestBody . Content ) ;
13681382 Assert . Equal ( "application/vnd.github.patch+json" , content . Key ) ;
1383+ var schema = Assert . IsType < OpenApiSchemaReference > ( content . Value . Schema ) ;
1384+ Assert . Equal ( "JsonPatchDocument" , schema . Reference . Id ) ;
13691385 } ) ;
13701386 }
13711387
@@ -1379,4 +1395,56 @@ private sealed class JsonPatchModel
13791395 public string ? Second { get ; set ; }
13801396 }
13811397#nullable restore
1398+
1399+ [ Fact ]
1400+ public async Task GetRequestBody_HandlesCustomJsonPatchBody ( )
1401+ {
1402+ // Arrange
1403+ var builder = CreateBuilder ( ) ;
1404+
1405+ // Act
1406+ builder . MapPatch ( "/" , ( CustomJsonPatchDocument patch ) => { } ) ;
1407+
1408+ // Assert
1409+ await VerifyOpenApiDocument ( builder , document =>
1410+ {
1411+ var paths = Assert . Single ( document . Paths . Values ) ;
1412+ var operation = paths . Operations [ HttpMethod . Patch ] ;
1413+ Assert . NotNull ( operation . RequestBody ) ;
1414+ Assert . False ( operation . RequestBody . Required ) ;
1415+ Assert . NotNull ( operation . RequestBody . Content ) ;
1416+ var content = Assert . Single ( operation . RequestBody . Content ) ;
1417+ Assert . Equal ( "application/json-patch+json" , content . Key ) ;
1418+ var schema = Assert . IsType < OpenApiSchemaReference > ( content . Value . Schema ) ;
1419+ Assert . Equal ( "JsonPatchDocument" , schema . Reference . Id ) ;
1420+ } ) ;
1421+ }
1422+
1423+ private class CustomJsonPatchDocument : JsonPatchDocument ;
1424+
1425+ [ Fact ]
1426+ public async Task GetRequestBody_HandlesGenericCustomJsonPatchBody( )
1427+ {
1428+ // Arrange
1429+ var builder = CreateBuilder ( ) ;
1430+
1431+ // Act
1432+ builder . MapPatch ( "/ ", (CustomJsonPatchDocument<JsonPatchModel> patch) => { });
1433+
1434+ // Assert
1435+ await VerifyOpenApiDocument ( builder , document =>
1436+ {
1437+ var paths = Assert . Single ( document . Paths . Values ) ;
1438+ var operation = paths . Operations [ HttpMethod . Patch ] ;
1439+ Assert . NotNull ( operation . RequestBody ) ;
1440+ Assert . False ( operation . RequestBody . Required ) ;
1441+ Assert . NotNull ( operation . RequestBody . Content ) ;
1442+ var content = Assert . Single ( operation . RequestBody . Content ) ;
1443+ Assert . Equal ( "application/json-patch+json" , content . Key ) ;
1444+ var schema = Assert . IsType < OpenApiSchemaReference > ( content . Value . Schema ) ;
1445+ Assert . Equal ( "JsonPatchDocument" , schema . Reference . Id ) ;
1446+ } ) ;
1447+ }
1448+
1449+ private class CustomJsonPatchDocument < T > : JsonPatchDocument < T > where T : class ;
13821450}
0 commit comments