Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Add support for templatedRef in Reference Object

Đang mở
#2,453 6 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
25/100
Loại issue
Tính năng
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Lĩnh vực
api, backend-api-design

Hướng nghiên cứu

Bắt đầu bằng cách xem xét định nghĩa Reference Object, tài liệu JSON Reference, RFC 6570 và phần thảo luận được liên kết về các vocabulary của JSON Schema. Công việc hoàn tất khi ngữ nghĩa và phạm vi của $templatedRef được thống nhất và đặc tả đủ rõ ràng để hỗ trợ các ví dụ về collection và style.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Proposing to add support for "$templatedRef" to Reference Objects supporting templated references, allowing referencing dynamic schemas that could be retrieved by substituting the template variables by the selected value for earlier path parameters
so that later path parameters can be defined differently based on earlier path parameters.

Example:

  "parameters" :
   {
      "collection-styleId" :
      {
         "name" : "styleId",
         "schema" :
         {
            "$templatedRef" : "./api/collections-styles/{collectionId}"`
         }         
      }
   }

As it was initially suggested that this would require to first extend JSON schema, an initial discussion took place in https://github.com/json-schema-org/json-schema-vocabularies/issues/36 . However reading on https://swagger.io/specification/ that the Reference Object is defined by the JSON Reference, rather than by JSON Schema, it seems that this could rather simply be extended with$templatedRef, following https://tools.ietf.org/html/rfc6570 (or a simpler subset of it).

The {collectionId} template would be replaced by a selected value like collection1.
(e.g. in this example, this "$templatedRef" is used to define the valid values for {styleId} in a path /collections/{collectionId}/styles/{styleId}).

The {collectionId} would have previously been validated against another potentially dynamic list like "$ref" : "./api/collections".

./api/collections would return something like:

{
   "type" : "string",
   "enum" : [
      "collection1",
      "collection2",
      "collection3"
   ]
}

and ./api/collection-styles/collection1 would return something like

{
   "type" : "string",
   "enum" : [
      "style234",
      "style235",
      "style236"
   ]
}

while ./api/collection-styles/collection2 would return something like

{
   "type" : "string",
   "enum" : [
      "style454",
      "style455",
      "style456"
   ]
}

The context being that available/compatibles styles depend on the selected collection.

Such a capability would allow to define much more interoperable APIs, where the specifics of a particular instance / deployment would be left to the templated references. In turn this would allow to automatically generate clients from an API definition that will work with multiple instances of the same templatable API, therefore extending the usability of clients automatically generated from OpenAPI definitions beyond on-the-fly client generation, more suitable for compiled programming languages.

Ngôn ngữ chính
Markdown
Star
31.2k
Fork
9.2k
Merge trung bình
2 ngày 9 giờ
Pull request đã merge (30 ngày)
17

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của OAI/OpenAPI-Specification

Tất cả issue của OAI/OpenAPI-Specification

Issue tương tự

Thêm issue về Backend & API Design

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.