@@ -483,15 +483,15 @@ public async Task SerializeAsV32JsonWithQueryAndAdditionalOperationsWorks()
483483 "query": {
484484 "summary": "query operation",
485485 "description": "query description",
486- "operationId": "queryOperation",
486+ "operationId": "queryOperation",
487487 "responses": {
488488 "200": {
489489 "description": "query success"
490490 }
491491 }
492492 },
493493 "additionalOperations": {
494- "notify ": {
494+ "Notify ": {
495495 "summary": "notify operation",
496496 "description": "notify description",
497497 "operationId": "notifyOperation",
@@ -501,9 +501,9 @@ public async Task SerializeAsV32JsonWithQueryAndAdditionalOperationsWorks()
501501 }
502502 }
503503 },
504- "custom ": {
504+ "Custom ": {
505505 "summary": "custom operation",
506- "description": "custom description",
506+ "description": "custom description",
507507 "operationId": "customOperation",
508508 "responses": {
509509 "200": {
@@ -575,14 +575,13 @@ public async Task SerializeV32FeaturesAsExtensionsInV31Works()
575575
576576 // When
577577 var actualJson = await pathItem . SerializeAsJsonAsync ( OpenApiSpecVersion . OpenApi3_1 ) ;
578- var parsedActualJson = JsonNode . Parse ( actualJson ) ;
578+ var parsedActualJson = Assert . IsType < JsonObject > ( JsonNode . Parse ( actualJson ) ) ;
579579
580- // Then - should contain x-oas- prefixed extensions in the operation
581- var getOperation = parsedActualJson ! [ "get" ] ;
582- Assert . True ( getOperation ! [ "x-oas-query" ] != null ) ;
583- Assert . True ( getOperation ! [ "x-oas-additionalOperations" ] != null ) ;
584- Assert . Equal ( "query operation" , getOperation ! [ "x-oas-query" ] ! [ "summary" ] ! . GetValue < string > ( ) ) ;
585- Assert . Equal ( "notify operation" , getOperation ! [ "x-oas-additionalOperations" ] ! [ "notify" ] ! [ "summary" ] ! . GetValue < string > ( ) ) ;
580+ // Then - should contain x-oai- prefixed extensions in the operation
581+ var additionalOperationsElement = Assert . IsType < JsonObject > ( Assert . Contains ( "x-oai-additionalOperations" , parsedActualJson ) ) ;
582+ var queryElement = Assert . IsType < JsonObject > ( Assert . Contains ( "Query" , additionalOperationsElement ) ) ;
583+ Assert . Equal ( "query operation" , queryElement [ "summary" ] ! . GetValue < string > ( ) ) ;
584+ Assert . Equal ( "notify operation" , additionalOperationsElement [ "Notify" ] ! [ "summary" ] ! . GetValue < string > ( ) ) ;
586585 }
587586
588587 [ Fact ]
@@ -635,14 +634,13 @@ public async Task SerializeV32FeaturesAsExtensionsInV3Works()
635634
636635 // When
637636 var actualJson = await pathItem . SerializeAsJsonAsync ( OpenApiSpecVersion . OpenApi3_0 ) ;
638- var parsedActualJson = JsonNode . Parse ( actualJson ) ;
637+ var parsedActualJson = Assert . IsType < JsonObject > ( JsonNode . Parse ( actualJson ) ) ;
639638
640- // Then - should contain x-oas- prefixed extensions in the operation
641- var getOperation = parsedActualJson ! [ "get" ] ;
642- Assert . True ( getOperation ! [ "x-oas-query" ] != null ) ;
643- Assert . True ( getOperation ! [ "x-oas-additionalOperations" ] != null ) ;
644- Assert . Equal ( "query operation" , getOperation ! [ "x-oas-query" ] ! [ "summary" ] ! . GetValue < string > ( ) ) ;
645- Assert . Equal ( "notify operation" , getOperation ! [ "x-oas-additionalOperations" ] ! [ "notify" ] ! [ "summary" ] ! . GetValue < string > ( ) ) ;
639+ // Then - should contain x-oai- prefixed extensions in the operation
640+ var additionalOperationsElement = Assert . IsType < JsonObject > ( Assert . Contains ( "x-oai-additionalOperations" , parsedActualJson ) ) ;
641+ var queryElement = Assert . IsType < JsonObject > ( Assert . Contains ( "Query" , additionalOperationsElement ) ) ;
642+ Assert . Equal ( "query operation" , queryElement [ "summary" ] ! . GetValue < string > ( ) ) ;
643+ Assert . Equal ( "notify operation" , additionalOperationsElement [ "Notify" ] ! [ "summary" ] ! . GetValue < string > ( ) ) ;
646644 }
647645
648646 [ Fact ]
@@ -695,14 +693,13 @@ public async Task SerializeV32FeaturesAsExtensionsInV2Works()
695693
696694 // When
697695 var actualJson = await pathItem . SerializeAsJsonAsync ( OpenApiSpecVersion . OpenApi2_0 ) ;
698- var parsedActualJson = JsonNode . Parse ( actualJson ) ;
696+ var parsedActualJson = Assert . IsType < JsonObject > ( JsonNode . Parse ( actualJson ) ) ;
699697
700- // Then - should contain x-oas- prefixed extensions in the operation
701- var getOperation = parsedActualJson ! [ "get" ] ;
702- Assert . True ( getOperation ! [ "x-oas-query" ] != null ) ;
703- Assert . True ( getOperation ! [ "x-oas-additionalOperations" ] != null ) ;
704- Assert . Equal ( "query operation" , getOperation ! [ "x-oas-query" ] ! [ "summary" ] ! . GetValue < string > ( ) ) ;
705- Assert . Equal ( "notify operation" , getOperation ! [ "x-oas-additionalOperations" ] ! [ "notify" ] ! [ "summary" ] ! . GetValue < string > ( ) ) ;
698+ // Then - should contain x-oai- prefixed extensions in the operation
699+ var additionalOperationsElement = Assert . IsType < JsonObject > ( Assert . Contains ( "x-oai-additionalOperations" , parsedActualJson ) ) ;
700+ var queryElement = Assert . IsType < JsonObject > ( Assert . Contains ( "Query" , additionalOperationsElement ) ) ;
701+ Assert . Equal ( "query operation" , queryElement [ "summary" ] ! . GetValue < string > ( ) ) ;
702+ Assert . Equal ( "notify operation" , additionalOperationsElement [ "Notify" ] ! [ "summary" ] ! . GetValue < string > ( ) ) ;
706703 }
707704
708705 [ Fact ]
@@ -739,28 +736,17 @@ public void CopyConstructorCopiesQueryAndAdditionalOperations()
739736 // Assert
740737 Assert . NotNull ( original . Operations ) ;
741738 Assert . NotNull ( copy . Operations ) ;
742- var originalGetOp = original . Operations [ HttpMethod . Get ] ;
743- var copyGetOp = copy . Operations [ HttpMethod . Get ] ;
739+ Assert . Contains ( HttpMethod . Get , original . Operations ) ;
740+ Assert . Contains ( HttpMethod . Get , copy . Operations ) ;
744741
745- Assert . NotNull ( originalGetOp ) ;
746- Assert . NotNull ( copyGetOp ) ;
747-
748- var copyQueryOp = copy . Operations [ new HttpMethod ( "Query" ) ] ;
749- var originalQueryOp = original . Operations [ new HttpMethod ( "Query" ) ] ;
750- Assert . NotNull ( copyQueryOp ) ;
751- Assert . NotNull ( originalQueryOp ) ;
752- Assert . Equal ( originalQueryOp ! . Summary , copyQueryOp . Summary ) ;
742+ var copyQueryOp = Assert . Contains ( new HttpMethod ( "Query" ) , copy . Operations ) ;
743+ var originalQueryOp = Assert . Contains ( new HttpMethod ( "Query" ) , original . Operations ) ;
744+ Assert . Equal ( originalQueryOp . Summary , copyQueryOp . Summary ) ;
753745 Assert . Equal ( originalQueryOp . OperationId , copyQueryOp . OperationId ) ;
754746
755- var originalNotifyOp = original . Operations [ new HttpMethod ( "Notify" ) ] ;
756- var copyNotifyOp = copy . Operations [ new HttpMethod ( "Notify" ) ] ;
757- Assert . NotNull ( originalNotifyOp ) ;
758- Assert . NotNull ( copyNotifyOp ) ;
747+ var originalNotifyOp = Assert . Contains ( new HttpMethod ( "Notify" ) , original . Operations ) ;
748+ var copyNotifyOp = Assert . Contains ( new HttpMethod ( "Notify" ) , copy . Operations ) ;
759749
760750 Assert . Equal ( originalNotifyOp . Summary , copyNotifyOp . Summary ) ;
761-
762- // Verify it's a deep copy
763- copyQueryOp . Summary = "modified" ;
764- Assert . NotEqual ( originalQueryOp . Summary , copyQueryOp . Summary ) ;
765751 }
766752}
0 commit comments