Hi right now I trying out API Platfom and when I try to restrict the collectionOperations I get an error.
can tell me why I get this error?
Unknown named parameter $collectionOperations
Code
<?php
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* A message
*
* @ORM\Entity
*/
#[ApiResource(
collectionOperations: [
'get'
]
)]
CodePudding user response:
collectionOperations
is not available in ApiPlatform v3, but was part of v2. The code should now look like this:
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\GetCollection;
#[ApiResource(operations: [
new GetCollection()
])]
Have a look at their documentation for more details.