Describe the bug
OpenApiYamlReader.Read throws and exception in some error cases and returns a ReadResult in others. I expect it to always return a ReadResult. A ReadResult is already something that can describe a failure.
For instance, given an empty document:
using var stream = new MemoryStream();
new OpenApiYamlReader().Read(stream, new Uri("https://example.com/"), new OpenApiReaderSettings());
It throws:
System.InvalidOperationException : No documents found in the YAML stream.
at Microsoft.OpenApi.YamlReader.OpenApiYamlReader.LoadJsonNodesFromYamlDocument(TextReader input)
at Microsoft.OpenApi.YamlReader.OpenApiYamlReader.Read(MemoryStream input, Uri location, OpenApiReaderSettings settings)
I expected it it return a ReadResult describing the error.
OpenApi File To Reproduce
An empty file.
Expected behavior
It returns a ReadResult with Document = null and a Diagnostic describing the problem.
Alternatively, when the choice between throwing an exception or returning a ReadResult is by design, this should be documented.
Describe the bug
OpenApiYamlReader.Readthrows and exception in some error cases and returns aReadResultin others. I expect it to always return aReadResult. AReadResultis already something that can describe a failure.For instance, given an empty document:
It throws:
I expected it it return a ReadResult describing the error.
OpenApi File To Reproduce
An empty file.
Expected behavior
It returns a
ReadResultwithDocument = nulland aDiagnosticdescribing the problem.Alternatively, when the choice between throwing an exception or returning a ReadResult is by design, this should be documented.