Description
assertMatchesResourceItemJsonSchema throws JsonSchema\Exception\InvalidArgumentException: 0 is an invalid type for int when comparing against an int backed enum property.
How to reproduce
Simplified example:
public Status: int {
case Active = 1;
case Inactive = 0;
}
class Entity {
[ORM\Column()]
private Status $status = Status::Active;
}
Use assertMatchesResourceItemJsonSchema against a request to /api/entities/1
Possible Solution
TypeConstraint.php@278 compares $type to 'integer'. Looks like int backed enums are detected as 'int' and not 'integer'.
API Platform version(s) affected: 3.2.1
Description
assertMatchesResourceItemJsonSchema throws JsonSchema\Exception\InvalidArgumentException: 0 is an invalid type for int when comparing against an int backed enum property.
How to reproduce Simplified example:
public Status: int { case Active = 1; case Inactive = 0; }
class Entity {
[ORM\Column()]
}
Use assertMatchesResourceItemJsonSchema against a request to /api/entities/1
Possible Solution
TypeConstraint.php@278 compares $type to 'integer'. Looks like int backed enums are detected as 'int' and not 'integer'.
Additional Context
Symfony 6.3.6 PHP 8.2