Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Wrong Serializer Groups import in Symfony User documentation

Aperta Adatta ai principianti
#8,573 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
1/5
Tempo stimato
Meno di un'ora
Idoneità per principianti
85/100
Tipo di issue
Documentazione
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
php, symfony
Ambito
documentation

Direzione di ricerca

Individuare il file di documentazione utente nel repository (probabilmente in docs/core/user-guide/ o simile). Individuare l'istruzione di importazione per Groups. Modificare 'Annotation\Groups' in 'Attribute\Groups'. Verificare la modifica controllando se la documentazione viene generata correttamente e assicurarsi che non sia necessario aggiornare altre importazioni correlate.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
PHP
Stelle
2.6k
Fork
982
Merge medio
1g 16h
PR unite (30g)
59

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di api-platform/core

Tutte le issue di api-platform/core

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.