Skip to content

Commit 0b710d5

Browse files
Merge pull request #1006 from microsoft/ma/readasync-filter-errors
Separate warnings and errors in Open API YAML reader ReadAsync method
2 parents 6ff3176 + 6cdceb0 commit 0b710d5

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<Company>Microsoft</Company>
1111
<Title>Microsoft.OpenApi.Readers</Title>
1212
<PackageId>Microsoft.OpenApi.Readers</PackageId>
13-
<Version>1.4.0</Version>
13+
<Version>1.4.1</Version>
1414
<Description>OpenAPI.NET Readers for JSON and YAML documents</Description>
1515
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
1616
<PackageTags>OpenAPI .NET</PackageTags>

src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ public OpenApiDocument Read(YamlDocument input, out OpenApiDiagnostic diagnostic
7171
if (_settings.RuleSet != null && _settings.RuleSet.Rules.Count > 0)
7272
{
7373
var openApiErrors = document.Validate(_settings.RuleSet);
74-
foreach (var item in openApiErrors.Where(e => e is OpenApiValidatorError))
74+
foreach (var item in openApiErrors.OfType<OpenApiValidatorError>())
7575
{
7676
diagnostic.Errors.Add(item);
7777
}
78-
foreach (var item in openApiErrors.Where(e => e is OpenApiValidatorWarning))
78+
foreach (var item in openApiErrors.OfType<OpenApiValidatorWarning>())
7979
{
8080
diagnostic.Warnings.Add(item);
8181
}
@@ -114,11 +114,15 @@ public async Task<ReadResult> ReadAsync(YamlDocument input)
114114
// Validate the document
115115
if (_settings.RuleSet != null && _settings.RuleSet.Rules.Count > 0)
116116
{
117-
var errors = document.Validate(_settings.RuleSet);
118-
foreach (var item in errors)
117+
var openApiErrors = document.Validate(_settings.RuleSet);
118+
foreach (var item in openApiErrors.OfType<OpenApiValidatorError>())
119119
{
120120
diagnostic.Errors.Add(item);
121121
}
122+
foreach (var item in openApiErrors.OfType<OpenApiValidatorWarning>())
123+
{
124+
diagnostic.Warnings.Add(item);
125+
}
122126
}
123127

124128
return new ReadResult()

0 commit comments

Comments
 (0)