Ayato-Stack
Ayato-Stack

Reputation: 25

Symfony API Platform Operations

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'
    ]
)]

Upvotes: 1

Views: 1772

Answers (1)

Nico Haase
Nico Haase

Reputation: 12130

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.

Upvotes: 5

Related Questions