File tree Expand file tree Collapse file tree 2 files changed +58
-0
lines changed
test/Microsoft.OpenApi.Readers.Tests/V3Tests Expand file tree Collapse file tree 2 files changed +58
-0
lines changed Original file line number Diff line number Diff line change 44using System . IO ;
55using FluentAssertions ;
66using Microsoft . OpenApi . Any ;
7+ using Microsoft . OpenApi . Extensions ;
78using Microsoft . OpenApi . Models ;
89using Microsoft . OpenApi . Readers . ParseNodes ;
910using Microsoft . OpenApi . Readers . V3 ;
11+ using Microsoft . OpenApi . Tests ;
1012using Xunit ;
1113
1214namespace Microsoft . OpenApi . Readers . Tests . V3Tests
@@ -77,5 +79,43 @@ public void ParseMediaTypeWithExamplesShouldSucceed()
7779 }
7880 } ) ;
7981 }
82+
83+ [ Fact ]
84+ public void ParseMediaTypeWithEmptyArrayInExamplesWorks ( )
85+ {
86+ // Arrange
87+ var expected = @"{
88+ ""schema"": {
89+ ""type"": ""array"",
90+ ""items"": {
91+ ""type"": ""object"",
92+ ""properties"": {
93+ ""id"": {
94+ ""type"": ""string""
95+ }
96+ }
97+ }
98+ },
99+ ""examples"": {
100+ ""Success response - no results"": {
101+ ""value"": [ ]
102+ }
103+ }
104+ }
105+ " ;
106+ MapNode node ;
107+ using ( var stream = Resources . GetStream ( Path . Combine ( SampleFolderPath , "examplesWithEmptyArray.json" ) ) )
108+ {
109+ node = TestHelper . CreateYamlMapNode ( stream ) ;
110+ }
111+
112+ // Act
113+ var mediaType = OpenApiV3Deserializer . LoadMediaType ( node ) ;
114+ var serialized = mediaType . SerializeAsJson ( OpenApiSpecVersion . OpenApi3_0 ) ;
115+
116+ // Assert
117+ serialized . MakeLineBreaksEnvironmentNeutral ( )
118+ . Should ( ) . BeEquivalentTo ( expected . MakeLineBreaksEnvironmentNeutral ( ) ) ;
119+ }
80120 }
81121}
Original file line number Diff line number Diff line change 1+ {
2+ "schema" : {
3+ "type" : " array" ,
4+ "items" : {
5+ "type" : " object" ,
6+ "properties" : {
7+ "id" : {
8+ "type" : " string"
9+ }
10+ }
11+ }
12+ },
13+ "examples" : {
14+ "Success response - no results" : {
15+ "value" : []
16+ }
17+ }
18+ }
You can’t perform that action at this time.
0 commit comments