diff options
author | Christopher Ng <chrng8@gmail.com> | 2024-07-31 14:53:25 -0700 |
---|---|---|
committer | Christopher Ng <chrng8@gmail.com> | 2024-08-01 09:17:56 -0700 |
commit | 012e2687ab9f4307b299dc1018794d1f22e93574 (patch) | |
tree | 7573ec7f3bd2f9202c7325655aa4f8967cb9f43b /apps | |
parent | 8f27cd6d5d4b09b4e976889d648ee7160785bf00 (diff) | |
download | nextcloud-server-012e2687ab9f4307b299dc1018794d1f22e93574.tar.gz nextcloud-server-012e2687ab9f4307b299dc1018794d1f22e93574.zip |
feat(files): Update openapi spec
Signed-off-by: Christopher Ng <chrng8@gmail.com>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files/lib/Controller/ApiController.php | 10 | ||||
-rw-r--r-- | apps/files/lib/ResponseDefinitions.php | 9 | ||||
-rw-r--r-- | apps/files/openapi.json | 86 |
3 files changed, 104 insertions, 1 deletions
diff --git a/apps/files/lib/Controller/ApiController.php b/apps/files/lib/Controller/ApiController.php index e5b9086995e..0d4503682b0 100644 --- a/apps/files/lib/Controller/ApiController.php +++ b/apps/files/lib/Controller/ApiController.php @@ -11,6 +11,7 @@ use OC\AppFramework\Middleware\Security\Exceptions\NotLoggedInException; use OC\Files\Node\Node; use OC\Files\Search\SearchComparison; use OC\Files\Search\SearchQuery; +use OCA\Files\ResponseDefinitions; use OCA\Files\Service\TagService; use OCA\Files\Service\UserConfig; use OCA\Files\Service\ViewConfig; @@ -46,6 +47,8 @@ use Psr\Log\LoggerInterface; use Throwable; /** + * @psalm-import-type FilesFolderTree from ResponseDefinitions + * * @package OCA\Files\Controller */ class ApiController extends Controller { @@ -265,7 +268,12 @@ class ApiController extends Controller { } /** - * Returns a folder tree for the user. + * Returns the folder tree of the user + * + * @return JSONResponse<Http::STATUS_OK, FilesFolderTree, array{}>|JSONResponse<Http::STATUS_UNAUTHORIZED, array{message: string}, array{}> + * + * 200: Folder tree returned successfully + * 401: Unauthorized */ #[NoAdminRequired] #[ApiRoute(verb: 'GET', url: '/api/v1/folder-tree')] diff --git a/apps/files/lib/ResponseDefinitions.php b/apps/files/lib/ResponseDefinitions.php index 50893af7b11..79f7544fdac 100644 --- a/apps/files/lib/ResponseDefinitions.php +++ b/apps/files/lib/ResponseDefinitions.php @@ -38,6 +38,15 @@ namespace OCA\Files; * content: string, * type: string, * } + * + * @psalm-type FilesFolderTreeNode = array{ + * id: int, + * displayName?: string, + * children?: array<string, array{}>, + * } + * + * @psalm-type FilesFolderTree = array<string, FilesFolderTreeNode> + * */ class ResponseDefinitions { } diff --git a/apps/files/openapi.json b/apps/files/openapi.json index e93c4d2807a..c9da18b0cd1 100644 --- a/apps/files/openapi.json +++ b/apps/files/openapi.json @@ -99,6 +99,33 @@ } } }, + "FolderTree": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/FolderTreeNode" + } + }, + "FolderTreeNode": { + "type": "object", + "required": [ + "id" + ], + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "displayName": { + "type": "string" + }, + "children": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + }, "OCSMeta": { "type": "object", "required": [ @@ -1928,6 +1955,65 @@ } } } + }, + "/ocs/v2.php/apps/files/api/v1/folder-tree": { + "get": { + "operationId": "api-get-folder-tree", + "summary": "Returns the folder tree of the user", + "tags": [ + "api" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "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": "Folder tree returned successfully", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FolderTree" + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "message" + ], + "properties": { + "message": { + "type": "string" + } + } + } + } + } + } + } + } } }, "tags": [] |