Problem with schema descriptions
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ó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 42/100
Hướng nghiên cứu
Bắt đầu bằng cách theo dõi quá trình tạo schema OpenAPI cho các thuộc tính enum tùy chỉnh và so sánh với cách xử lý mô tả PHPDoc hiện có cho các thuộc tính vô hướng. Được xem là hoàn tất khi đặc tả OpenAPI được tạo bao gồm mô tả PHPDoc của thuộc tính mà không yêu cầu mô tả rõ ràng trong schema ApiProperty.
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.1.8
Description
When using a custom enum as a property type, the OpenAPI description must be explicitly defined using the #[ApiProperty(schema: ['description' => '...'])] attribute.
In contrast, for scalar or other non-enum types, the description can be extracted automatically from the PHPDoc comment block.
This inconsistency can lead to confusion and additional boilerplate when using enums.
How to reproduce
class ChecklistQuestionTypeType extends Type implements TypeNameInterface {
case ACTIVE = 'active';
case INACTIVE = 'inactive';
public const array MAPPED_VALUES = [
1 => self::ACTIVE,
2 => self::INACTIVE,
];
public const array VALUES = [...self::MAPPED_VALUES];
public function getValues(): array
{
return self::VALUES;
}
public function getMappedValues(): array
{
return self::MAPPED_VALUES;
}
}
final class ExampleResource
{
/**
* The current status of the resource.
*/
#[ApiProperty(schema: ['type' => 'string', 'enum' => Status::VALUES])]
public string $status;
}
Expected: The OpenAPI spec should include the description from the PHPDoc (The current status of the resource.).
Actual: The description is missing unless explicitly added in the ApiProperty attribute like so:
#[ApiProperty(schema: ['description' => 'The current status of the resource.', ...])]
Additional Context
- The inconsistency suggests that PHPDoc parsing is skipped or not supported for enum types.
- It would improve DX if enum properties behaved consistently with scalar types regarding description inference.
- 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ự
-
Độ 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
-
macOS
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
beyondcode/herd-community#1771 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 63/100
-
module: user interface priority: high severity: minor type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Enhancement] Add a dark-bg Tailwind variantCó thể đã có người làm @bd-viget đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
vigetlabs/wordpress-site-starter#306 ·
Maintainer thường phản hồi trong vòng 1 ngày