api 平台为我生成的架构和 json 请求权是错误的,档案实体与 fase、类型和状态实体有关系,因此在制作新档案时,fase、类型和状态实体通过 id 连接到每个档案实体,但生成的架构是错误的 fase 有一个标题字段,我想发布的不是字面上的 fase 对象,与其他 2 个实体相同
我的档案实体
<?php
namespace App\Entity;
use Doctrine\DBAL\Types\Types;
use Symfony\Component\Serializer\Annotation\Groups;
use Doctrine\ORM\Mapping as ORM;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Doctrine\Common\Filter\SearchFilterInterface;
use ApiPlatform\Doctrine\Common\Filter\DateFilterInterface;
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Doctrine\Orm\Filter\DateFilter;
use Proxies\__CG__\App\Entity\Fase;
#[ApiResource(normalizationContext: ['groups' => ['dossier']])]
#[ApiFilter(DateFilter::class, properties: ['deleted_at' => DateFilterInterface::INCLUDE_NULL_AFTER])]
#[ApiFilter(SearchFilter::class, properties: ['title' => SearchFilterInterface::STRATEGY_PARTIAL, 'created_at' => SearchFilterInterface::STRATEGY_PARTIAL])]
#[ORM\Entity]
class Dossier
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups('dossier')]
private ?int $id = null;
#[ORM\Column(length: 255)]
#[Groups('dossier')]
private ?string $title = null;
#[ORM\Column(type: Types::SMALLINT)]
#[Groups('dossier')]
private ?int $status = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
#[Groups('dossier')]
private ?\DateTimeInterface $created_at = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
#[Groups('dossier')]
private ?\DateTimeInterface $updated_at = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true, options: ['default' => null])]
#[Groups('dossier')]
private ?\DateTimeInterface $deleted_at = null;
#[ORM\ManyToOne(targetEntity: Fase::class)]
#[ORM\JoinColumn(nullable: false)]
#[Groups(['dossier', 'dossier:write'])]
private ?Fase $fase = null;
#[ORM\ManyToOne(targetEntity: Type::class)]
#[ORM\JoinColumn(nullable: false)]
#[Groups(['dossier', 'dossier:write'])]
private ?Type $type = null;
#[ORM\ManyToOne(targetEntity: DossierStatus::class)]
#[ORM\JoinColumn(nullable: false)]
#[Groups(['dossier', 'dossier:write'])]
private ?DossierStatus $dossier_status = null;
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getStatus(): ?int
{
return $this->status;
}
public function setStatus(int $status): self
{
$this->status = $status;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->created_at;
}
public function setCreatedAt(\DateTimeInterface $created_at): self
{
$this->created_at = $created_at;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updated_at;
}
public function setUpdatedAt(\DateTimeInterface $updated_at): self
{
$this->updated_at = $updated_at;
return $this;
}
public function getDeletedAt(): ?\DateTimeInterface
{
return $this->deleted_at;
}
public function setDeletedAt(?\DateTimeInterface $deleted_at): self
{
$this->deleted_at = $deleted_at;
return $this;
}
public function getFase(): ?Fase
{
return $this->fase;
}
public function setFase(?Fase $fase): self
{
$this->fase = $fase;
return $this;
}
public function getType(): ?Type
{
return $this->type;
}
public function setType(?Type $type): self
{
$this->type = $type;
return $this;
}
public function getDossierStatus(): ?DossierStatus
{
return $this->dossier_status;
}
public function setDossierStatus(?DossierStatus $dossier_status): self
{
$this->dossier_status = $dossier_status;
return $this;
}
}
为帖子生成的架构
{
"title": "string",
"status": 0,
"fase": "string",
"type": "string",
"createdAt": "2023-03-22T10:17:02.147Z",
"updatedAt": "2023-03-22T10:17:02.147Z",
"deletedAt": "2023-03-22T10:17:02.147Z",
"dossierStatus": "string"
}
我想要的
{
"title" : "Sample Dossier",
"status": 1,
" fase_title": "AdviesLijn",
"fase_status": 1,
"type_title": "Rijbewijs",
"type_status": 1,
"dossier_status_title": "Wachten Op Document",
"dossier_status": 1,
"createdAt": "2023-03-22T09:53:53.753Z"
}