microsoft / microsoft/OpenAPI.NET

Add support for $schema and jsonSchemaDialect

オープン
#2,963 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

help wanted
主要言語
C#
スター
1.6k
フォーク
286
平均マージ
6時間 38分
マージ済み PR(30日)
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:

  1. 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.
  2. if that value is known (like https://spec.openapis.org/oas/3.1/dialect/base using the parsing logic associated with that entry
  3. 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.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず OpenAPISchema のデシリアライザーとシリアライザーを追跡し、2020-12 の前提が適用されている箇所を特定します。方言の登録、フォールバック解決、未知のスキーマの再帰的な処理、セキュリティ制約を中心に JSON Schema サービスを定義します。$schema と jsonSchemaDialect が既知または読み込まれた正しい方言を選択し、既存の動作を壊さなければ完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
csharp, openapi
領域
api, backend-api-design
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
活発
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。