Closed ttskch closed 4 weeks ago
[!NOTE] Is this a bug? If so, we can close this PR and go to #6394.
In the schema for the request body of application/merge-patch+json PATCH operation, all required properties should be output as optional.
application/merge-patch+json
See here: https://datatracker.ietf.org/doc/html/rfc7386#section-3
This PR fixes the SchemaFactory for the 'json' format to output required properties as optional only for input context of PATCH operations.
'json'
For example, for the following entity, the output of the OpenAPI document will change as follows:
#[ORM\Entity(repositoryClass: TodoRepository::class)] #[ApiResource] class Todo { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id = null; #[ORM\Column(length: 255)] #[Assert\NotBlank] #[Assert\Length(max: 255)] private ?string $title = null; #[ORM\Column(type: Types::TEXT, nullable: true)] private ?string $description = null; #[ORM\Column] #[Assert\NotNull] private ?bool $done = null;
This PR was integrated into #6394.
refs: https://github.com/api-platform/core/pull/6394#issuecomment-2138917295
In the schema for the request body of
application/merge-patch+json
PATCH operation, all required properties should be output as optional.This PR fixes the SchemaFactory for the
'json'
format to output required properties as optional only for input context of PATCH operations.For example, for the following entity, the output of the OpenAPI document will change as follows: