Skip to content

Commit f140912

Browse files
authored
fix: add resources root key in YAML (#1706)
1 parent 0b3c4dd commit f140912

11 files changed

+184
-150
lines changed

core/controllers.md

Lines changed: 46 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,15 @@ class Book
114114

115115
```yaml
116116
# api/config/api_platform/resources.yaml
117-
App\Entity\Book:
118-
operations:
119-
ApiPlatform\Metadata\Get: ~
120-
post_publication:
121-
class: ApiPlatform\Metadata\Post
122-
method: POST
123-
uriTemplate: /books/{id}/publication
124-
controller: App\Controller\CreateBookPublication
117+
resources:
118+
App\Entity\Book:
119+
operations:
120+
ApiPlatform\Metadata\Get: ~
121+
post_publication:
122+
class: ApiPlatform\Metadata\Post
123+
method: POST
124+
uriTemplate: /books/{id}/publication
125+
controller: App\Controller\CreateBookPublication
125126
```
126127
127128
```xml
@@ -185,14 +186,15 @@ class Book
185186

186187
```yaml
187188
# api/config/api_platform/resources.yaml
188-
App\Entity\Book:
189-
operations:
190-
ApiPlatform\Metadata\Get: ~
191-
post_publication:
192-
class: ApiPlatform\Metadata\Post
193-
method: POST
194-
uriTemplate: /books/{id}/publication
195-
controller: ApiPlatform\Action\PlaceholderAction
189+
resources:
190+
App\Entity\Book:
191+
operations:
192+
ApiPlatform\Metadata\Get: ~
193+
post_publication:
194+
class: ApiPlatform\Metadata\Post
195+
method: POST
196+
uriTemplate: /books/{id}/publication
197+
controller: ApiPlatform\Action\PlaceholderAction
196198
```
197199
198200
```xml
@@ -255,15 +257,16 @@ class Book
255257

256258
```yaml
257259
# api/config/api_platform/resources.yaml
258-
App\Entity\Book:
259-
operations:
260-
ApiPlatform\Metadata\Get: ~
261-
post_publication:
262-
class: ApiPlatform\Metadata\Get
263-
uriTemplate: /books/{id}/publication
264-
controller: App\Controller\CreateBookPublication
265-
normalizationContext:
266-
groups: ['publication']
260+
resources:
261+
App\Entity\Book:
262+
operations:
263+
ApiPlatform\Metadata\Get: ~
264+
post_publication:
265+
class: ApiPlatform\Metadata\Get
266+
uriTemplate: /books/{id}/publication
267+
controller: App\Controller\CreateBookPublication
268+
normalizationContext:
269+
groups: ['publication']
267270
```
268271
269272
```xml
@@ -326,14 +329,15 @@ class Book
326329

327330
```yaml
328331
# api/config/api_platform/resources.yaml
329-
App\Entity\Book:
330-
operations:
331-
ApiPlatform\Metadata\Get: ~
332-
post_publication:
333-
class: ApiPlatform\Metadata\Post
334-
uriTemplate: /books/{id}/publication
335-
controller: App\Controller\CreateBookPublication
336-
read: false
332+
resources:
333+
App\Entity\Book:
334+
operations:
335+
ApiPlatform\Metadata\Get: ~
336+
post_publication:
337+
class: ApiPlatform\Metadata\Post
338+
uriTemplate: /books/{id}/publication
339+
controller: App\Controller\CreateBookPublication
340+
read: false
337341
```
338342
339343
```xml
@@ -398,14 +402,15 @@ class Book
398402

399403
```yaml
400404
# api/config/api_platform/resources.yaml
401-
App\Entity\Book:
402-
operations:
403-
ApiPlatform\Metadata\Get: ~
404-
post_publication:
405-
class: ApiPlatform\Metadata\Post
406-
routeName: book_post_publication
407-
book_post_discontinuation:
408-
class: ApiPlatform\Metadata\Post
405+
resources:
406+
App\Entity\Book:
407+
operations:
408+
ApiPlatform\Metadata\Get: ~
409+
post_publication:
410+
class: ApiPlatform\Metadata\Post
411+
routeName: book_post_publication
412+
book_post_discontinuation:
413+
class: ApiPlatform\Metadata\Post
409414
```
410415
411416
```xml

core/dto.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,12 @@ class Book {}
140140
```
141141
```yaml
142142
# api/config/api_platform/resources.yaml
143-
App\Entity\Book:
144-
operations:
145-
ApiPlatform\Metadata\Post:
146-
output: App\Dto\AnotherRepresentation
147-
processor: App\State\BookRepresentationProcessor
143+
resources:
144+
App\Entity\Book:
145+
operations:
146+
ApiPlatform\Metadata\Post:
147+
output: App\Dto\AnotherRepresentation
148+
processor: App\State\BookRepresentationProcessor
148149
```
149150
```xml
150151
<?xml version="1.0" encoding="UTF-8" ?>

core/extending-jsonld-context.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,11 @@ class Book
8888

8989
```yaml
9090
# api/config/api_platform/resources.yaml
91-
App\Entity\Book:
92-
operations:
93-
ApiPlatform\Metadata\Get:
94-
hydraContext: { foo: 'bar' }
91+
resources:
92+
App\Entity\Book:
93+
operations:
94+
ApiPlatform\Metadata\Get:
95+
hydraContext: { foo: 'bar' }
9596
```
9697
9798
```xml

core/filters.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,12 @@ to a Resource in two ways:
7171

7272
```yaml
7373
# api/config/api_platform/resources.yaml
74-
App\Entity\Offer:
75-
operations:
76-
ApiPlatform\Metadata\GetCollection:
77-
filters: ['offer.date_filter']
78-
# ...
74+
resources:
75+
App\Entity\Offer:
76+
operations:
77+
ApiPlatform\Metadata\GetCollection:
78+
filters: ['offer.date_filter']
79+
# ...
7980
```
8081

8182
```xml

core/messenger.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,16 @@ final class Person
5151
```yaml
5252
# api/config/api_platform/resources.yaml
5353
resources:
54-
App\Entity\Person:
55-
operations:
56-
ApiPlatform\Metadata\Post:
57-
status: 202
58-
messenger: true
59-
output: false
60-
ApiPlatform\Metadata\Get:
61-
status: 404
62-
controller: ApiPlatform\Action\NotFoundAction
63-
read: false
54+
App\Entity\Person:
55+
operations:
56+
ApiPlatform\Metadata\Post:
57+
status: 202
58+
messenger: true
59+
output: false
60+
ApiPlatform\Metadata\Get:
61+
status: 404
62+
controller: ApiPlatform\Action\NotFoundAction
63+
read: false
6464
```
6565
6666
[/codeSelector]

core/openapi.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -161,25 +161,26 @@ class Product // The class name will be used to name exposed resources
161161
```
162162

163163
```yaml
164-
# api/config/api_platform/resources.yaml
165-
resources:
164+
# api/config/api_platform/properties.yaml
165+
properties:
166166
App\Entity\Product:
167-
properties:
168167
name:
169-
attributes:
170-
openapi_context:
171-
type: string
172-
enum: ['one', 'two']
173-
example: one
168+
attributes:
169+
openapiContext:
170+
type: string
171+
enum: ['one', 'two']
172+
example: one
174173
timestamp:
175-
attributes:
176-
openapi_context:
177-
type: string
178-
format: date-time
174+
attributes:
175+
openapiContext:
176+
type: string
177+
format: date-time
179178
```
180179
181180
```xml
182181
<?xml version="1.0" encoding="UTF-8" ?>
182+
<!-- api/config/api_platform/properties.xml -->
183+
183184
<properties xmlns="https://api-platform.com/schema/metadata/properties-3.0"
184185
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
185186
xsi:schemaLocation="https://api-platform.com/schema/metadata/properties-3.0

core/operations.md

Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,11 @@ class Book
9090

9191
```yaml
9292
# api/config/api_platform/resources.yaml
93-
App\Entity\Book:
94-
operations:
95-
ApiPlatform\Metadata\GetCollection: ~ # nothing more to add if we want to keep the default controller
96-
ApiPlatform\Metadata\Get: ~
93+
resources:
94+
App\Entity\Book:
95+
operations:
96+
ApiPlatform\Metadata\GetCollection: ~ # nothing more to add if we want to keep the default controller
97+
ApiPlatform\Metadata\Get: ~
9798
```
9899
99100
```xml
@@ -143,12 +144,13 @@ class Book
143144

144145
```yaml
145146
# api/config/api_platform/resources.yaml
146-
App\Entity\Book:
147-
operations:
148-
ApiPlatform\Metadata\GetCollection:
149-
method: GET
150-
ApiPlatform\Metadata\Get:
151-
method: GET
147+
resources:
148+
App\Entity\Book:
149+
operations:
150+
ApiPlatform\Metadata\GetCollection:
151+
method: GET
152+
ApiPlatform\Metadata\Get:
153+
method: GET
152154
```
153155
154156
```xml
@@ -203,13 +205,14 @@ class Book
203205

204206
```yaml
205207
# api/config/api_platform/resources.yaml
206-
App\Entity\Book:
207-
operations:
208-
ApiPlatform\Metadata\GetCollection: ~
209-
ApiPlatform\Metadata\Get:
210-
controller: ApiPlatform\Action\NotFoundAction
211-
read: false
212-
output: false
208+
resources:
209+
App\Entity\Book:
210+
operations:
211+
ApiPlatform\Metadata\GetCollection: ~
212+
ApiPlatform\Metadata\Get:
213+
controller: ApiPlatform\Action\NotFoundAction
214+
read: false
215+
output: false
213216
```
214217
215218
```xml
@@ -272,21 +275,22 @@ class Book
272275

273276
```yaml
274277
# api/config/api_platform/resources.yaml
275-
App\Entity\Book:
276-
operations:
277-
ApiPlatform\Metadata\Post:
278-
uriTemplate: '/grimoire'
279-
status: 301
280-
ApiPlatform\Metadata\Get:
281-
uriTemplate: '/grimoire/{id}'
282-
requirements:
283-
id: '\d+'
284-
defaults:
285-
color: 'brown'
286-
host: '{subdomain}.api-platform.com'
287-
schemes: ['https']
288-
options:
289-
my_option: 'my_option_value'
278+
resources:
279+
App\Entity\Book:
280+
operations:
281+
ApiPlatform\Metadata\Post:
282+
uriTemplate: '/grimoire'
283+
status: 301
284+
ApiPlatform\Metadata\Get:
285+
uriTemplate: '/grimoire/{id}'
286+
requirements:
287+
id: '\d+'
288+
defaults:
289+
color: 'brown'
290+
host: '{subdomain}.api-platform.com'
291+
schemes: ['https']
292+
options:
293+
my_option: 'my_option_value'
290294
```
291295
292296
```xml
@@ -349,8 +353,9 @@ class Book
349353

350354
```yaml
351355
# api/config/api_platform/resources.yaml
352-
App\Entity\Book:
353-
routePrefix: /library
356+
resources:
357+
App\Entity\Book:
358+
routePrefix: /library
354359
```
355360
356361
```xml

core/pagination.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,9 @@ class Book
9090

9191
```yaml
9292
# api/config/api_platform/resources.yaml
93-
App\Entity\Book:
94-
paginationEnabled: false
93+
resources:
94+
App\Entity\Book:
95+
paginationEnabled: false
9596
```
9697
[/codeSelector]
9798
@@ -124,10 +125,11 @@ class Book
124125

125126
```yaml
126127
# api/config/api_platform/resources.yaml
127-
App\Entity\Book:
128-
operations:
129-
ApiPlatform\Metadata\GetCollection:
130-
paginationEnabled: false
128+
resources:
129+
App\Entity\Book:
130+
operations:
131+
ApiPlatform\Metadata\GetCollection:
132+
paginationEnabled: false
131133
```
132134
133135
```xml

0 commit comments

Comments
 (0)