I'm building an API with API Platform under Symfony4,
I want to hide an entity in the doc which is accessible only to the ROLE_ADMIN of the blow no interest to be visible in the doc.
Here is the entity I want to hide:
<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ApiResource(
* attributes={"access_control"="is_granted('ROLE_ADMIN')"}
* )
* @ORM\Entity(repositoryClass="App\Repository\OrderStatusRepository")
*/
class OrderStatus
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
* @Groups("orderGET")
*/
private $label;
/**
* @return int|null
*/
public function getId(): ?int
{
return $this->id;
}
/**
* @return null|string
*/
public function getLabel(): ?string
{
return $this->label;
}
/**
* @param string $label
* @return OrderStatus
*/
public function setLabel(string $label): self
{
$this->label = $label;
return $this;
}
}
Thank you for your help
api_platform.swagger.normalizer.api_gateway
becameapi_platform.openapi.normalizer.api_gateway
– Infantry