How to hide an entity property in Symfony4 api-platform
Symfony Serializer supports @Groups
annotation, which gives you support to hide or show fields based on given group.
There is example in API Platform docs https://api-platform.com/docs/core/serialization/#using-serialization-groups
/** * @ApiResource( * normalizationContext={"groups"={"read"}}, * denormalizationContext={"groups"={"write"}} * ) */class Book{ /** * @Groups({"read", "write"}) */ public $name; /** * @Groups("write") */ public $author; // ...}