microsoft / microsoft/OpenAPI.NET
Add support for $schema and jsonSchemaDialect
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- C#
- Star
- 1.6k
- Fork
- 286
- Merge trung bình
- 6 giờ 38 phút
- Pull request đã merge (30 ngày)
- 35
Mô tả
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.
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng cách lần theo các deserializer và serializer của OpenAPISchema, đồng thời xác định nơi áp dụng giả định 2020-12. Xác định dịch vụ JSON Schema xoay quanh việc đăng ký dialect, phân giải fallback, xử lý đệ quy các schema chưa biết và các ràng buộc bảo mật; được xem là hoàn tất khi $schema và jsonSchemaDialect chọn đúng dialect đã biết hoặc đã tải mà không làm hỏng hành vi hiện có.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- csharp, openapi
- Lĩnh vực
- api, backend-api-design
- Loại issue
- Tính năng
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Sôi nổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100