OpenAPI missing request schema when providing MediaType examples
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ó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 45/100
Hướng nghiên cứu
Start by reproducing with the EntityResource class and the POST operation's custom openapi RequestBody from the issue, then inspect the generated OpenAPI output for that request body. The bug is that providing MediaType examples drops the schema, so the first question is where the custom MediaType replaces the generated one. Done when the request body keeps the resource schema alongside the examples, and the maintainers have settled whether the merge approach proposed in the issue is acceptable.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
API Platform version(s) affected: 5.0.2
Description
Documenting requestBody examples removes the request format schemas
How to reproduce
Using the following ApiResource class:
#[Post(
status: 201,
openapi: new Operation(
requestBody: new RequestBody(
content: new ArrayObject(
[
'application/ld+json' => new MediaType(
examples: new ArrayObject(
[
'hello world' => new Example(description: 'Submitting a "hello world" entity', value: new EntityResource(1, 'Hello world')),
'foo bar' => new Example(description: 'Submitting a "foo bar" entity', value: new EntityResource(2, 'Foo bar')),
],
),
),
],
),
),
),
)]
readonly class EntityResource
{
public function __construct(#[ApiProperty(identifier: true)] public int $id, public string $name)
{
}
}
The schema is missing from the generated spec:
SwaggerUI output
And I have to add it myself, but this risks documentation drift caused by future API updates.
new ArrayObject(
[
'type' => 'object',
'properties' => new ArrayObject(
[
'id' => new ArrayObject(['type' => 'integer']),
'name' => new ArrayObject(['type' => 'string']),
],
),
],
),
SwaggerUI output
Additional
Would it be possible/okay to merge the API-Platform generated MediaType with the APIResource's MediaType? And only fill in the null values?
- Ngôn ngữ chính
- PHP
- Star
- 2.6k
- Fork
- 989
- Merge trung bình
- 1 ngày 22 giờ
- Pull request đã merge (30 ngày)
- 100
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc 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 api-platform/core
-
JSON:API: resource schemas (`*.jsonapi`) have `properties` but no `type: object`Có thể đã có người làm @ousamabenyounes đã nhận 3 ngày trước. Đang mở
Độ khó 2/5 Dưới một giờ Mức phù hợp với người mới 80/100
api-platform/core#8701 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
JSON:API: `JsonApiCollectionBaseSchemaNoPagination` declares `data` as `type: array` without `items`Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
api-platform/core#8699 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Json-Schema] Nested resources lost externalDoc and description dataCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
api-platform/core#8721 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
JSON:API: 404/405 router errors are empty, and error objects have a non-spec `type` memberCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 50/100
api-platform/core#8704 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
JSON:API: request documents with no `data`, no `type` or a wrong `type` are accepted with 201Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 62/100
api-platform/core#8703 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của api-platform/core
Issue tương tự
-
sync-en
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 77/100
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
verbb/formie#3022 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Automattic/blocks-engine#3090 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
(php): ORT workflow always fails due to incompatibility between Pluggy 1.7.0 and Scancode-Toolkit 32.5.0Có thể đã có người làm @leslie-bq đã nhận 3 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
valkey-io/valkey-glide-php#375 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100