【问题标题】:Keep getting error on unknown property on annotation when using api-platform使用 api-platform 时,注释上的未知属性不断出现错误
【发布时间】:2019-02-07 15:11:10
【问题描述】:

我正在使用 symfony 4 的 api 平台。尝试使用 DTO 输出类并遵循文档 (https://api-platform.com/docs/core/dto/)。

我的班级看起来像这样:

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use ApiPlatform\Core\Annotation\ApiResource;
use App\DTO\ElementDTO;

/**
 * Elements
 * @ORM\Table(name="elements")
 * @ORM\Entity
 * @ApiResource(
 *    inputClass=false,
 *    outputClass=ElementDTO::class
 *   )
 */
class Elements
{
}

但是,我收到如下所示的错误:

Unknown property "inputClass" on annotation "ApiPlatform\Core\Annotation\ApiResource".

我搜索了api平台的源代码,没有找到对inputClass或outputClass的引用。文档中的方法是否已弃用或尚未实现?

【问题讨论】:

    标签: symfony annotations api-platform.com


    【解决方案1】:

    inputClassoutputClass 似乎都只在 v2.4.0-beta1 中,我认为你使用 2.3.6 因为这是最新的稳定版 AFAIK。

    查看此提交:https://github.com/api-platform/core/commit/cb5421abdb19392ac225909f63cf8677583cedd3

    尝试在您的代码中使用测试版(或dev-master),看看它是否有效

    【讨论】:

      猜你喜欢
      • 2018-01-16
      • 1970-01-01
      • 2023-03-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多