Skip to content

Commit 62be9f9

Browse files
rogamooredunglas
authored andcommitted
Fix routePrefix documentation (#528)
* Fix routePrefix documentation It needs to be either ``` @ApiResource(attributes={"route_prefix"="/library"}) ``` or ``` @ApiResource(routePrefix="/library") ``` to work correctly. * Update operations.md
1 parent 13aeb73 commit 62be9f9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

core/operations.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ In all the previous examples, you can safely remove the `method` because the met
232232

233233
Sometimes it's also useful to put a whole resource into its own "namespace" regarding the URI. Let's say you want to
234234
put everything that's related to a `Book` into the `library` so that URIs become `library/book/{id}`. In that case
235-
you don't need to override all the operations to set the path but configure a `routePrefix` for the whole entity instead:
235+
you don't need to override all the operations to set the path but configure the `route_prefix` attribute for the whole entity instead:
236236

237237
```php
238238
<?php
@@ -241,15 +241,16 @@ you don't need to override all the operations to set the path but configure a `r
241241
use ApiPlatform\Core\Annotation\ApiResource;
242242

243243
/**
244-
* ...
245-
* @ApiResource("attributes"={"routePrefix"="/library"})
244+
* @ApiResource(routePrefix="/library")
246245
*/
247246
class Book
248247
{
249248
//...
250249
}
251250
```
252251

252+
Alternatively, the more verbose attributes syntax can be used `@ApiResource(attributes={"route_prefix"="/library"})`
253+
253254
## Subresources
254255

255256
Since ApiPlatform 2.1, you can declare subresources. A subresource is a collection or an item that belongs to another resource.

0 commit comments

Comments
 (0)