Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Wrong Serializer Groups import in Symfony User documentation

Đang mở Phù hợp với người mới
#8,573 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của api-platform/core

Tất cả issue của api-platform/core

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.