OpenApiYamlReader.Read inconsistent behavior for errors
維護者通常 1 天內回覆
評估
這個 Issue 還沒有評估資料。
描述
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.
- 主要語言
- C#
- 星號
- 1.6k
- 分支
- 286
- 平均合併
- 9 小時 16 分鐘
- 30 天內合併 PR
- 28
環境準備
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
microsoft/OpenAPI.NET 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 72/100
microsoft/OpenAPI.NET#2798 ·
維護者通常 1 天內回覆
-
type:breaking-change
難度 4/5 3-5 天 新手友好度 52/100
microsoft/OpenAPI.NET#3014 · 2 則留言 ·
維護者通常 1 天內回覆
-
help wanted
難度 5/5 一週以上 新手友好度 35/100
microsoft/OpenAPI.NET#2989 · 3 則留言 ·
維護者通常 1 天內回覆
-
help wanted type:feature
難度 3/5 1-2 天 新手友好度 55/100
microsoft/OpenAPI.NET#2967 · 18 則留言 · 1 個 reaction ·
維護者通常 1 天內回覆
-
help wanted
難度 5/5 一週以上 新手友好度 35/100
microsoft/OpenAPI.NET#2963 · 5 則留言 ·
維護者通常 1 天內回覆
查看 microsoft/OpenAPI.NET 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 82/100
NethermindEth/nethermind#14012 ·
維護者通常 1 天內回覆
-
dependencies Status: Triage
難度 2/5 1-3 小時 新手友好度 68/100
json-schema-org/website#2518 ·
維護者通常 1 天內回覆
-
agentic-workflows
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
builtbybel/Flyoobe#498 ·
-
難度 2/5 1-3 小時 新手友好度 62/100
builtbybel/CrapFixer#112 ·