【问题标题】:Api Platform renaming class when generating Documentation?生成文档时 Api 平台重命名类?
【发布时间】:2021-05-15 10:07:53
【问题描述】:

当我尝试访问 Api Platform/Symfony 的默认 /api 时,我正在处理的项目出现问题。 加载文档页面并且已经生成缓存时会发生错误。 我检查了项目,我没有在任何地方将其加载为“调查”,生成缓存后错误就很明显了。 例如:我清理缓存 => 第一次 /api 加载顺利,任何进一步的 /api 加载都会触发错误。

我收到此错误: 类 App\Entity\survey 不存在 https://i.stack.imgur.com/83pK7.png

这是该实体的声明:

namespace App\Entity;

use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\SurveyRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Serializer\Annotation\Groups;
 /**
 * @ORM\Entity(repositoryClass=SurveyRepository::class)
 * @ApiResource(
 *     normalizationContext={
 *         "groups"={"survey_read"}
 *     },
 *     denormalizationContext={
 *          "groups"={"survey_write"}
 *     },
 *     collectionOperations={
 *          "get"={
 *              "security"="is_granted('ROLE_ADMIN')"
 *          },
 *          "post"={
 *              "security"="is_granted('ROLE_ADMIN')"
 *          }
 *     },
 *     itemOperations={
 *          "get"={
 *              "security"="is_granted('ROLE_USER')"
 *          },
 *          "delete"={
 *              "security"="is_granted('ROLE_ADMIN')"
 *          },
 *          "patch"={
 *              "security"="is_granted('ROLE_ADMIN')"
 *          }
 *     }
 * )
 * @ORM\HasLifecycleCallbacks
 */
class Survey

这是非常基本的配置,所以我不知道发生了什么。 如果有人在修复时遇到类似的错误?或一些我会找到答案的网址。 谢谢!!

【问题讨论】:

  • 文件叫什么?
  • 还有...类有哪个命名空间
  • App\Entity\survey 对比。 App\Entity\Survey 你一定在某个地方叫它survey 而不是Survey

标签: symfony entity api-platform.com


【解决方案1】:

我在与这个实体关联的另一个实体中拼写错误。

我现在的问题是它如何没有在第一次触发错误?

【讨论】:

    猜你喜欢
    • 2021-09-09
    • 1970-01-01
    • 1970-01-01
    • 2014-05-21
    • 1970-01-01
    • 2012-12-30
    • 1970-01-01
    • 2015-06-04
    • 1970-01-01
    相关资源
    最近更新 更多