Skip to content

Commit 42a4015

Browse files
committed
Add test
1 parent 7c9fac2 commit 42a4015

File tree

1 file changed

+53
-1
lines changed

1 file changed

+53
-1
lines changed

test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Microsoft Corporation. All rights reserved.
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
33

44
using System;
@@ -1356,5 +1356,57 @@ public void CopyConstructorForAdvancedDocumentWorks()
13561356
Assert.Equal(2, doc.Paths.Count);
13571357
Assert.NotNull(doc.Components);
13581358
}
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+
}
13591411
}
13601412
}

0 commit comments

Comments
 (0)