Skip to content

Commit fabb572

Browse files
authored
Update dto.md
Add process explanation
1 parent d094c19 commit fabb572

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

core/dto.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ Similarly, the `output` attribute is used during [the serialization process](ser
6464

6565
The `input` and `output` attributes are taken into account by all the documentation generators (GraphQL and OpenAPI, Hydra).
6666

67+
Note that `Book` entity needs an id property. The simplest way is adding a public property called `$id`, as in the example. However, as in any other entity, you can use a private property, with getter and setter functions, and/or named it as you wish, provided you annotate it with `@ApiProperty (identifier = true)`. For instance, you could have a property called `$code`. So the `InputDataTransformer` actually transforms the isbn into a code. And then in the `OutputDataTransformer`, from this code into the name.
68+
6769
To create a `Book`, we `POST` a data structure corresponding to the `BookInput` class and get back in the response a data structure corresponding to the `BookOutput` class:
6870

6971
![Diagram post input output](images/diagrams/api-platform-post-i-o.png)

0 commit comments

Comments
 (0)