You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Wrong Serializer Groups import in Symfony User documentation #8573
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.
You are right, and it is wider than the User doc: the Annotation alias namespace was deprecated in Symfony 7.4 and removed in 8.0, so on your Symfony 8.1 the import resolves to nothing and the attribute never applies, which is exactly the groups => [] you saw.
Fixed across the documentation in api-platform/docs#2348 — 21 imports in 6 files, covering Groups and Context, the two classes from that namespace the docs reference.
Thanks for the precise report, the debug:serializer output made it quick to confirm.
Activity
soyuka commentedon Sep 28, 2026
You are right, and it is wider than the User doc: the
Annotationalias namespace was deprecated in Symfony 7.4 and removed in 8.0, so on your Symfony 8.1 the import resolves to nothing and the attribute never applies, which is exactly thegroups => []you saw.Fixed across the documentation in api-platform/docs#2348 — 21 imports in 6 files, covering
GroupsandContext, the two classes from that namespace the docs reference.Thanks for the precise report, the
debug:serializeroutput made it quick to confirm.