如何配置ApiResource注解

问题描述 投票:0回答:1

我已将此注释添加到我的一个实体中,正如我在文档的最新版本中看到的那样,使用注释而不是属性(https://api-platform.com/docs/v2.5/core/serialization/) :

 * @ApiResource(attributes={
 *     "normalization_context"={"enable_max_depth"=true}}
 * )

我收到此错误:

An error occurred while instantiating the annotation @ApiResource declared on class App\Entity\Client: "Argument 1 passed to ApiPlatform\Metadata\ApiResource::__construct() must be of the type string or null, array given

我正在使用 API Platform 2.7,因为我仍在使用 PHP 7.4。

有什么建议吗?

api-platform.com
1个回答
0
投票

没关系...我导入了

ApiPlatform\Metadata\ApiResource
而不是
ApiPlatform\Core\Annotation\ApiResource
。 😞

© www.soinside.com 2019 - 2024. All rights reserved.