diff --git a/lib/Controller/FolderController.php b/lib/Controller/FolderController.php index 1344f08c0..0293a2019 100644 --- a/lib/Controller/FolderController.php +++ b/lib/Controller/FolderController.php @@ -90,7 +90,7 @@ private function formatFolder(array $folder): array { * Gets all Groupfolders * * @param bool $applicable Filter by applicable groups - * @return DataResponse, array{}> + * @return DataResponse, array{}> * @throws OCSNotFoundException Storage not found * * 200: Groupfolders returned @@ -103,8 +103,11 @@ public function getFolders(bool $applicable = false): DataResponse { throw new OCSNotFoundException(); } - $folders = array_values($this->manager->getAllFoldersWithSize($storageId)); - $folders = array_map($this->formatFolder(...), $folders); + $folders = []; + foreach ($this->manager->getAllFoldersWithSize($storageId) as $id => $folder) { + // Make them string-indexed for OpenAPI JSON output + $folders[(string)$id] = $this->formatFolder($folder); + } $isAdmin = $this->delegationService->isAdminNextcloud() || $this->delegationService->isDelegatedAdmin(); if ($isAdmin && !$applicable) { return new DataResponse($folders); @@ -115,7 +118,7 @@ public function getFolders(bool $applicable = false): DataResponse { } if ($applicable || !$this->delegationService->hasApiAccess()) { - $folders = array_values(array_filter(array_map($this->filterNonAdminFolder(...), $folders))); + $folders = array_filter(array_map($this->filterNonAdminFolder(...), $folders)); } return new DataResponse($folders); diff --git a/lib/Service/FoldersFilter.php b/lib/Service/FoldersFilter.php index dcb6fb0d6..2f3af74d2 100644 --- a/lib/Service/FoldersFilter.php +++ b/lib/Service/FoldersFilter.php @@ -22,8 +22,8 @@ public function __construct( } /** - * @param list $folders List of all folders - * @return list + * @param GroupFoldersFolder[] $folders List of all folders + * @return GroupFoldersFolder[] */ public function getForApiUser(array $folders): array { $user = $this->userSession->getUser(); diff --git a/openapi.json b/openapi.json index 7233e88aa..42f11ea0c 100644 --- a/openapi.json +++ b/openapi.json @@ -389,8 +389,8 @@ "content": { "application/json": { "schema": { - "type": "array", - "items": { + "type": "object", + "additionalProperties": { "$ref": "#/components/schemas/Folder" } } diff --git a/src/types/openapi/openapi.ts b/src/types/openapi/openapi.ts index 1fff7ad55..4420830e5 100644 --- a/src/types/openapi/openapi.ts +++ b/src/types/openapi/openapi.ts @@ -400,7 +400,9 @@ export interface operations { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["Folder"][]; + "application/json": { + [key: string]: components["schemas"]["Folder"]; + }; }; }; /** @description Storage not found */