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 4
4
using System . IO ;
5
5
using FluentAssertions ;
6
6
using Microsoft . OpenApi . Any ;
7
+ using Microsoft . OpenApi . Extensions ;
7
8
using Microsoft . OpenApi . Models ;
8
9
using Microsoft . OpenApi . Readers . ParseNodes ;
9
10
using Microsoft . OpenApi . Readers . V3 ;
11
+ using Microsoft . OpenApi . Tests ;
10
12
using Xunit ;
11
13
12
14
namespace Microsoft . OpenApi . Readers . Tests . V3Tests
@@ -77,5 +79,43 @@ public void ParseMediaTypeWithExamplesShouldSucceed()
77
79
}
78
80
} ) ;
79
81
}
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
+ }
80
120
}
81
121
}
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