嗨,我现在正在尝试API平台,当我试图限制集合操作时,我会得到一个错误。
能告诉我为什么会出现这个错误吗?
Unknown named parameter $collectionOperations
代码
<?php
namespace AppEntity;
use ApiPlatformMetadataApiResource;
use DoctrineORMMapping as ORM;
use SymfonyComponentValidatorConstraints as Assert;
/**
* A message
*
* @ORMEntity
*/
#[ApiResource(
collectionOperations: [
'get'
]
)]
collectionOperations
在ApiPlatform v3中不可用,但它是v2的一部分。代码现在应该是这样的:
use ApiPlatformMetadataApiResource;
use ApiPlatformMetadataGetCollection;
#[ApiResource(operations: [
new GetCollection()
])]
查看他们的文档以了解更多详细信息。