生成文档时 Api 平台重命名类?

时间:2021-02-11 16:23:18

标签: symfony entity api-platform.com

当我尝试访问 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

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

1 个答案:

答案 0 :(得分:0)

我在另一个实体关联中拼错了这个实体。

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