Skip to content

Commit 2623239

Browse files
GregoireHebertdunglas
authored andcommitted
Enhance yaml-xml serialization groups configuration doc (#447)
* Enhance yaml-xml serialization groups configuration doc * Add default configuration * remove useless config and improve mapping need explaination * Update getting-started.md
1 parent 871d58b commit 2623239

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

core/getting-started.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,25 @@ resources:
196196
pagination_items_per_page: 25 # optional
197197
```
198198
199+
If you prefer to use XML or YAML files instead of annotations, you must configure API Platform to load the appropriate files:
200+
201+
```yaml
202+
# api/config/packages/api_platform.yaml
203+
api_platform:
204+
mapping:
205+
paths:
206+
- '%kernel.project_dir%/src/Entity' # default configuration for annotations
207+
- '%kernel.project_dir%/config/api_platform' # yaml or xml directory configuration
208+
```
209+
210+
The API Platform's configuration (annotations, `YAML` or `XML`) only allow to configure the context passed to the Symfony Serializer:
211+
212+
* The `normalization_context` key will be passed as 3rd argument of [the `Serializer::serialize()` method](https://api.symfony.com/master/Symfony/Component/Serializer/SerializerInterface.html#method_serialize)
213+
* The `denormalization_context` key will be passed as 4th argument of [the `Serializer::deserialize()` method](https://api.symfony.com/master/Symfony/Component/Serializer/SerializerInterface.html#method_deserialize)
214+
215+
216+
To configure the serialization groups of classes's properties, you must use directly [the Symfony Serializer's configuration files or annotations]( https://symfony.com/doc/current/components/serializer.html#attributes-groups).
217+
199218
**You're done!**
200219

201220
You now have a fully featured API exposing your entities.

0 commit comments

Comments
 (0)