File tree Expand file tree Collapse file tree 2 files changed +79
-1
lines changed
test/Microsoft.OpenApi.Readers.Tests/V2Tests Expand file tree Collapse file tree 2 files changed +79
-1
lines changed Original file line number Diff line number Diff line change 11
11
using Microsoft . OpenApi . Models ;
12
12
using Microsoft . OpenApi . Readers . ParseNodes ;
13
13
using Microsoft . OpenApi . Readers . V2 ;
14
+ using Microsoft . OpenApi . Readers . V3 ;
14
15
using Microsoft . OpenApi . Tests ;
15
16
using Xunit ;
16
17
@@ -484,7 +485,56 @@ public void ParseV2ResponseWithExamplesExtensionWorks()
484
485
actual = actual . MakeLineBreaksEnvironmentNeutral ( ) ;
485
486
expected = expected . MakeLineBreaksEnvironmentNeutral ( ) ;
486
487
actual . Should ( ) . Be ( expected ) ;
487
- //Assert.Equal(expected, actual);
488
+ }
489
+
490
+ [ Fact ]
491
+ public void LoadV3ExamplesInResponseAsExtensionsWorks ( )
492
+ {
493
+ // Arrange
494
+ MapNode node ;
495
+ using ( var stream = Resources . GetStream ( Path . Combine ( SampleFolderPath , "v3OperationWithResponseExamples.yaml" ) ) )
496
+ {
497
+ node = TestHelper . CreateYamlMapNode ( stream ) ;
498
+ }
499
+
500
+ // Act
501
+ var operation = OpenApiV3Deserializer . LoadOperation ( node ) ;
502
+ var actual = operation . SerializeAsYaml ( OpenApiSpecVersion . OpenApi2_0 ) ;
503
+
504
+ // Assert
505
+ var expected = @"summary: Get all pets
506
+ produces:
507
+ - application/json
508
+ responses:
509
+ '200':
510
+ description: Successful response
511
+ schema:
512
+ type: array
513
+ items:
514
+ type: object
515
+ properties:
516
+ name:
517
+ type: string
518
+ age:
519
+ type: integer
520
+ x-examples:
521
+ example1:
522
+ summary: Example - List of Pets
523
+ value:
524
+ - name: Buddy
525
+ age: 2
526
+ - name: Whiskers
527
+ age: 1
528
+ example2:
529
+ summary: Example - Playful Cat
530
+ value:
531
+ name: Whiskers
532
+ age: 1" ;
533
+
534
+ // Assert
535
+ actual = actual . MakeLineBreaksEnvironmentNeutral ( ) ;
536
+ expected = expected . MakeLineBreaksEnvironmentNeutral ( ) ;
537
+ actual . Should ( ) . Be ( expected ) ;
488
538
}
489
539
}
490
540
}
Original file line number Diff line number Diff line change
1
+ summary : Get all pets
2
+ responses :
3
+ ' 200 ' :
4
+ description : Successful response
5
+ content :
6
+ application/json :
7
+ schema :
8
+ type : array
9
+ items :
10
+ type : object
11
+ properties :
12
+ name :
13
+ type : string
14
+ age :
15
+ type : integer
16
+ examples :
17
+ example1 :
18
+ summary : Example - List of Pets
19
+ value :
20
+ - name : " Buddy"
21
+ age : 2
22
+ - name : " Whiskers"
23
+ age : 1
24
+ example2 :
25
+ summary : Example - Playful Cat
26
+ value :
27
+ name : " Whiskers"
28
+ age : 1
You can’t perform that action at this time.
0 commit comments