diff --git a/src/OpenApiType.php b/src/OpenApiType.php index 4362673..dbb7e54 100644 --- a/src/OpenApiType.php +++ b/src/OpenApiType.php @@ -397,6 +397,14 @@ enum: [(int)$node->constExpr->value], ); } + if ($node instanceof GenericTypeNode && $node->type->name === 'class-string') { + return new OpenApiType( + context: $context, + type: 'string', + minLength: 1, + ); + } + if ($node instanceof ConstTypeNode) { Logger::panic($context, 'Constants are not supported'); } diff --git a/tests/lib/ResponseDefinitions.php b/tests/lib/ResponseDefinitions.php index 150fd54..126f319 100644 --- a/tests/lib/ResponseDefinitions.php +++ b/tests/lib/ResponseDefinitions.php @@ -9,12 +9,15 @@ namespace OCA\Notifications; +use OCA\Notifications\Controller\AdminSettingsController; + /** * @psalm-type NotificationsItem = array{ * label: string, * link: string, * type: string, * primary: bool, + * class: class-string, * } * * @psalm-type NotificationsCollection = list diff --git a/tests/openapi-full.json b/tests/openapi-full.json index ff0935d..8552f7c 100644 --- a/tests/openapi-full.json +++ b/tests/openapi-full.json @@ -52,7 +52,8 @@ "label", "link", "type", - "primary" + "primary", + "class" ], "properties": { "label": { @@ -66,6 +67,10 @@ }, "primary": { "type": "boolean" + }, + "class": { + "type": "string", + "minLength": 1 } } }, diff --git a/tests/openapi.json b/tests/openapi.json index 1c5bb6e..8a3b651 100644 --- a/tests/openapi.json +++ b/tests/openapi.json @@ -52,7 +52,8 @@ "label", "link", "type", - "primary" + "primary", + "class" ], "properties": { "label": { @@ -66,6 +67,10 @@ }, "primary": { "type": "boolean" + }, + "class": { + "type": "string", + "minLength": 1 } } },