Skip to content

Commit be414df

Browse files
committed
Add tests
1 parent 99b8140 commit be414df

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

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

Lines changed: 18 additions & 2 deletions
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;
@@ -356,7 +356,8 @@ public void SerializeV2SchemaWithNullableExtensionAsV31Works()
356356
// Arrange
357357
var expected = @"type:
358358
- string
359-
- null";
359+
- null
360+
x-nullable: true";
360361

361362
var path = Path.Combine(SampleFolderPath, "schemaWithNullableExtension.yaml");
362363

@@ -369,5 +370,20 @@ public void SerializeV2SchemaWithNullableExtensionAsV31Works()
369370

370371
schemaString.MakeLineBreaksEnvironmentNeutral().Should().Be(expected.MakeLineBreaksEnvironmentNeutral());
371372
}
373+
374+
[Theory]
375+
[InlineData("schemaWithNullable.yaml")]
376+
[InlineData("schemaWithNullableExtension.yaml")]
377+
public void LoadSchemaWithNullableExtensionAsV31Works(string filePath)
378+
{
379+
// Arrange
380+
var path = Path.Combine(SampleFolderPath, filePath);
381+
382+
// Act
383+
var schema = OpenApiModelFactory.Load<OpenApiSchema>(path, OpenApiSpecVersion.OpenApi3_1, out _);
384+
385+
// Assert
386+
schema.Type.Should().BeEquivalentTo(new string[] { "string", "null" });
387+
}
372388
}
373389
}

0 commit comments

Comments
 (0)