File tree Expand file tree Collapse file tree 1 file changed +53
-1
lines changed
test/Microsoft.OpenApi.Tests/Models Expand file tree Collapse file tree 1 file changed +53
-1
lines changed Original file line number Diff line number Diff line change 1
- // Copyright (c) Microsoft Corporation. All rights reserved.
1
+ // Copyright (c) Microsoft Corporation. All rights reserved.
2
2
// Licensed under the MIT license.
3
3
4
4
using System ;
@@ -1356,5 +1356,57 @@ public void CopyConstructorForAdvancedDocumentWorks()
1356
1356
Assert . Equal ( 2 , doc . Paths . Count ) ;
1357
1357
Assert . NotNull ( doc . Components ) ;
1358
1358
}
1359
+
1360
+ [ Fact ]
1361
+ public void SerializeV2DocumentWithNonArraySchemaTypeDoesNotWriteOutCollectionFormat ( )
1362
+ {
1363
+ // Arrange
1364
+ var expected = @"swagger: '2.0'
1365
+ info: { }
1366
+ paths:
1367
+ /foo:
1368
+ get:
1369
+ parameters:
1370
+ - in: query
1371
+ type: string
1372
+ responses: { }" ;
1373
+
1374
+ var doc = new OpenApiDocument
1375
+ {
1376
+ Info = new OpenApiInfo ( ) ,
1377
+ Paths = new OpenApiPaths
1378
+ {
1379
+ [ "/foo" ] = new OpenApiPathItem
1380
+ {
1381
+ Operations = new Dictionary < OperationType , OpenApiOperation >
1382
+ {
1383
+ [ OperationType . Get ] = new OpenApiOperation
1384
+ {
1385
+ Parameters = new List < OpenApiParameter >
1386
+ {
1387
+ new OpenApiParameter
1388
+ {
1389
+ In = ParameterLocation . Query ,
1390
+ Schema = new OpenApiSchema
1391
+ {
1392
+ Type = "string"
1393
+ }
1394
+ }
1395
+ } ,
1396
+ Responses = new OpenApiResponses ( )
1397
+ }
1398
+ }
1399
+ }
1400
+ }
1401
+ } ;
1402
+
1403
+ // Act
1404
+ var actual = doc . SerializeAsYaml ( OpenApiSpecVersion . OpenApi2_0 ) ;
1405
+
1406
+ // Assert
1407
+ actual = actual . MakeLineBreaksEnvironmentNeutral ( ) ;
1408
+ expected = expected . MakeLineBreaksEnvironmentNeutral ( ) ;
1409
+ actual . Should ( ) . Be ( expected ) ;
1410
+ }
1359
1411
}
1360
1412
}
You can’t perform that action at this time.
0 commit comments