Vary presence and requirement of properties with CRUD operation
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
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- openapi
- Lĩnh vực
- api
Hướng nghiên cứu
Bắt đầu bằng việc xem xét bảng vendor-extension của issue cùng với ngữ nghĩa OpenAPI hiện có cho readOnly, writeOnly và required. Công việc được xem là hoàn tất khi có một đặc tả đã được thống nhất về sự hiện diện và các yêu cầu của property phụ thuộc vào CRUD, bao gồm các quy tắc xác thực và tương tác với composition và các schema đa hình.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Properties of a schema could be marked as readOnly or writeOnly if they should not be used respectively in a request or response. Additionally, required properties are present in the required field. Request vs response is the only criteria that can alter a resource schema.
This was not sufficient to describe our legacy REST APIs where presence and requirement of resource's properties is highly dependent of CRUD operation. The was due, in part, to wrong design choices. However, we faced generic situations that cannot be expressed for example:
- Write once / immutable property: for properties like slug or identifier. Those properties should not be part of update request.
- Server side default value: this kind of property is required only in response.
All this can be achieved using composition. I don't think that's a reasonable solution because:
- contract is not more human readable as resources are split in many schema
- for polymorphic resources (using oneOf), there is too many different schema to create and duplication is inevitable
We used following vendor extensions to be able to produce the documentation of our API:
| Field Name | Type | Description |
|---|---|---|
| x-createOnly | boolean |
Relevant only for Schema "properties" definitions. Declares the property as "create only". This means that it MAY be sent as part of a POST request but SHOULD NOT be sent as part of the response or any other request type. If the property is marked as x-createOnly being true and is in the required list, the required will take effect on the POST request only. A property MUST NOT be marked as both x-createOnly and readOnly, writeOnly, x-updateOnly, x-createForbidden or x-updateForbidden being true. Default value is false. |
| x-updateOnly | boolean |
Relevant only for Schema "properties" definitions. Declares the property as "update only". This means that it MAY be sent as part of a PUT request but SHOULD NOT be sent as part of the response or any other request type. If the property is marked as x-updateOnly being true and is in the required list, the required will take effect on the PUT request only. A property MUST NOT be marked as both x-updateOnly and readOnly, writeOnly, x-createOnly, x-createForbidden or x-updateForbidden being true. Default value is false. |
| x-createForbidden | boolean |
Relevant only for Schema "properties" definitions. Declares the property as "create forbidden". This means that it MAY be sent as part of a PUT request or be sent as part of the response but SHOULD NOT be sent as part of any other request type. If the property is marked as x-createForbidden being true and is in the required list, the required will take effect on the PUT request and the response only. A property MUST NOT be marked as both x-createForbidden and readOnly, writeOnly, x-createOnly, x-updateOnly or x-updateForbidden being true. Default value is false. |
| x-updateForbidden | boolean |
Relevant only for Schema "properties" definitions. Declares the property as "create and read only". This means that it MAY be sent as part of a POST request or be sent as part of the response but SHOULD NOT be sent as part of any other request type. If the property is marked as x-updateForbidden being true and is in the required list, the required will take effect on the POST request and the response only. A property MUST NOT be marked as both x-updateForbidden and readOnly, writeOnly, x-createOnly, x-updateOnly or x-createForbidden being true. Default value is false. |
| x-requiredCreate | [string] |
List properties required in the POST request. |
| x-requiredUpdate | [string] |
List properties requires in the PUT request. |
| x-requiredRead | [string] |
List properties required in the response. |
Being able to describe requirement and presence of resource's properties based on usage context could be a great enhancement.
- Ngôn ngữ chính
- Markdown
- Star
- 31.2k
- Fork
- 9.2k
- Merge trung bình
- 6 giờ 37 phút
- Pull request đã merge (30 ngày)
- 27
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.
Issue khác của OAI/OpenAPI-Specification
-
Housekeeping
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 15/100
OAI/OpenAPI-Specification#5554 ·
-
Housekeeping
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 25/100
OAI/OpenAPI-Specification#5542 · 8 bình luận ·
-
Housekeeping
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 25/100
OAI/OpenAPI-Specification#5532 · 4 bình luận ·
-
v3.2.1 release Đang mở
OAI/OpenAPI-Specification#5460 · 11 bình luận · 1 reaction · 1 người được giao ·
-
param serialization
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
OAI/OpenAPI-Specification#5366 · 12 bình luận ·
Tất cả issue của OAI/OpenAPI-Specification
Issue tương tự
-
area/sessions comp/agent P2 tool/skills type/perf
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
NousResearch/hermes-agent#117788 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
code-quality refactoring
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
github/gh-aw-firewall#8816 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
getgrav/grav-plugin-api#45 ·