microsoft / microsoft/OpenAPI.NET
OpenApiYamlReader.Read inconsistent behavior for errors
- Langage dominant
- C#
- Étoiles
- 1.6k
- Forks
- 286
- Merge moyen
- 6 h 38 min
- PR mergées (30 j)
- 35
Description
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.
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Évaluation
Cette issue n'a pas encore été évaluée.