microsoft / microsoft/OpenAPI.NET
Add support for $schema and jsonSchemaDialect
還沒有人認領這個 Issue。
- 主要語言
- C#
- 星號
- 1.6k
- 分支
- 286
- 平均合併
- 6 小時 38 分鐘
- 30 天內合併 PR
- 35
描述
In today's implementation (2.11.0, 3.9.0), the deserialization and serialization of JSON Schemas is effectively hard-coded to 2020-12.
However, starting with OpenAPI 3.1, people can set the $schema property of any given schema to a different dialect (default being documented here.
This entails a couple of things:
- parsing that keyword first if it exists, or falling back on the document dialect property, or falling back to the default value for the OpenAPI version.
- if that value is known (like
https://spec.openapis.org/oas/3.1/dialect/baseusing the parsing logic associated with that entry - if that value is unknown, we need to load the corresponding schema, and read its schema (recursively) until we find a known value. (note be careful of the security considerations here)
Note: ideally we'd make the OpenAPISchema type generic and allow the caller to provide new registrations of schemas uris with the corresponding parsing logic and data type, but that'd introduce major breaking changes, making the cost prohibitive.
That update will most likely require introducing a JSON Schema service of some kind in charge of mapping the known schemas with their deserialization logic, and having the OpenAPISchema deserializers call into that service.
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
首先追蹤 OpenAPISchema 的反序列化器和序列化器,並找出套用 2020-12 假設的位置。圍繞方言註冊、回退解析、未知 schema 的遞迴處理以及安全性限制來定義 JSON Schema 服務;當 $schema 和 jsonSchemaDialect 能夠選取正確的已知或已載入方言,且不破壞現有行為時,即表示完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- csharp, openapi
- 領域
- api, backend-api-design
- Issue 類型
- 功能
- 難度
- 5/5
- 預估耗時
- 一週以上
- 活躍度
- 活躍
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100