Wrong Serializer Groups import in Symfony User documentation
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 1/5
- Thời gian dự kiến
- Dưới một giờ
- Mức phù hợp với người mới
- 85/100
- Loại issue
- Tài liệu
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- php, symfony
- Lĩnh vực
- documentation
Hướng nghiên cứu
Tìm tệp tài liệu người dùng trong kho lưu trữ (có thể trong docs/core/user-guide/ hoặc tương tự). Xác định câu lệnh import cho Groups. Thay đổi 'Annotation\Groups' thành 'Attribute\Groups'. Xác minh thay đổi bằng cách kiểm tra xem tài liệu có được xây dựng chính xác không và đảm bảo không có import liên quan nào khác cần cập nhật.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
The Symfony User documentation uses the following import for serialization groups:
use Symfony\Component\Serializer\Annotation\Groups;
With API Platform 5.0 and Symfony 8.1, this does not work as shown in the documentation.
The correct import is:
use Symfony\Component\Serializer\Attribute\Groups;
I noticed this because debug:serializer App\Entity\User showed empty serialization groups for all properties when using Annotation\Groups.
After changing the import to Attribute\Groups and clearing the Symfony cache, the serialization groups were correctly detected and the documented user creation endpoint worked as expected.
Environment
API Platform: 5.0
Symfony: 8.1
PHP: 8.4
Expected behavior
The serialization groups shown in the documentation should be recognized when following the example with a current Symfony version.
Actual behavior
Using Symfony\Component\Serializer\Annotation\Groups results in the groups not being recognized by the serializer.
debug:serializer App\Entity\User reports:
email groups => []
plainPassword groups => []
This subsequently causes the documented POST /api/users operation to fail validation because email and plainPassword are not denormalized.
Suggested fix
Update the example to use:
use Symfony\Component\Serializer\Attribute\Groups;
The current serialization documentation already indicates that Symfony 7+ uses attributes, so the User documentation appears to be inconsistent with this.
- Ngôn ngữ chính
- PHP
- Star
- 2.6k
- Fork
- 982
- Merge trung bình
- 1 ngày 16 giờ
- Pull request đã merge (30 ngày)
- 59
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
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
api-platform/core#8571 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
api-platform/core#8564 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
api-platform/core#8495 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
api-platform/core#8471 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
api-platform/core#8475 ·
Tất cả issue của api-platform/core
Issue tương tự
-
tooling
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
UX
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
ProfessionalWiki/NeoWiki#1525 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
OpenConext/OpenConext-engineblock#2122 ·
-
Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Automattic/safe-publish#594 ·