ExactFilter on enum typed property is not generating enums in docs.jsonopenapi
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 55/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Lĩnh vực
- api, documentation
Hướng nghiên cứu
Start by reading the QueryParameter and ExactFilter documentation generation paths, then compare the reported OpenAPI schemas for the legacy BackedEnumFilter and the new ExactFilter parameter. Identify where enum types are inferred for parameter schemas and check the relevant tests; done means enum values from an enum typed property appear in the generated schema for the new parameter.
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: 4.4.3
Description
I'm rewriting the legacy ApiFilter BackedEnumFilter to a #[QueryParameter] attribute using the ExactFilter that is kept in 6.0 (see this documentation: https://api-platform.com/docs/core/upgrade-guide/#legacy-doctrine-filters). The filter works but the enums are not generated anymore (which means the dropdown with available values is lost on the SwaggerUI). Now a normal text input is given which is not desired for our UI.
How to reproduce
So the old situation was:
#[ApiFilter(BackedEnumFilter::class, properties: ['type'])]
This generated the enums belonging to this type property in the docs.jsonopenapi of our api
In the new situation a QueryParameter is used with ExactFilter:
#[ApiResource(
operations: [
new GetCollection(
'/activiteiten/bijeenkomsten{._format}',
parameters: [
'type' => new QueryParameter(
filter: new ExactFilter(),
property: 'type',
),
]
),
],
)]
And type in this Entity is the following:
#[ORM\Column(name: 'act_type', type: Types::ENUM)]
private TypeEnum $type;
Filtering like this works when the user correctly inputs an enum value but the enums are not generated anymore in the docs.jsonopenapi
Possible Solution
Adding
schema: [
'type' => 'string',
'enum' => array_column(TypeEnum::cases(), 'value'),
],
to the requestParameter to retrieve the values of the enums here for the dropdown is not possible since only constant values can be given here.
Another idea is creating a custom filter and using the getOpenApiParameters() function to document the filter, but this seem #s impossible because ExactFilter is a final class.
Additional Context
This was the json in our docs.jsonopenapi:
{ "name": "type", "in": "query", "description": "", "required": false, "deprecated": false, "schema": { "type": "string", "enum": [ "cursus", "opleiding", "clinic", "themabijeenkomst", "clusterbijeenkomst", "symposium", "congres", "regioraad", "bondsraad", "officialbijeenkomst", "kaderbijeenkomst", "webinar", "workshop", "e-learning", "bijscholing" ] }, "style": "form", "explode": false }, { "name": "type[]", "in": "query", "description": "", "required": false, "deprecated": false, "schema": { "type": "array", "items": { "type": "string", "enum": [ "cursus", "opleiding", "clinic", "themabijeenkomst", "clusterbijeenkomst", "symposium", "congres", "regioraad", "bondsraad", "officialbijeenkomst", "kaderbijeenkomst", "webinar", "workshop", "e-learning", "bijscholing" ] } }, "style": "form", "explode": true },
And this is the json now with the Exactfilter in the QueryParameter:
{ "name": "type", "in": "query", "description": "Bijeenkomst type", "required": false, "deprecated": false, "schema": { "type": "string" }, "style": "form", "explode": true }, { "name": "type[]", "in": "query", "description": "Bijeenkomst type", "required": false, "deprecated": false, "schema": { "type": "array", "items": { "type": "string" } }, "style": "deepObject", "explode": true },
Which misses the enum in the schema attribute
THIS ISSUE WAS ALSO POSTED IN THE api-platform/api-platform REPOSITORY
https://github.com/api-platform/api-platform/issues/3017
- Ngôn ngữ chính
- PHP
- Star
- 2.6k
- Fork
- 988
- Merge trung bình
- 4 ngày 10 giờ
- Pull request đã merge (30 ngày)
- 114
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
-
API Platform ignores array shapes in the JSON SchemaCó thể đã có người làm @afraca đã nhận 11 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
api-platform/core#8766 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
api-platform/core#8744 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
JSON:API: resource schemas (`*.jsonapi`) have `properties` but no `type: object`Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đ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 2 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
api-platform/core#8819 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 66/100
api-platform/core#8815 ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của api-platform/core
Issue tương tự
-
Visual COBOL: missing 11.0 and 12.0, and 9.0 date differs from Rocket Software's lifecycle pageĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
endoflife-date/endoflife.date#11561 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
good first issue priority:low type:bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
crazy-goat/fdb-php#184 ·
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 75/100
nextcloud/groupfolders#5218 ·
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
nextcloud/sharelisting#624 ·
-
`wp theme mod set` prints its failure message as `Success` and exits 0Có thể đã có người làm @dhrupo đã nhận hôm nay. Đang mởbug command:theme-mod-set status:unconfirmed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
wp-cli/extension-command#570 ·