Skip to content

Commit afae479

Browse files
authored
Merge pull request #779 from borNfreee/patch-2
Fix incorrect docs for subresource operations
2 parents 361a588 + 7100414 commit afae479

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

core/operations.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ If you put the subresource on a relation that is to-many, you will retrieve a co
376376

377377
Last but not least, subresources can be nested, such that `/questions/42/answer/comments` will get the collection of comments for the answer to question 42.
378378

379-
You may want custom groups on subresources. Because a subresource is nothing more than a collection operation, you can set `normalization_context` or `denormalization_context` on that operation. To do so, you need to override `collectionOperations`. Based on the above operation, because we retrieve an answer, we need to alter its configuration:
379+
You may want custom groups on subresources. Because a subresource is nothing more than a collection operation, you can set `normalization_context` or `denormalization_context` on that operation. To do so, you need to override `subresourceOperations`. Based on the above operation, because we retrieve an answer, we need to alter its configuration:
380380

381381
```php
382382
<?php
@@ -387,7 +387,7 @@ namespace App\Entity;
387387
use ApiPlatform\Core\Annotation\ApiResource;
388388
389389
/**
390-
* @ApiResource(collectionOperations={
390+
* @ApiResource(subresourceOperations={
391391
* "api_questions_answer_get_subresource"={
392392
* "method"="GET",
393393
* "normalization_context"={"groups"={"foobar"}}
@@ -405,7 +405,7 @@ Or using YAML:
405405
```yaml
406406
# api/config/api_platform/resources.yaml
407407
App\Entity\Answer:
408-
collectionOperations:
408+
subresourceOperations:
409409
api_questions_answer_get_subresource:
410410
normalization_context: {groups: ['foobar']}
411411
```
@@ -421,16 +421,16 @@ Or in XML:
421421
xsi:schemaLocation="https://api-platform.com/schema/metadata
422422
https://api-platform.com/schema/metadata/metadata-2.0.xsd">
423423
<resource class="App\Entity\Answer">
424-
<collectionOperations>
425-
<collectionOperation name="api_questions_answer_get_subresource">
424+
<subresourceOperations>
425+
<subresourceOperation name="api_questions_answer_get_subresource">
426426
<attribute name="method">GET</attribute>
427427
<attribute name="normalization_context">
428428
<attribute name="groups">
429429
<attribute>foobar</attribute>
430430
</attribute>
431431
</attribute>
432-
</collectionOperation>
433-
</collectionOperations>
432+
</subresourceOperation>
433+
</subresourceOperations>
434434
</resource>
435435
</resources>
436436
```

0 commit comments

Comments
 (0)