Skip to content

Commit 6ac0bd1

Browse files
committed
Add test
1 parent aa3781b commit 6ac0bd1

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiSchemaTests.cs

Lines changed: 20 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.Collections.Generic;
@@ -371,6 +371,25 @@ public void SerializeV2SchemaWithNullableExtensionAsV31Works()
371371
schemaString.MakeLineBreaksEnvironmentNeutral().Should().Be(expected.MakeLineBreaksEnvironmentNeutral());
372372
}
373373

374+
[Fact]
375+
public void SerializeSchemaWithTypeArrayAndNullableDoesntEmitType()
376+
{
377+
var input = @"type:
378+
- ""string""
379+
- ""int""
380+
nullable: true";
381+
382+
var expected = @"{ }";
383+
384+
var schema = OpenApiModelFactory.Parse<OpenApiSchema>(input, OpenApiSpecVersion.OpenApi3_1, out _, "yaml");
385+
386+
var writer = new StringWriter();
387+
schema.SerializeAsV2(new OpenApiYamlWriter(writer));
388+
var schemaString = writer.ToString();
389+
390+
schemaString.MakeLineBreaksEnvironmentNeutral().Should().Be(expected.MakeLineBreaksEnvironmentNeutral());
391+
}
392+
374393
[Theory]
375394
[InlineData("schemaWithNullable.yaml")]
376395
[InlineData("schemaWithNullableExtension.yaml")]

0 commit comments

Comments
 (0)