Search code examples
symfonyentityapi-platform.com

Api Platform renaming class when generating Documentation?


i have a problem on a project i'm working on, when i try to access the default /api for Api Platform/Symfony. The error ocurrs when the documentation page is loaded and cache has already been produced. I checked the project i don't load it as 'survey' anywhere, the error comes clearly after the cache is generated. Ex: i clean the cache => 1st /api load goes well, any further loads of /api trigger the error.

I get this error: Class App\Entity\survey does not exist https://i.sstatic.net/83pK7.png

Here is the declaration of said entity:

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

It's pretty basic config so i don't know what's going on. If someone has a similar error with a fix? or some url where i would find an answer. Thanks !!


Solution

  • I was mispelling in another entity association with this one.

    My question now is how it didn't trigger an error in the 1st time?