File tree Expand file tree Collapse file tree 2 files changed +80
-0
lines changed
test/Microsoft.OpenApi.Readers.Tests/V2Tests Expand file tree Collapse file tree 2 files changed +80
-0
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 . Tests ;
14
15
using Xunit ;
15
16
16
17
namespace Microsoft . OpenApi . Readers . Tests . V2Tests
@@ -434,5 +435,56 @@ public void ParseOperationWithBodyAndEmptyConsumesSetsRequestBodySchemaIfExists(
434
435
// Assert
435
436
operation . Should ( ) . BeEquivalentTo ( _operationWithBody ) ;
436
437
}
438
+
439
+ [ Fact ]
440
+ public void ParseV2ResponseWithExamplesExtensionWorks ( )
441
+ {
442
+ // Arrange
443
+ MapNode node ;
444
+ using ( var stream = Resources . GetStream ( Path . Combine ( SampleFolderPath , "opWithResponseExamplesExtension.yaml" ) ) )
445
+ {
446
+ node = TestHelper . CreateYamlMapNode ( stream ) ;
447
+ }
448
+
449
+ // Act
450
+ var operation = OpenApiV2Deserializer . LoadOperation ( node ) ;
451
+ var actual = operation . SerializeAsYaml ( OpenApiSpecVersion . OpenApi3_0 ) ;
452
+
453
+ // Assert
454
+ var expected = @"summary: Get all pets
455
+ responses:
456
+ '200':
457
+ description: Successful response
458
+ content:
459
+ application/json:
460
+ schema:
461
+ type: array
462
+ items:
463
+ type: object
464
+ properties:
465
+ name:
466
+ type: string
467
+ age:
468
+ type: integer
469
+ examples:
470
+ example1:
471
+ summary: Example - List of Pets
472
+ value:
473
+ - name: Buddy
474
+ age: 2
475
+ - name: Whiskers
476
+ age: 1
477
+ example2:
478
+ summary: Example - Playful Cat
479
+ value:
480
+ name: Whiskers
481
+ age: 1" ;
482
+
483
+ // Assert
484
+ actual = actual . MakeLineBreaksEnvironmentNeutral ( ) ;
485
+ expected = expected . MakeLineBreaksEnvironmentNeutral ( ) ;
486
+ actual . Should ( ) . Be ( expected ) ;
487
+ //Assert.Equal(expected, actual);
488
+ }
437
489
}
438
490
}
Original file line number Diff line number Diff line change
1
+ summary : Get all pets
2
+ produces :
3
+ - application/json
4
+ responses :
5
+ ' 200 ' :
6
+ description : Successful response
7
+ schema :
8
+ type : array
9
+ items :
10
+ type : object
11
+ properties :
12
+ name :
13
+ type : string
14
+ age :
15
+ type : integer
16
+ x-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