Skip to content

Commit 866c02a

Browse files
committed
Added validation to ReadFragment
1 parent 2a08ff5 commit 866c02a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,16 @@ public T ReadFragment<T>(Stream input, OpenApiSpecVersion version, out OpenApiDi
144144
diagnostic.Errors.Add(new OpenApiError(ex));
145145
}
146146

147+
// Validate the element
148+
if (_settings.RuleSet != null && _settings.RuleSet.Rules.Count > 0)
149+
{
150+
var errors = element.Validate(_settings.RuleSet);
151+
foreach (var item in errors)
152+
{
153+
diagnostic.Errors.Add(item);
154+
}
155+
}
156+
147157
return (T)element;
148158
}
149159

0 commit comments

Comments
 (0)