Skip to content

Commit db083c3

Browse files
committed
Added YAML examplel for serialization groups doc.
1 parent f8d876a commit db083c3

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

core/serialization.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,18 @@ Alternatively, you can use the more verbose syntax:
106106
*/
107107
```
108108

109+
You can also use the YAML configuration format:
110+
111+
```yaml
112+
# api/config/api_platform/resources.yaml
113+
App\Entity\Book:
114+
attributes:
115+
normalization_context:
116+
groups: ['read']
117+
denormalization_context:
118+
groups: ['write']
119+
```
120+
109121
In the previous example, the `name` property will be visible when reading (`GET`) the object, and it will also be available
110122
to write (`PUT/POST`). The `author` property will be write-only; it will not be visible when serialized responses are
111123
returned by the API.

0 commit comments

Comments
 (0)