Skip to content

Commit d26420b

Browse files
committed
fix: also add support for integer backed enums
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
1 parent 8417b0d commit d26420b

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/EnumResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ private function load(string $fqcn): ?OpenApiType {
7676

7777
return new OpenApiType(
7878
context: $path,
79-
type: $node->scalarType->name === 'int' ? 'integer' : 'string',
80-
format: $node->scalarType->name === 'int' ? 'int64' : null,
79+
type: $node->scalarType->name === 'int' || $node->scalarType->name === 'integer' ? 'integer' : 'string',
80+
format: $node->scalarType->name === 'int' || $node->scalarType->name === 'integer' ? 'int64' : null,
8181
description: $description,
8282
enum: $values,
8383
);

tests/lib/Notification/NotificationPriority.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Declared in a sub-namespace/sub-directory to confirm that enums are resolved
1616
* by mapping their namespace to a file path instead of relying on a directory scan.
1717
*/
18-
enum NotificationPriority: int {
18+
enum NotificationPriority: integer {
1919
case Low = 0;
2020
case Normal = 1;
2121
case High = 2;

0 commit comments

Comments
 (0)