Skip to content

Commit

Permalink
Move admin-only routes to administration scope when default only
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Nov 8, 2023
1 parent 52198a2 commit 04a3b99
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 72 deletions.
4 changes: 4 additions & 0 deletions generate-spec
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
72 changes: 72 additions & 0 deletions tests/openapi-administration.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
72 changes: 0 additions & 72 deletions tests/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 04a3b99

Please sign in to comment.