diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2023-09-19 21:49:19 -0100 |
---|---|---|
committer | Maxence Lange <maxence@artificial-owl.com> | 2023-09-20 08:23:45 -0100 |
commit | b5dcd048ae85cfe8d7fb22663f1955efbdca7921 (patch) | |
tree | 0aba878eec4ee9222e4de538f229be908535cd3c /core | |
parent | c6c06d517cfe80f1a75c7eff2b66fb9cefea86d9 (diff) | |
download | nextcloud-server-b5dcd048ae85cfe8d7fb22663f1955efbdca7921.tar.gz nextcloud-server-b5dcd048ae85cfe8d7fb22663f1955efbdca7921.zip |
small fixes
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'core')
-rw-r--r-- | core/Controller/OCMController.php | 16 | ||||
-rw-r--r-- | core/openapi.json | 110 |
2 files changed, 121 insertions, 5 deletions
diff --git a/core/Controller/OCMController.php b/core/Controller/OCMController.php index 421803439b0..8d08da1f8e4 100644 --- a/core/Controller/OCMController.php +++ b/core/Controller/OCMController.php @@ -29,9 +29,8 @@ namespace OC\Core\Controller; use Exception; use OCP\AppFramework\Controller; use OCP\AppFramework\Http; -use OCP\AppFramework\Http\Attribute\IgnoreOpenAPI; use OCP\AppFramework\Http\DataResponse; -use OCP\AppFramework\Http\Response; +use OCP\Capabilities\ICapability; use OCP\IConfig; use OCP\IRequest; use OCP\Server; @@ -58,11 +57,14 @@ class OCMController extends Controller { * * @PublicPage * @NoCSRFRequired + * @psalm-suppress MoreSpecificReturnType + * @psalm-suppress LessSpecificReturnStatement + * @return DataResponse<Http::STATUS_OK, array{enabled: bool, apiVersion: string, endPoint: string, resourceTypes: array{array{name: string, shareTypes: string[], protocols: array{webdav: string}}}}, array{X-NEXTCLOUD-OCM-PROVIDERS: true, Content-Type: 'application/json'}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, array{message: string}, array{}> * - * @return Response + * 200: OCM Provider details returned + * 500: OCM not supported */ - #[IgnoreOpenAPI] - public function discovery(): Response { + public function discovery(): DataResponse { try { $cap = Server::get( $this->config->getAppValue( @@ -72,6 +74,10 @@ class OCMController extends Controller { ) ); + if (!($cap instanceof ICapability)) { + throw new Exception('loaded class does not implements OCP\Capabilities\ICapability'); + } + return new DataResponse( $cap->getCapabilities()['ocm'] ?? ['enabled' => false], Http::STATUS_OK, diff --git a/core/openapi.json b/core/openapi.json index 3a67a076988..95fc7c2ff9f 100644 --- a/core/openapi.json +++ b/core/openapi.json @@ -1289,6 +1289,116 @@ } } }, + "/index.php/ocm-provider": { + "get": { + "operationId": "ocm-discovery", + "summary": "generate a OCMProvider with local data and send it as DataResponse. This replaces the old PHP file ocm-provider/index.php", + "tags": [ + "ocm" + ], + "security": [ + {}, + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "responses": { + "200": { + "description": "OCM Provider details returned", + "headers": { + "X-NEXTCLOUD-OCM-PROVIDERS": { + "schema": { + "type": "boolean" + } + } + }, + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "enabled", + "apiVersion", + "endPoint", + "resourceTypes" + ], + "properties": { + "enabled": { + "type": "boolean" + }, + "apiVersion": { + "type": "string" + }, + "endPoint": { + "type": "string" + }, + "resourceTypes": { + "type": "object", + "required": [ + null + ], + "properties": { + "": { + "type": "object", + "required": [ + "name", + "shareTypes", + "protocols" + ], + "properties": { + "name": { + "type": "string" + }, + "shareTypes": { + "type": "array", + "items": { + "type": "string" + } + }, + "protocols": { + "type": "object", + "required": [ + "webdav" + ], + "properties": { + "webdav": { + "type": "string" + } + } + } + } + } + } + } + } + } + } + } + }, + "500": { + "description": "OCM not supported", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "message" + ], + "properties": { + "message": { + "type": "string" + } + } + } + } + } + } + } + } + }, "/ocs/v2.php/cloud/capabilities": { "get": { "operationId": "ocs-get-capabilities", |