From dc9721b6f2830f9fdda7e642386d0bdeb6f31d41 Mon Sep 17 00:00:00 2001 From: soyuka Date: Mon, 28 Sep 2026 23:06:07 +0200 Subject: [PATCH] docs: fix Serializer\Annotation import removed in Symfony 8.0 Symfony 8.0 removed the Annotation namespace class aliases (deprecated since 7.4); Groups and Context now live under Serializer\Attribute. The old import silently drops all groups (debug:serializer shows groups => []), breaking every documented denormalization example. Refs api-platform/core#8573 --- core/graphql.md | 8 ++++---- core/serialization.md | 24 ++++++++++++------------ symfony/controllers.md | 2 +- symfony/file-upload.md | 4 ++-- symfony/fosuser-bundle.md | 2 +- symfony/user.md | 2 +- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/core/graphql.md b/core/graphql.md index 6194fcdc658..949333dccba 100644 --- a/core/graphql.md +++ b/core/graphql.md @@ -1950,7 +1950,7 @@ use ApiPlatform\Metadata\ApiResource; use ApiPlatform\Metadata\GraphQl\Mutation; use ApiPlatform\Metadata\GraphQl\Query; use ApiPlatform\Metadata\GraphQl\QueryCollection; -use Symfony\Component\Serializer\Annotation\Groups; +use Symfony\Component\Serializer\Attribute\Groups; #[ApiResource( normalizationContext: ['groups' => ['read']], @@ -2191,7 +2191,7 @@ namespace App\Entity; use ApiPlatform\Metadata\ApiResource; use ApiPlatform\Metadata\GraphQl\Mutation; -use Symfony\Component\Serializer\Annotation\Groups; +use Symfony\Component\Serializer\Attribute\Groups; #[ApiResource(graphQlOperations: [new Mutation(name: 'create', denormalizationContext: ['groups' => ['book:create']])])] class Book @@ -2253,7 +2253,7 @@ And in the author resource: namespace App\Entity; use ApiPlatform\Metadata\ApiResource; -use Symfony\Component\Serializer\Annotation\Groups; +use Symfony\Component\Serializer\Attribute\Groups; #[ApiResource] class Author @@ -2990,7 +2990,7 @@ use ApiPlatform\Metadata\GraphQl\Mutation; use App\Resolver\CreateMediaObjectResolver; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\HttpFoundation\File\File; -use Symfony\Component\Serializer\Annotation\Groups; +use Symfony\Component\Serializer\Attribute\Groups; use Symfony\Component\Validator\Constraints as Assert; use Vich\UploaderBundle\Mapping\Annotation as Vich; diff --git a/core/serialization.md b/core/serialization.md index d4b077ea094..131af338068 100644 --- a/core/serialization.md +++ b/core/serialization.md @@ -120,7 +120,7 @@ It is simple to specify what groups to use in the API system: namespace App\ApiResource; use ApiPlatform\Metadata\ApiResource; -use Symfony\Component\Serializer\Annotation\Groups; +use Symfony\Component\Serializer\Attribute\Groups; #[ApiResource( normalizationContext: ['groups' => ['read']], @@ -256,7 +256,7 @@ namespace App\ApiResource; use ApiPlatform\Metadata\ApiResource; use ApiPlatform\Metadata\Get; use ApiPlatform\Metadata\Patch; -use Symfony\Component\Serializer\Annotation\Groups; +use Symfony\Component\Serializer\Attribute\Groups; #[ApiResource(normalizationContext: ['groups' => ['get']])] #[Get] @@ -402,7 +402,7 @@ be embedded. namespace App\ApiResource; use ApiPlatform\Metadata\ApiResource; -use Symfony\Component\Serializer\Annotation\Groups; +use Symfony\Component\Serializer\Attribute\Groups; #[ApiResource(normalizationContext: ['groups' => ['book']])] class Book @@ -444,7 +444,7 @@ App\ApiResource\Book: namespace App\ApiResource; use ApiPlatform\Metadata\ApiResource; -use Symfony\Component\Serializer\Annotation\Groups; +use Symfony\Component\Serializer\Attribute\Groups; #[ApiResource] class Person @@ -544,7 +544,7 @@ It is a common problem to have entities that reference other entities of the sam namespace App\ApiResource; use ApiPlatform\Metadata\ApiResource; -use Symfony\Component\Serializer\Annotation\Groups; +use Symfony\Component\Serializer\Attribute\Groups; #[ApiResource( normalizationContext: ['groups' => ['person']], @@ -598,7 +598,7 @@ namespace App\ApiResource; use ApiPlatform\Metadata\ApiProperty; use ApiPlatform\Metadata\ApiResource; -use Symfony\Component\Serializer\Annotation\Groups; +use Symfony\Component\Serializer\Attribute\Groups; #[ApiResource( normalizationContext: ['groups' => ['person']], @@ -711,7 +711,7 @@ namespace App\Entity; use ApiPlatform\Metadata\ApiResource; use Doctrine\ORM\Mapping as ORM; -use Symfony\Component\Serializer\Annotation\Context; +use Symfony\Component\Serializer\Attribute\Context; use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer; #[ORM\Entity] @@ -745,7 +745,7 @@ namespace App\Entity; use ApiPlatform\Metadata\ApiResource; use Doctrine\ORM\Mapping as ORM; -use Symfony\Component\Serializer\Annotation\Context; +use Symfony\Component\Serializer\Attribute\Context; use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer; #[ORM\Entity] @@ -768,8 +768,8 @@ namespace App\Entity; use ApiPlatform\Metadata\ApiResource; use Doctrine\ORM\Mapping as ORM; -use Symfony\Component\Serializer\Annotation\Context; -use Symfony\Component\Serializer\Annotation\Groups; +use Symfony\Component\Serializer\Attribute\Context; +use Symfony\Component\Serializer\Attribute\Groups; use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer; #[ORM\Entity] @@ -803,7 +803,7 @@ namespace App\Entity; use ApiPlatform\Metadata\ApiResource; use ApiPlatform\Metadata\GetCollection; use Doctrine\ORM\Mapping as ORM; -use Symfony\Component\Serializer\Annotation\Groups; +use Symfony\Component\Serializer\Attribute\Groups; #[ApiResource] #[GetCollection(normalizationContext: ['groups' => 'greeting:collection:get'])] @@ -871,7 +871,7 @@ by admin users: namespace App\ApiResource; use ApiPlatform\Metadata\ApiResource; -use Symfony\Component\Serializer\Annotation\Groups; +use Symfony\Component\Serializer\Attribute\Groups; #[ApiResource( normalizationContext: ['groups' => ['book:output']], diff --git a/symfony/controllers.md b/symfony/controllers.md index 276179e12f1..0726db795d4 100644 --- a/symfony/controllers.md +++ b/symfony/controllers.md @@ -262,7 +262,7 @@ use ApiPlatform\Metadata\ApiResource; use ApiPlatform\Metadata\Get; use ApiPlatform\Metadata\Post; use App\Controller\CreateBookPublication; -use Symfony\Component\Serializer\Annotation\Groups; +use Symfony\Component\Serializer\Attribute\Groups; #[ApiResource(operations: [ new Get(), diff --git a/symfony/file-upload.md b/symfony/file-upload.md index 4e4c123eab5..aba48624315 100644 --- a/symfony/file-upload.md +++ b/symfony/file-upload.md @@ -68,7 +68,7 @@ use ApiPlatform\Metadata\Post; use ApiPlatform\OpenApi\Model; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\HttpFoundation\File\File; -use Symfony\Component\Serializer\Annotation\Groups; +use Symfony\Component\Serializer\Attribute\Groups; use Symfony\Component\Validator\Constraints as Assert; use Vich\UploaderBundle\Mapping\Attribute as Vich; @@ -455,7 +455,7 @@ use ApiPlatform\Metadata\GetCollection; use ApiPlatform\Metadata\Post; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\HttpFoundation\File\File; -use Symfony\Component\Serializer\Annotation\Groups; +use Symfony\Component\Serializer\Attribute\Groups; use Vich\UploaderBundle\Mapping\Annotation as Vich; #[Vich\Uploadable] diff --git a/symfony/fosuser-bundle.md b/symfony/fosuser-bundle.md index 1dc12951ca5..9cbdb370969 100644 --- a/symfony/fosuser-bundle.md +++ b/symfony/fosuser-bundle.md @@ -52,7 +52,7 @@ use ApiPlatform\Metadata\ApiResource; use Doctrine\ORM\Mapping as ORM; use FOS\UserBundle\Model\User as BaseUser; use FOS\UserBundle\Model\UserInterface; -use Symfony\Component\Serializer\Annotation\Groups; +use Symfony\Component\Serializer\Attribute\Groups; #[ORM\Entity] #[ORM\Table(name: 'fos_user')] diff --git a/symfony/user.md b/symfony/user.md index 25c30b6f6ba..9e5cdfda434 100644 --- a/symfony/user.md +++ b/symfony/user.md @@ -30,7 +30,7 @@ use App\State\UserPasswordHasher; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface; use Symfony\Component\Security\Core\User\UserInterface; -use Symfony\Component\Serializer\Annotation\Groups; +use Symfony\Component\Serializer\Attribute\Groups; use Symfony\Component\Validator\Constraints as Assert; #[ApiResource(