microsoft / microsoft/OpenAPI.NET

OpenApiYamlReader.Read inconsistent behavior for errors

Abierto
#3,056 1 comentario 1 reacción 2 asignados Ver en GitHub

@baywet ya está trabajando en esto.

Desde el 10/9/2026.

  • #3078 de @copilot-swe-agent — abierto
Lenguaje dominante
C#
Estrellas
1.6k
Forks
286
Merge medio
6 h 38 min
PR fusionados (30 d)
35

Descripción

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.

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.