From 04a3b99b3d3ae91b1f8af73debe5934800e94de9 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 8 Nov 2023 16:51:01 +0100 Subject: [PATCH] Move admin-only routes to administration scope when default only Signed-off-by: Joas Schilling --- generate-spec | 4 ++ tests/openapi-administration.json | 72 +++++++++++++++++++++++++++++++ tests/openapi.json | 72 ------------------------------- 3 files changed, 76 insertions(+), 72 deletions(-) diff --git a/generate-spec b/generate-spec index df3e7b6..49df7fb 100755 --- a/generate-spec +++ b/generate-spec @@ -351,6 +351,10 @@ foreach ($parsedRoutes as $key => $value) { } } + if ($scopes === ['default'] && $isAdmin) { + $scopes = ['administration']; + } + if ($isOCS && !array_key_exists("OCSMeta", $schemas)) { $schemas["OCSMeta"] = [ "type" => "object", diff --git a/tests/openapi-administration.json b/tests/openapi-administration.json index 65f90fb..eff288f 100644 --- a/tests/openapi-administration.json +++ b/tests/openapi-administration.json @@ -66,6 +66,78 @@ } }, "paths": { + "/ocs/v2.php/apps/notifications/api/{apiVersion}/default-admin": { + "post": { + "operationId": "settings-default-admin-scope", + "summary": "Route is only in the admin scope because there is no \"NoAdminRequired\" annotation or attribute", + "description": "This endpoint requires admin access", + "tags": [ + "settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "name": "apiVersion", + "in": "path", + "required": true, + "schema": { + "type": "string", + "enum": [ + "v2" + ], + "default": "v2" + } + }, + { + "name": "OCS-APIRequest", + "in": "header", + "description": "Required to be true for the API request to pass", + "required": true, + "schema": { + "type": "boolean", + "default": true + } + } + ], + "responses": { + "200": { + "description": "Personal settings updated", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": {} + } + } + } + } + } + } + } + } + } + }, "/ocs/v2.php/apps/notifications/api/{apiVersion}/admin": { "post": { "operationId": "settings-admin-scope", diff --git a/tests/openapi.json b/tests/openapi.json index c349739..72f2e75 100644 --- a/tests/openapi.json +++ b/tests/openapi.json @@ -118,78 +118,6 @@ } } }, - "/ocs/v2.php/apps/notifications/api/{apiVersion}/default-admin": { - "post": { - "operationId": "settings-default-admin-scope", - "summary": "Route is only in the admin scope because there is no \"NoAdminRequired\" annotation or attribute", - "description": "This endpoint requires admin access", - "tags": [ - "settings" - ], - "security": [ - { - "bearer_auth": [] - }, - { - "basic_auth": [] - } - ], - "parameters": [ - { - "name": "apiVersion", - "in": "path", - "required": true, - "schema": { - "type": "string", - "enum": [ - "v2" - ], - "default": "v2" - } - }, - { - "name": "OCS-APIRequest", - "in": "header", - "description": "Required to be true for the API request to pass", - "required": true, - "schema": { - "type": "boolean", - "default": true - } - } - ], - "responses": { - "200": { - "description": "Personal settings updated", - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "ocs" - ], - "properties": { - "ocs": { - "type": "object", - "required": [ - "meta", - "data" - ], - "properties": { - "meta": { - "$ref": "#/components/schemas/OCSMeta" - }, - "data": {} - } - } - } - } - } - } - } - } - } - }, "/ocs/v2.php/apps/notifications/api/{apiVersion}/double": { "post": { "operationId": "settings-double-scope",