Skip to content

Commit e2dd55d

Browse files
authored
Merge pull request #735 from soyuka/name_converter
change name converter configuration node
2 parents 978535d + 3adf4b6 commit e2dd55d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

core/serialization.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -516,13 +516,13 @@ This will add the serialization group `can_retrieve_book` only if the currently
516516
instance.
517517

518518
Note: In this example, we use the `TokenStorageInterface` to verify access to the book instance. However, Symfony
519-
provides many useful other services that might be better suited to your use case (for example, the [`AuthorizationChecker`](https://symfony.com/doc/current/components/security/authorization.html#authorization-checker)).
519+
provides many useful other services that might be better suited to your use case. For example, the [`AuthorizationChecker`](https://symfony.com/doc/current/components/security/authorization.html#authorization-checker).
520520

521521
## Name Conversion
522522

523523
The Serializer Component provides a handy way to map PHP field names to serialized names. See the related [Symfony documentation](http://symfony.com/doc/master/components/serializer.html#converting-property-names-when-serializing-and-deserializing).
524524

525-
To use this feature, declare a new service with the id `app.name_converter`. For example, you can convert `CamelCase` to
525+
To use this feature, declare a new name converter service. For example, you can convert `CamelCase` to
526526
`snake_case` with the following configuration:
527527

528528
```yaml
@@ -537,9 +537,11 @@ api_platform:
537537
name_converter: 'Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter'
538538
```
539539

540+
If symfony's `MetadataAwareNameConverter` is available it'll be used by default. If you specify one in ApiPlatform configuration, it'll be used. Note that you can use decoration to benefit from this name converter in your own implementation.
541+
540542
## Decorating a Serializer and Adding Extra Data
541543

542-
In the following example, we will see how we can add extra information to the serialized output. Here is how we can add the
544+
In the following example, we will see how we add extra informations to the serialized output. Here is how we add the
543545
date on each request in `GET`:
544546

545547
```yaml

0 commit comments

Comments
 (0)