Skip to content

Commit 084ad21

Browse files
authored
Add yaml example for subresource configuration
1 parent ded58e5 commit 084ad21

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

core/operations.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,19 @@ class Question
271271
}
272272
```
273273

274+
Alternatively, you can use the YAML configuration format:
275+
276+
```yaml
277+
AppBundle\Entity\Answer: ~
278+
AppBundle\Entity\Question:
279+
properties:
280+
answer:
281+
subresource:
282+
resourceClass: AppBundle\Entity\Answer
283+
collection: false
284+
```
285+
286+
274287
Note that all we had to do is to set up `@ApiSubresource` on the `Question::answer` relation. Because the `answer` is a to-one relation, we know that this subresource is an item. Therefore the response will look like this:
275288

276289
```json

0 commit comments

Comments
 (0)