4
4
using System . Collections . Generic ;
5
5
using System . Globalization ;
6
6
using System . IO ;
7
- using System . Linq ;
8
7
using System . Threading ;
9
8
using FluentAssertions ;
10
9
using Microsoft . OpenApi . Any ;
@@ -159,25 +158,12 @@ public void ShouldParseProducesInAnyOrder()
159
158
Assert . NotNull ( doc . Paths [ "/items" ] ) ;
160
159
Assert . Equal ( 3 , doc . Paths [ "/items" ] . Operations . Count ) ;
161
160
162
- foreach ( var operation in doc . Paths [ "/items" ] . Operations )
161
+ var successSchema = new OpenApiSchema ( )
163
162
{
164
- Assert . Equal ( 2 , operation . Value . Responses . Count ) ;
165
-
166
- var okResponse = operation . Value . Responses [ "200" ] ;
167
- okResponse . ShouldBeEquivalentTo (
168
- new OpenApiResponse ( )
169
- {
170
- Description = "An OK response" ,
171
- Content =
172
- {
173
- [ "application/json" ] = new OpenApiMediaType ( )
174
- {
175
- Schema = new OpenApiSchema ( )
176
- {
177
- Type = "array" ,
178
- Items = new OpenApiSchema ( )
179
- {
180
- Properties = new Dictionary < string , OpenApiSchema > ( )
163
+ Type = "array" ,
164
+ Items = new OpenApiSchema ( )
165
+ {
166
+ Properties = new Dictionary < string , OpenApiSchema > ( )
181
167
{
182
168
{ "id" , new OpenApiSchema ( )
183
169
{
@@ -186,29 +172,16 @@ public void ShouldParseProducesInAnyOrder()
186
172
}
187
173
}
188
174
} ,
189
- Reference = new OpenApiReference ( )
190
- {
191
- Type = ReferenceType . Schema ,
192
- Id = "Item"
193
- }
194
- }
195
- } ,
196
- }
197
- }
198
- } ) ;
199
-
200
- var errorResponse = operation . Value . Responses [ "default" ] ;
201
- errorResponse . ShouldBeEquivalentTo (
202
- new OpenApiResponse ( )
175
+ Reference = new OpenApiReference ( )
203
176
{
204
- Description = "An error response" ,
205
- Content =
206
- {
207
- [ "application/json" ] = new OpenApiMediaType ( )
208
- {
209
- Schema = new OpenApiSchema ( )
210
- {
211
- Properties = new Dictionary < string , OpenApiSchema > ( )
177
+ Type = ReferenceType . Schema ,
178
+ Id = "Item"
179
+ }
180
+ }
181
+ } ;
182
+ var errorSchema = new OpenApiSchema ( )
183
+ {
184
+ Properties = new Dictionary < string , OpenApiSchema > ( )
212
185
{
213
186
{ "code" , new OpenApiSchema ( )
214
187
{
@@ -227,12 +200,48 @@ public void ShouldParseProducesInAnyOrder()
227
200
}
228
201
}
229
202
} ,
230
- Reference = new OpenApiReference ( )
231
- {
232
- Type = ReferenceType . Schema ,
233
- Id = "Error"
234
- }
235
- } ,
203
+ Reference = new OpenApiReference ( )
204
+ {
205
+ Type = ReferenceType . Schema ,
206
+ Id = "Error"
207
+ }
208
+ } ;
209
+ foreach ( var operation in doc . Paths [ "/items" ] . Operations )
210
+ {
211
+ Assert . Equal ( 2 , operation . Value . Responses . Count ) ;
212
+
213
+ var okResponse = operation . Value . Responses [ "200" ] ;
214
+ okResponse . ShouldBeEquivalentTo (
215
+ new OpenApiResponse ( )
216
+ {
217
+ Description = "An OK response" ,
218
+ Content =
219
+ {
220
+ [ "application/json" ] = new OpenApiMediaType ( )
221
+ {
222
+ Schema = successSchema ,
223
+ } ,
224
+ [ "application/xml" ] = new OpenApiMediaType ( )
225
+ {
226
+ Schema = successSchema ,
227
+ }
228
+ }
229
+ } ) ;
230
+
231
+ var errorResponse = operation . Value . Responses [ "default" ] ;
232
+ errorResponse . ShouldBeEquivalentTo (
233
+ new OpenApiResponse ( )
234
+ {
235
+ Description = "An error response" ,
236
+ Content =
237
+ {
238
+ [ "application/json" ] = new OpenApiMediaType ( )
239
+ {
240
+ Schema = errorSchema ,
241
+ } ,
242
+ [ "application/xml" ] = new OpenApiMediaType ( )
243
+ {
244
+ Schema = errorSchema ,
236
245
}
237
246
}
238
247
} ) ;
0 commit comments