I have gone over the ApiPlatform SymfonyCasts and so far I love what I can do with it. However, I have hit the wall with the following scenario:
I have a class
Contractwith propertybaseContractwhich points to an object on which the new object should be based upon.Both
denormalizationContextandnormalizationContextare set for all fields (for now) tocontracts:writeandcontracts:read, respectfully.When I go to
/api, bothGETandPOSTendpoints show all properties, but skip thebaseContract...
Is there some gotcha to this?
The very basic idea is that I want to be able to post something like this:
{
"name": "string",
"description": "string",
"contractNo": "string",
"baseContract": "/api/contacts/{some_id}
}
/**
* @ORM\Entity(repositoryClass=ContractRepository::class)
*
* @ApiResource(
* normalizationContext={"groups": "contract:read"},
* denormalizationContext={"groups": "contract:write"},
* collectionOperations={
* "get",
* "post"
* },
* itemOperations={
* "get"
* }
* )
*/
class Contract
{
......
/**
* @ORM\ManyToOne(targetEntity=Contract::class)
* @ORM\JoinColumn()
*
* @Groups({"contract:read", "contract:write"})
*/
private ?Contract $baseContract;