fix: warn instead of error out when $schema is present in the document · Frulfump/OpenAPI.NET@7c7b053 · GitHub
Skip to content

Commit 7c7b053

Browse files
committed
fix: warn instead of error out when $schema is present in the document
1 parent 34c9de1 commit 7c7b053

3 files changed

Lines changed: 47 additions & 2 deletions

File tree

‎src/Microsoft.OpenApi/Reader/ParseNodes/PropertyNode.cs‎

Lines changed: 9 additions & 2 deletions

‎test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentTests.cs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,17 @@ public async Task ParseDocumentWithEmptyTagsWorks()
579579

580580
doc.Paths["/groups"].Operations[HttpMethod.Get].Tags.Should().BeNull("Empty tags are ignored, so we should not have any tags");
581581
}
582+
[Fact]
583+
public async Task DocumentWithSchemaResultsInWarning()
584+
{
585+
var path = Path.Combine(SampleFolderPath, "documentWithSchema.json");
586+
var (doc, diag) = await OpenApiDocument.LoadAsync(path, SettingsFixture.ReaderSettings);
587+
Assert.NotNull(doc);
588+
Assert.NotNull(diag);
589+
Assert.Empty(diag.Errors);
590+
Assert.Single(diag.Warnings);
591+
Assert.StartsWith("$schema is not a valid property", diag.Warnings[0].Message);
592+
}
582593

583594
[Fact]
584595
public void ParseEmptyMemoryStreamThrowsAnArgumentException()
Lines changed: 27 additions & 0 deletions

0 commit comments

Comments
 (0)