您好,現在我正在嘗試 API 平臺,當我嘗試限制 collectionOperations 時出現錯誤。
能告訴我為什么會出現這個錯誤嗎?
Unknown named parameter $collectionOperations
代碼
<?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'
]
)]
uj5u.com熱心網友回復:
collectionOperations在 ApiPlatform v3 中不可用,但它是 v2 的一部分。代碼現在應該如下所示:
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\GetCollection;
#[ApiResource(operations: [
new GetCollection()
])]
查看他們的檔案以獲取更多詳細資訊。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/513423.html
