sajad torkamani
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Annotation\ApiProperty;
use Symfony\Component\Serializer\Annotation\Groups;

    normalizationContext: ['groups' => ['read']],
    denormalizationContext: ['groups' => ['write']]
class Product
        description: "The unique identifier of the product.",
        example: "123",
        openapiContext: [
            'type' => 'integer',
            'description' => 'Unique identifier of the product.',
    private $id;

        description: "The name of the product.",
        example: "A fancy Product",
        openapiContext: [
            'type' => 'string',
            'description' => 'Name of the product.',
    #[Groups(['read', 'write'])]
    private $name;

Leave a comment

Your email address will not be published. Required fields are marked *