api-platform
api-platform copied to clipboard
Swagger UI ignores required property based on code case convention
API Platform version(s) affected: 2.6.8
Description
Swagger UI ignores required property when mixing snake_case for variables and camelCase for accessors in entities.
How to reproduce
#[ApiResource(...)]
#[ORM\Entity]
class AnEntity
{
#[ORM\OneToOne(...)]
#[Assert\NotNull]
private AnotherEntity $another_entity;
/**
* @return AnotherEntity
*/
public function getAnotherEntity(): AnotherEntity
{
return $this->another_entity;
}
/**
* @param AnotherEntity $another_entity
*/
public function setAnotherEntity(AnotherEntity $another_entity): void
{
$this->another_entity= $another_entity;
}
}
Possible Solution
- Clearly expose in documentation that Symfony naming convention is required
- Make metadata loaders aware of project naming convention
- The third solution
Additional Context