From 36cf891b7fa22bffca8ae29d334a435dfed87330 Mon Sep 17 00:00:00 2001 From: Christopher Ng Date: Wed, 7 Aug 2024 20:52:29 -0700 Subject: feat(files): Update openapi Signed-off-by: Christopher Ng --- apps/files/lib/Controller/ApiController.php | 7 +- apps/files/lib/ResponseDefinitions.php | 9 ++- apps/files/openapi.json | 105 ++++++++++++++++++++++------ 3 files changed, 93 insertions(+), 28 deletions(-) (limited to 'apps') diff --git a/apps/files/lib/Controller/ApiController.php b/apps/files/lib/Controller/ApiController.php index 44e88c443e4..62ae4e6b0f0 100644 --- a/apps/files/lib/Controller/ApiController.php +++ b/apps/files/lib/Controller/ApiController.php @@ -261,10 +261,15 @@ class ApiController extends Controller { /** * Returns the folder tree of the user * - * @return JSONResponse|JSONResponse + * @param string $path The path relative to the user folder + * @param int $depth The depth of the tree + * + * @return JSONResponse|JSONResponse * * 200: Folder tree returned successfully + * 400: Invalid folder path * 401: Unauthorized + * 404: Folder not found */ #[NoAdminRequired] #[ApiRoute(verb: 'GET', url: '/api/v1/folder-tree')] diff --git a/apps/files/lib/ResponseDefinitions.php b/apps/files/lib/ResponseDefinitions.php index 79f7544fdac..a05cbb75b21 100644 --- a/apps/files/lib/ResponseDefinitions.php +++ b/apps/files/lib/ResponseDefinitions.php @@ -39,13 +39,12 @@ namespace OCA\Files; * type: string, * } * - * @psalm-type FilesFolderTreeNode = array{ + * @psalm-type FilesFolderTree = list, - * } - * - * @psalm-type FilesFolderTree = array + * children: list, + * }> * */ class ResponseDefinitions { diff --git a/apps/files/openapi.json b/apps/files/openapi.json index c9da18b0cd1..97c95cc29c0 100644 --- a/apps/files/openapi.json +++ b/apps/files/openapi.json @@ -100,28 +100,30 @@ } }, "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" + "type": "array", + "items": { + "type": "object", + "required": [ + "id", + "basename", + "children" + ], + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "basename": { + "type": "string" + }, + "displayName": { + "type": "string" + }, + "children": { + "type": "array", + "items": { + "type": "object" + } } } } @@ -1971,6 +1973,29 @@ "basic_auth": [] } ], + "requestBody": { + "required": false, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "path": { + "type": "string", + "default": "/", + "description": "The path relative to the user folder" + }, + "depth": { + "type": "integer", + "format": "int64", + "default": 1, + "description": "The depth of the tree" + } + } + } + } + } + }, "parameters": [ { "name": "OCS-APIRequest", @@ -2011,6 +2036,42 @@ } } } + }, + "400": { + "description": "Invalid folder path", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "message" + ], + "properties": { + "message": { + "type": "string" + } + } + } + } + } + }, + "404": { + "description": "Folder not found", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "message" + ], + "properties": { + "message": { + "type": "string" + } + } + } + } + } } } } -- cgit v1.2.3