diff --git a/generate-spec.php b/generate-spec.php index b31728d..c1d4b0c 100755 --- a/generate-spec.php +++ b/generate-spec.php @@ -463,18 +463,11 @@ Logger::panic($routeName, 'Route is marked as ignore but also has other scopes'); } - if (in_array('ignore', $scopes, true)) { - if (count($scopes) === 1) { - Logger::debug($routeName, 'Route ignored because of OpenAPI attribute'); - continue; - } - - Logger::panic($routeName, 'Route is marked as ignore but also has other scopes'); - } - if ($scopes === []) { if ($controllerScopes !== []) { $scopes = $controllerScopes; + } elseif (!$isOCS) { + $scopes = ['ignore']; } elseif ($isExApp) { $scopes = ['ex_app']; } elseif ($isAdmin) { @@ -484,6 +477,15 @@ } } + if (in_array('ignore', $scopes, true)) { + if (count($scopes) === 1) { + Logger::debug($routeName, 'Route ignored because of OpenAPI attribute'); + continue; + } + + Logger::panic($routeName, 'Route is marked as ignore but also has other scopes'); + } + $routeTags = Helpers::getOpenAPIAttributeTagsByScope($classMethod, $routeName, $tagName, reset($scopes)); if ($isOCS && !array_key_exists('OCSMeta', $schemas)) { diff --git a/tests/lib/Controller/PlainController.php b/tests/lib/Controller/PlainController.php new file mode 100644 index 0000000..e5c5ba9 --- /dev/null +++ b/tests/lib/Controller/PlainController.php @@ -0,0 +1,40 @@ + + * + * 200: Response returned + */ + #[NoCSRFRequired] + #[OpenAPI(scope: OpenAPI::SCOPE_DEFAULT)] + #[FrontpageRoute(verb: 'GET', url: '/plain/with-scope')] + public function withScope(): Response { + return new Response(); + } +} diff --git a/tests/openapi-full.json b/tests/openapi-full.json index 14c533e..2519a54 100644 --- a/tests/openapi-full.json +++ b/tests/openapi-full.json @@ -5485,6 +5485,29 @@ } } }, + "/index.php/apps/notifications/plain/with-scope": { + "get": { + "operationId": "plain-with-scope", + "summary": "Route with manual scope to not get ignored", + "description": "This endpoint requires admin access", + "tags": [ + "plain" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "responses": { + "200": { + "description": "Response returned" + } + } + } + }, "/ocs/v2.php/apps/notifications/api/{apiVersion}/ex-app-attribute": { "post": { "operationId": "ex_app_settings-ex-app-scope-attribute", diff --git a/tests/openapi.json b/tests/openapi.json index 57520b8..6173bb9 100644 --- a/tests/openapi.json +++ b/tests/openapi.json @@ -797,6 +797,29 @@ } } } + }, + "/index.php/apps/notifications/plain/with-scope": { + "get": { + "operationId": "plain-with-scope", + "summary": "Route with manual scope to not get ignored", + "description": "This endpoint requires admin access", + "tags": [ + "plain" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "responses": { + "200": { + "description": "Response returned" + } + } + } } }, "tags": []