Skip to content

Commit 8aa9a54

Browse files
authored
Fix incorrect docs for subresource operations
We have just upgraded a big app from `2.3.6` to `2.4.2` and I think documentation is incorrect for subResources. Without these changes, our tests were failing 1. First of all, I think this is a BC break, because id *did* work before, but doesn't work after upgrading 2. What we did is just replaced `collectionOperations` with `subresourceOperations`, pleasee see the simplified diff ```diff # This is a subResource config - collectionOperations: + subresourceOperations: api_services_service_products_get_subresource: normalization_context: groups: [...] ``` Why doesn't it work in `2.4.2` anymore? Because the following code expects sub resources' configuration to be under `subresourceOperations` key: https://github.com/api-platform/core/blob/ef76e6bc20ca0658a28c5ccccc1b406f47dbbec3/src/Metadata/Resource/ResourceMetadata.php#L179-L182
1 parent 82b0cf1 commit 8aa9a54

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

core/operations.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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
```

0 commit comments

Comments
 (0)