microsoft / microsoft/OpenAPI.NET

OpenApiYamlReader.Read inconsistent behavior for errors

Aperta
#3,056 1 commento 1 reazione 2 assegnatari Vedi su GitHub

@baywet ci sta già lavorando.

Dal 10/9/2026.

  • #3078 di @copilot-swe-agent — aperta
Lingua principale
C#
Stelle
1.6k
Fork
286
Merge medio
6h 38m
PR unite (30g)
35

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.