@@ -26,9 +26,9 @@ use Symfony\Component\Validator\Constraints as Assert; // Symfony's built-in con
26
26
/**
27
27
* A product.
28
28
*
29
- * @ApiResource
30
29
* @ORM\Entity
31
30
*/
31
+ #[ApiResource]
32
32
class Product
33
33
{
34
34
/**
@@ -138,10 +138,7 @@ You can configure the groups you want to use when the validation occurs directly
138
138
use ApiPlatform\Core\Annotation\ApiResource;
139
139
use Symfony\Component\Validator\Constraints as Assert;
140
140
141
- /**
142
- * @ApiResource(attributes={"validation_groups"={"a", "b"}})
143
- * ...
144
- */
141
+ #[ApiResource(attributes: ['validation_groups' => ['a', 'b']])]
145
142
class Book
146
143
{
147
144
/**
@@ -179,20 +176,17 @@ You can have different validation for each [operation](operations.md) related to
179
176
use ApiPlatform\Core\Annotation\ApiResource;
180
177
use Symfony\Component\Validator\Constraints as Assert;
181
178
182
- /**
183
- * @ApiResource(
184
- * collectionOperations={
185
- * "get",
186
- * "post"={"validation_groups"={"Default", "postValidation"}}
187
- * },
188
- * itemOperations={
189
- * "delete",
190
- * "get",
191
- * "put"={"validation_groups"={"Default", "putValidation"}}
192
- * }
193
- * )
194
- * ...
195
- */
179
+ #[ApiResource(
180
+ collectionOperations: [
181
+ 'get',
182
+ 'post' => ['validation_groups' => ['Default', 'postValidation']]
183
+ ],
184
+ itemOperations: [
185
+ 'delete',
186
+ 'get',
187
+ 'put' => ['validation_groups' => ['Default', 'putValidation']]
188
+ ]
189
+ )]
196
190
class Book
197
191
{
198
192
/**
@@ -247,11 +241,9 @@ In the following example, we use a static method to return the validation groups
247
241
use ApiPlatform\Core\Annotation\ApiResource;
248
242
use Symfony\Component\Validator\Constraints as Assert;
249
243
250
- /**
251
- * @ApiResource(
252
- * attributes={"validation_groups"={Book::class, "validationGroups"}}
253
- * )
254
- */
244
+ #[ApiResource(
245
+ attributes: ['validation_groups' => [Book::class, 'validationGroups']]
246
+ )]
255
247
class Book
256
248
{
257
249
/**
@@ -329,9 +321,7 @@ use ApiPlatform\Core\Annotation\ApiResource;
329
321
use App\Validator\AdminGroupsGenerator;
330
322
use Symfony\Component\Validator\Constraints as Assert;
331
323
332
- /**
333
- * @ApiResource(attributes={"validation_groups"=AdminGroupsGenerator::class})
334
- */
324
+ #[ApiResource(attributes: ['validation_groups' => AdminGroupsGenerator::class])
335
325
class Book
336
326
{
337
327
/**
@@ -394,15 +384,15 @@ use App\Validator\MySequencedGroup; // the sequence group to use
394
384
use Doctrine\ORM\Mapping as ORM;
395
385
396
386
/**
397
- * @ApiResource(
398
- * collectionOperations={
399
- * "post" = {
400
- * "validation_groups" = MySequencedGroup::class
401
- * }
402
- * }
403
- * )
404
387
* @ORM\Entity
405
388
*/
389
+ # [ApiResource(
390
+ collectionOperations : [
391
+ ' post' => [
392
+ ' validation_groups' => MySequencedGroup::class
393
+ ]
394
+ ]
395
+ )]
406
396
class Greeting
407
397
{
408
398
/**
0 commit comments