I have an entity with some OneToOne relations:
/**
* @OAProperty(type="integer")
* @SerializerGroups({"list", "detail"})
* @SerializerType("File::class")
* @ORMOneToOne(targetEntity="File")
*/
private ?File $cv = null;
And here is the File entity:
/**
* @OASchema()
* @ORMEntity(repositoryClass=FileRepository::class)
*/
class File
{
/**
* @OAProperty(type="integer")
* @SerializerGroups({"list", "detail"})
* @SerializerType("integer")
* @ORMId
* @ORMGeneratedValue
* @ORMColumn(type="integer")
*/
private $id;
/**
* @OAProperty(type="string")
* @SerializerGroups({"list", "detail"})
* @SerializerType("string")
* @ORMColumn(type="string", length=255, nullable=false)
*/
private $filename;
/**
* @OAProperty(type="string")
* @SerializerGroups({"list", "detail"})
* @SerializerType("string")
* @ORMColumn(type="guid", nullable=false)
*/
private $uuid;
/**
* @OAProperty(type="string")
* @SerializerGroups({"list", "detail"})
* @SerializerType("string")
* @ORMColumn(type="string", length=255, nullable=false)
*/
private $contentType;
/**
* @OAProperty(type="string", format="date-time")
* @SerializerGroups({"list", "detail"})
* @SerializerType("string")
* @ORMColumn(type="date", length=255, nullable=false)
*/
private $creationDate;
When I try to serialize with JMS my first entity, with the OneToOne relation:
$data = $this->serializer->serialize($candidate, 'json', SerializationContext::create()->setGroups(array('detail'))->setSerializeNull(true));
I always got the error: Class File does not exist
Obviously, it’s my @Type
annotation that is wrong, but why? What should I do.
Source: Symfony Questions
Was this helpful?
0 / 0