Wrong Serializer Groups import in Symfony User documentation
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 85/100
- Issue type
- Documentation
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- documentation
Research direction
Find the User documentation file in the repository (likely in docs/core/user-guide/ or similar). Locate the import statement for Groups. Change 'Annotation\Groups' to 'Attribute\Groups'. Verify the change by checking if the documentation builds correctly, and ensure no other related imports need updating.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- PHP
- Stars
- 2.6k
- Forks
- 982
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 67
Getting set up
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from api-platform/core
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
api-platform/core#8588 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
api-platform/core#8564 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
api-platform/core#8495 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
api-platform/core#8471 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
api-platform/core#8475 ·
Maintainers usually reply within 1 day
All issues in api-platform/core
Similar issues
-
[Feature]: Remove Kanboard Discourse forum link from README.md and CONTRIBUTING.md, or moderate itOpen
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
solana-foundation/pay-kit#341 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
a2aproject/A2A#2262 ·
Maintainers usually reply within 2 days
-
Bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 2 days