@@ -483,15 +483,15 @@ public async Task SerializeAsV32JsonWithQueryAndAdditionalOperationsWorks()
483
483
"query": {
484
484
"summary": "query operation",
485
485
"description": "query description",
486
- "operationId": "queryOperation",
486
+ "operationId": "queryOperation",
487
487
"responses": {
488
488
"200": {
489
489
"description": "query success"
490
490
}
491
491
}
492
492
},
493
493
"additionalOperations": {
494
- "notify ": {
494
+ "Notify ": {
495
495
"summary": "notify operation",
496
496
"description": "notify description",
497
497
"operationId": "notifyOperation",
@@ -501,9 +501,9 @@ public async Task SerializeAsV32JsonWithQueryAndAdditionalOperationsWorks()
501
501
}
502
502
}
503
503
},
504
- "custom ": {
504
+ "Custom ": {
505
505
"summary": "custom operation",
506
- "description": "custom description",
506
+ "description": "custom description",
507
507
"operationId": "customOperation",
508
508
"responses": {
509
509
"200": {
@@ -575,14 +575,13 @@ public async Task SerializeV32FeaturesAsExtensionsInV31Works()
575
575
576
576
// When
577
577
var actualJson = await pathItem . SerializeAsJsonAsync ( OpenApiSpecVersion . OpenApi3_1 ) ;
578
- var parsedActualJson = JsonNode . Parse ( actualJson ) ;
578
+ var parsedActualJson = Assert . IsType < JsonObject > ( JsonNode . Parse ( actualJson ) ) ;
579
579
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 > ( ) ) ;
586
585
}
587
586
588
587
[ Fact ]
@@ -635,14 +634,13 @@ public async Task SerializeV32FeaturesAsExtensionsInV3Works()
635
634
636
635
// When
637
636
var actualJson = await pathItem . SerializeAsJsonAsync ( OpenApiSpecVersion . OpenApi3_0 ) ;
638
- var parsedActualJson = JsonNode . Parse ( actualJson ) ;
637
+ var parsedActualJson = Assert . IsType < JsonObject > ( JsonNode . Parse ( actualJson ) ) ;
639
638
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 > ( ) ) ;
646
644
}
647
645
648
646
[ Fact ]
@@ -695,14 +693,13 @@ public async Task SerializeV32FeaturesAsExtensionsInV2Works()
695
693
696
694
// When
697
695
var actualJson = await pathItem . SerializeAsJsonAsync ( OpenApiSpecVersion . OpenApi2_0 ) ;
698
- var parsedActualJson = JsonNode . Parse ( actualJson ) ;
696
+ var parsedActualJson = Assert . IsType < JsonObject > ( JsonNode . Parse ( actualJson ) ) ;
699
697
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 > ( ) ) ;
706
703
}
707
704
708
705
[ Fact ]
@@ -739,28 +736,17 @@ public void CopyConstructorCopiesQueryAndAdditionalOperations()
739
736
// Assert
740
737
Assert . NotNull ( original . Operations ) ;
741
738
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 ) ;
744
741
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 ) ;
753
745
Assert . Equal ( originalQueryOp . OperationId , copyQueryOp . OperationId ) ;
754
746
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 ) ;
759
749
760
750
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 ) ;
765
751
}
766
752
}
0 commit comments