aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_external
diff options
context:
space:
mode:
authorJulien Veyssier <julien-nc@posteo.net>2023-08-07 12:10:19 +0200
committerGitHub <noreply@github.com>2023-08-07 12:10:19 +0200
commit787caefc9a58cf9cd105454b6b5a2d8046509878 (patch)
tree29cc7969ae0a7b991047403c6d4553cd5f1717e2 /apps/files_external
parentbfe42de8f878985c75c6f0bb868b905fe293d8da (diff)
parenta7808f0115ca2f3c10f839c2967fea105030bd11 (diff)
downloadnextcloud-server-787caefc9a58cf9cd105454b6b5a2d8046509878.tar.gz
nextcloud-server-787caefc9a58cf9cd105454b6b5a2d8046509878.zip
Merge pull request #39717 from nextcloud/fix/openapi/files_external
files_external: Fix OpenAPI
Diffstat (limited to 'apps/files_external')
-rw-r--r--apps/files_external/lib/Controller/ApiController.php4
-rw-r--r--apps/files_external/lib/Lib/StorageConfig.php10
-rw-r--r--apps/files_external/lib/ResponseDefinitions.php18
-rw-r--r--apps/files_external/openapi.json77
4 files changed, 103 insertions, 6 deletions
diff --git a/apps/files_external/lib/Controller/ApiController.php b/apps/files_external/lib/Controller/ApiController.php
index 1276dde91c6..fbab967e786 100644
--- a/apps/files_external/lib/Controller/ApiController.php
+++ b/apps/files_external/lib/Controller/ApiController.php
@@ -34,6 +34,7 @@ use OCA\Files_External\ResponseDefinitions;
use OCA\Files_External\Service\UserGlobalStoragesService;
use OCA\Files_External\Service\UserStoragesService;
use OCP\AppFramework\Http;
+use OCP\AppFramework\Http\Attribute\IgnoreOpenAPI;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCSController;
use OCP\IRequest;
@@ -127,6 +128,7 @@ class ApiController extends OCSController {
* Ask for credentials using a browser's native basic auth prompt
* Then returns it if provided
*/
+ #[IgnoreOpenAPI]
public function askNativeAuth(): DataResponse {
if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])) {
$response = new DataResponse([], Http::STATUS_UNAUTHORIZED);
@@ -137,7 +139,7 @@ class ApiController extends OCSController {
$user = $_SERVER['PHP_AUTH_USER'];
$password = $_SERVER['PHP_AUTH_PW'];
- // Reset auth
+ // Reset auth
unset($_SERVER['PHP_AUTH_USER']);
unset($_SERVER['PHP_AUTH_PW']);
diff --git a/apps/files_external/lib/Lib/StorageConfig.php b/apps/files_external/lib/Lib/StorageConfig.php
index 8cb59f70892..25205a24321 100644
--- a/apps/files_external/lib/Lib/StorageConfig.php
+++ b/apps/files_external/lib/Lib/StorageConfig.php
@@ -31,9 +31,12 @@ namespace OCA\Files_External\Lib;
use OCA\Files_External\Lib\Auth\AuthMechanism;
use OCA\Files_External\Lib\Auth\IUserProvided;
use OCA\Files_External\Lib\Backend\Backend;
+use OCA\Files_External\ResponseDefinitions;
/**
* External storage configuration
+ *
+ * @psalm-import-type FilesExternalStorageConfig from ResponseDefinitions
*/
class StorageConfig implements \JsonSerializable {
public const MOUNT_TYPE_ADMIN = 1;
@@ -63,7 +66,7 @@ class StorageConfig implements \JsonSerializable {
/**
* Backend options
*
- * @var array
+ * @var array<string, mixed>
*/
private $backendOptions = [];
@@ -112,7 +115,7 @@ class StorageConfig implements \JsonSerializable {
/**
* Mount-specific options
*
- * @var array
+ * @var array<string, mixed>
*/
private $mountOptions = [];
@@ -396,6 +399,7 @@ class StorageConfig implements \JsonSerializable {
/**
* Serialize config to JSON
+ * @return FilesExternalStorageConfig
*/
public function jsonSerialize(bool $obfuscate = false): array {
$result = [];
@@ -407,7 +411,7 @@ class StorageConfig implements \JsonSerializable {
if ($obfuscate) {
$this->formatStorageForUI();
}
-
+
$result['mountPoint'] = $this->mountPoint;
$result['backend'] = $this->backend->getIdentifier();
$result['authMechanism'] = $this->authMechanism->getIdentifier();
diff --git a/apps/files_external/lib/ResponseDefinitions.php b/apps/files_external/lib/ResponseDefinitions.php
index bae29085361..cb501ed1bce 100644
--- a/apps/files_external/lib/ResponseDefinitions.php
+++ b/apps/files_external/lib/ResponseDefinitions.php
@@ -26,6 +26,22 @@ declare(strict_types=1);
namespace OCA\Files_External;
/**
+ * @psalm-type FilesExternalStorageConfig = array{
+ * applicableGroups?: string[],
+ * applicableUsers?: string[],
+ * authMechanism: string,
+ * backend: string,
+ * backendOptions: array<string, mixed>,
+ * id?: int,
+ * mountOptions?: array<string, mixed>,
+ * mountPoint: string,
+ * priority?: int,
+ * status?: int,
+ * statusMessage?: string,
+ * type: 'personal'|'system',
+ * userProvided: bool,
+ * }
+ *
* @psalm-type FilesExternalMount = array{
* name: string,
* path: string,
@@ -35,7 +51,7 @@ namespace OCA\Files_External;
* permissions: int,
* id: int,
* class: string,
- * config: array<array-key, mixed>,
+ * config: FilesExternalStorageConfig,
* }
*/
class ResponseDefinitions {
diff --git a/apps/files_external/openapi.json b/apps/files_external/openapi.json
index a95ab67697a..f6ab4bc2a80 100644
--- a/apps/files_external/openapi.json
+++ b/apps/files_external/openapi.json
@@ -30,7 +30,8 @@
"scope",
"permissions",
"id",
- "class"
+ "class",
+ "config"
],
"properties": {
"name": {
@@ -65,6 +66,9 @@
},
"class": {
"type": "string"
+ },
+ "config": {
+ "$ref": "#/components/schemas/StorageConfig"
}
}
},
@@ -91,6 +95,77 @@
"type": "string"
}
}
+ },
+ "StorageConfig": {
+ "type": "object",
+ "required": [
+ "authMechanism",
+ "backend",
+ "backendOptions",
+ "mountPoint",
+ "type",
+ "userProvided"
+ ],
+ "properties": {
+ "applicableGroups": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "applicableUsers": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "authMechanism": {
+ "type": "string"
+ },
+ "backend": {
+ "type": "string"
+ },
+ "backendOptions": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "object"
+ }
+ },
+ "id": {
+ "type": "integer",
+ "format": "int64"
+ },
+ "mountOptions": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "object"
+ }
+ },
+ "mountPoint": {
+ "type": "string"
+ },
+ "priority": {
+ "type": "integer",
+ "format": "int64"
+ },
+ "status": {
+ "type": "integer",
+ "format": "int64"
+ },
+ "statusMessage": {
+ "type": "string"
+ },
+ "type": {
+ "type": "string",
+ "enum": [
+ "personal",
+ "system"
+ ]
+ },
+ "userProvided": {
+ "type": "boolean"
+ }
+ }
}
}
},