diff --git a/lib/Controller/FolderController.php b/lib/Controller/FolderController.php index 2182a0bea..ec82dd7e4 100644 --- a/lib/Controller/FolderController.php +++ b/lib/Controller/FolderController.php @@ -100,7 +100,7 @@ private function formatFolder(array $folder): array { * Gets all Groupfolders * @NoAdminRequired * @param bool $applicable Filter by applicable groups - * @return DataResponse, array{}> + * @return DataResponse, array{}> * @throws OCSNotFoundException Storage not found * * 200: Groupfolders returned @@ -111,8 +111,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); @@ -121,7 +124,7 @@ public function getFolders(bool $applicable = false): DataResponse { $folders = $this->foldersFilter->getForApiUser($folders); } 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 99df216c3..d13c52133 100644 --- a/lib/Service/FoldersFilter.php +++ b/lib/Service/FoldersFilter.php @@ -24,8 +24,8 @@ public function __construct(IUserSession $userSession, IGroupManager $groupManag } /** - * @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 ab42e83b4..bd7ec2fe1 100644 --- a/openapi.json +++ b/openapi.json @@ -248,8 +248,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 eab4ebb6a..daa2a5bc1 100644 --- a/src/types/openapi/openapi.ts +++ b/src/types/openapi/openapi.ts @@ -328,7 +328,9 @@ export interface operations { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["Folder"][]; + "application/json": { + [key: string]: components["schemas"]["Folder"]; + }; }; }; /** @description Storage not found */