fix: Cannot pass null to nullable enum parameters (#299)
* nullable enum value * fix tests
This commit is contained in:
parent
797472777f
commit
06917f6af6
1 changed files with 5 additions and 3 deletions
|
|
@ -374,7 +374,8 @@ final class SchemaGenerator implements SchemaGeneratorInterface
|
|||
|
||||
if ($jsonBackingType) {
|
||||
if (isset($paramSchema['type']) && \is_array($paramSchema['type']) && \in_array('null', $paramSchema['type'])) {
|
||||
$paramSchema['type'] = ['null', $jsonBackingType];
|
||||
$paramSchema['type'] = [$jsonBackingType, 'null'];
|
||||
$paramSchema['enum'][] = null;
|
||||
} else {
|
||||
$paramSchema['type'] = $jsonBackingType;
|
||||
}
|
||||
|
|
@ -383,7 +384,8 @@ final class SchemaGenerator implements SchemaGeneratorInterface
|
|||
// Non-backed enum - use names as enum values
|
||||
$paramSchema['enum'] = array_column($enumClass::cases(), 'name');
|
||||
if (isset($paramSchema['type']) && \is_array($paramSchema['type']) && \in_array('null', $paramSchema['type'])) {
|
||||
$paramSchema['type'] = ['null', 'string'];
|
||||
$paramSchema['type'] = ['string', 'null'];
|
||||
$paramSchema['enum'][] = null;
|
||||
} else {
|
||||
$paramSchema['type'] = 'string';
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue