Skip to content

Commit 2b2b7bc

Browse files
committed
fix(filter): use correct type for int-backed enums in BackedEnumFilter
| Q | A | ------------- | --- | Branch? | 4.2 | Tickets | ∅ | License | MIT | Doc PR | ∅ The OpenAPI schema hardcoded 'string' type regardless of the enum backing type, causing typed-enum linter warnings for int-backed enums.
1 parent 6a472a2 commit 2b2b7bc

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/Doctrine/Common/Filter/BackedEnumFilterTrait.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,15 @@ public function getDescription(string $resourceClass): array
6060
$isCollection = str_ends_with($filterParameterName, '[]');
6161

6262
$enumValues = array_map(static fn (\BackedEnum $case) => $case->value, $this->enumTypes[$property]::cases());
63+
$enumType = \is_int($enumValues[0] ?? null) ? 'integer' : 'string';
6364

6465
$schema = $isCollection
65-
? ['type' => 'array', 'items' => ['type' => 'string', 'enum' => $enumValues]]
66-
: ['type' => 'string', 'enum' => $enumValues];
66+
? ['type' => 'array', 'items' => ['type' => $enumType, 'enum' => $enumValues]]
67+
: ['type' => $enumType, 'enum' => $enumValues];
6768

6869
$description[$filterParameterName] = [
6970
'property' => $propertyName,
70-
'type' => 'string',
71+
'type' => $enumType,
7172
'required' => false,
7273
'is_collection' => $isCollection,
7374
'schema' => $schema,

0 commit comments

Comments
 (0)