@@ -351,6 +351,89 @@ App\Entity\Book:
351
351
352
352
In all these examples, the ` method ` attribute is omitted because it matches the operation name.
353
353
354
+ When specifying sub options, you must always use snake case as demonstrated below with the ` denormalization_context ` option on the ` put ` operation:
355
+
356
+ [ codeSelector]
357
+
358
+ ``` php
359
+ <?php
360
+ // api/src/Entity/Book.php
361
+
362
+ namespace App\Entity;
363
+
364
+ use ApiPlatform\Core\Annotation\ApiResource;
365
+
366
+ #[ApiResource(
367
+ itemOperations: [
368
+ 'get',
369
+ 'put' => [
370
+ 'denormalization_context' => [
371
+ 'groups' => ['item:put'],
372
+ 'swagger_definition_name' => 'put',
373
+ ],
374
+ ],
375
+ 'delete',
376
+ ],
377
+ ],
378
+ denormalizationContext: [
379
+ 'groups' => ['item:post'],
380
+ 'swagger_definition_name' => 'post',
381
+ ],
382
+ )]
383
+ class Book
384
+ {
385
+ //...
386
+ }
387
+ ```
388
+
389
+ ``` yaml
390
+ # api/config/api_platform/resources.yaml
391
+ App\Entity\Book :
392
+ itemOperations :
393
+ get : ~
394
+ put :
395
+ denormalization_context :
396
+ groups : ['item:put']
397
+ swagger_definition_name : ' put' ,
398
+ delete : ~
399
+ denormalizationContext :
400
+ groups : ['item:post']
401
+ swagger_definition_name : ' post'
402
+ ` ` `
403
+
404
+ ` ` ` xml
405
+ <?xml version="1.0" encoding="UTF-8" ?>
406
+ <!-- api/config/api_platform/resources.xml -->
407
+
408
+ <resources xmlns="https://api-platform.com/schema/metadata"
409
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
410
+ xsi:schemaLocation="https://api-platform.com/schema/metadata
411
+ https://api-platform.com/schema/metadata/metadata-2.0.xsd">
412
+ <resource class="App\Entity\Book">
413
+ <itemOperations>
414
+ <itemOperation name="get" />
415
+ <itemOperation name="put">
416
+ <attribute name="denormalization_context">
417
+ <attribute name="groups">
418
+ <attribute>item:put</attribute>
419
+ </attribute>
420
+ <attribute name="swagger_definition_name">put</attribute>
421
+ </attribute>
422
+ </itemOperation>
423
+ <itemOperation name="delete" />
424
+ </itemOperations>
425
+ <denormalizationContext>
426
+ <attribute name="groups">
427
+ <attribute>item:post</attribute>
428
+ </attribute>
429
+ <attribute name="swagger_definition_name">post</attribute>
430
+ </denormalizationContext>
431
+ </resource>
432
+ </resources>
433
+ ```
434
+
435
+ [ /codeSelector]
436
+
354
437
## Prefixing All Routes of All Operations
355
438
356
439
Sometimes it's also useful to put a whole resource into its own "namespace" regarding the URI. Let's say you want to
0 commit comments