microsoft / microsoft/OpenAPI.NET

Add support for $schema and jsonSchemaDialect

未关闭
#2,963 5 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

help wanted
主要语言
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:

  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. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先跟踪 OpenAPISchema 的反序列化器和序列化器,并确定应用 2020-12 假设的位置。围绕方言注册、回退解析、未知 schema 的递归处理以及安全约束来定义 JSON Schema 服务;当 $schema 和 jsonSchemaDialect 能够选择正确的已知或已加载方言,且不破坏现有行为时,即视为完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
csharp, openapi
领域
api, backend-api-design
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
活跃
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。