aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Veyssier <julien-nc@posteo.net>2025-01-09 11:12:22 +0100
committerGitHub <noreply@github.com>2025-01-09 11:12:22 +0100
commitd3ec3deab46707b095d64ce95df415b86de94c88 (patch)
treede5fd5ac7d124b1daacce01e1ee0ef35e8f22f28
parent4a3fceaf89b3a51185e7e1a23d0857a1a4b2d9c0 (diff)
parent7bf74f9d97296aeb1113fad2c6e0f18055d59e2a (diff)
downloadnextcloud-server-d3ec3deab46707b095d64ce95df415b86de94c88.tar.gz
nextcloud-server-d3ec3deab46707b095d64ce95df415b86de94c88.zip
Merge pull request #50094 from nextcloud/fix/noid/broken-taskprocessing-api
Fix broken taskprocessing api /tasktypes endpoint
-rw-r--r--core/Controller/TaskProcessingApiController.php80
-rw-r--r--core/ResponseDefinitions.php16
-rw-r--r--core/openapi-full.json32
-rw-r--r--core/openapi.json32
4 files changed, 100 insertions, 60 deletions
diff --git a/core/Controller/TaskProcessingApiController.php b/core/Controller/TaskProcessingApiController.php
index 925d4751383..2f5a81ea7a8 100644
--- a/core/Controller/TaskProcessingApiController.php
+++ b/core/Controller/TaskProcessingApiController.php
@@ -39,6 +39,7 @@ use OCP\TaskProcessing\IManager;
use OCP\TaskProcessing\ShapeEnumValue;
use OCP\TaskProcessing\Task;
use RuntimeException;
+use stdClass;
/**
* @psalm-import-type CoreTaskProcessingTask from ResponseDefinitions
@@ -67,31 +68,70 @@ class TaskProcessingApiController extends \OCP\AppFramework\OCSController {
#[PublicPage]
#[ApiRoute(verb: 'GET', url: '/tasktypes', root: '/taskprocessing')]
public function taskTypes(): DataResponse {
+ /** @var array<string, CoreTaskProcessingTaskType> $taskTypes */
$taskTypes = array_map(function (array $tt) {
- $tt['inputShape'] = array_values(array_map(function ($descriptor) {
+ $tt['inputShape'] = array_map(function ($descriptor) {
return $descriptor->jsonSerialize();
- }, $tt['inputShape']));
- $tt['outputShape'] = array_values(array_map(function ($descriptor) {
+ }, $tt['inputShape']);
+ if (empty($tt['inputShape'])) {
+ $tt['inputShape'] = new stdClass;
+ }
+
+ $tt['outputShape'] = array_map(function ($descriptor) {
return $descriptor->jsonSerialize();
- }, $tt['outputShape']));
- $tt['optionalInputShape'] = array_values(array_map(function ($descriptor) {
+ }, $tt['outputShape']);
+ if (empty($tt['outputShape'])) {
+ $tt['outputShape'] = new stdClass;
+ }
+
+ $tt['optionalInputShape'] = array_map(function ($descriptor) {
return $descriptor->jsonSerialize();
- }, $tt['optionalInputShape']));
- $tt['optionalOutputShape'] = array_values(array_map(function ($descriptor) {
+ }, $tt['optionalInputShape']);
+ if (empty($tt['optionalInputShape'])) {
+ $tt['optionalInputShape'] = new stdClass;
+ }
+
+ $tt['optionalOutputShape'] = array_map(function ($descriptor) {
return $descriptor->jsonSerialize();
- }, $tt['optionalOutputShape']));
- $tt['inputShapeEnumValues'] = array_values(array_map(function (array $enumValues) {
- return array_values(array_map(fn (ShapeEnumValue $enumValue) => $enumValue->jsonSerialize(), $enumValues));
- }, $tt['inputShapeEnumValues']));
- $tt['optionalInputShapeEnumValues'] = array_values(array_map(function (array $enumValues) {
- return array_values(array_map(fn (ShapeEnumValue $enumValue) => $enumValue->jsonSerialize(), $enumValues));
- }, $tt['optionalInputShapeEnumValues']));
- $tt['outputShapeEnumValues'] = array_values(array_map(function (array $enumValues) {
- return array_values(array_map(fn (ShapeEnumValue $enumValue) => $enumValue->jsonSerialize(), $enumValues));
- }, $tt['outputShapeEnumValues']));
- $tt['optionalOutputShapeEnumValues'] = array_values(array_map(function (array $enumValues) {
- return array_values(array_map(fn (ShapeEnumValue $enumValue) => $enumValue->jsonSerialize(), $enumValues));
- }, $tt['optionalOutputShapeEnumValues']));
+ }, $tt['optionalOutputShape']);
+ if (empty($tt['optionalOutputShape'])) {
+ $tt['optionalOutputShape'] = new stdClass;
+ }
+
+ $tt['inputShapeEnumValues'] = array_map(function (array $enumValues) {
+ return array_map(fn (ShapeEnumValue $enumValue) => $enumValue->jsonSerialize(), $enumValues);
+ }, $tt['inputShapeEnumValues']);
+ if (empty($tt['inputShapeEnumValues'])) {
+ $tt['inputShapeEnumValues'] = new stdClass;
+ }
+
+ $tt['optionalInputShapeEnumValues'] = array_map(function (array $enumValues) {
+ return array_map(fn (ShapeEnumValue $enumValue) => $enumValue->jsonSerialize(), $enumValues);
+ }, $tt['optionalInputShapeEnumValues']);
+ if (empty($tt['optionalInputShapeEnumValues'])) {
+ $tt['optionalInputShapeEnumValues'] = new stdClass;
+ }
+
+ $tt['outputShapeEnumValues'] = array_map(function (array $enumValues) {
+ return array_map(fn (ShapeEnumValue $enumValue) => $enumValue->jsonSerialize(), $enumValues);
+ }, $tt['outputShapeEnumValues']);
+ if (empty($tt['outputShapeEnumValues'])) {
+ $tt['outputShapeEnumValues'] = new stdClass;
+ }
+
+ $tt['optionalOutputShapeEnumValues'] = array_map(function (array $enumValues) {
+ return array_map(fn (ShapeEnumValue $enumValue) => $enumValue->jsonSerialize(), $enumValues);
+ }, $tt['optionalOutputShapeEnumValues']);
+ if (empty($tt['optionalOutputShapeEnumValues'])) {
+ $tt['optionalOutputShapeEnumValues'] = new stdClass;
+ }
+
+ if (empty($tt['inputShapeDefaults'])) {
+ $tt['inputShapeDefaults'] = new stdClass;
+ }
+ if (empty($tt['optionalInputShapeDefaults'])) {
+ $tt['optionalInputShapeDefaults'] = new stdClass;
+ }
return $tt;
}, $this->taskProcessingManager->getAvailableTaskTypes());
return new DataResponse([
diff --git a/core/ResponseDefinitions.php b/core/ResponseDefinitions.php
index 7dfd3b7da9b..3b344e6af99 100644
--- a/core/ResponseDefinitions.php
+++ b/core/ResponseDefinitions.php
@@ -171,16 +171,16 @@ namespace OC\Core;
* @psalm-type CoreTaskProcessingTaskType = array{
* name: string,
* description: string,
- * inputShape: list<CoreTaskProcessingShape>,
- * inputShapeEnumValues: list<list<array{name: string, value: string}>>,
+ * inputShape: array<string, CoreTaskProcessingShape>,
+ * inputShapeEnumValues: array<string, list<array{name: string, value: string}>>,
* inputShapeDefaults: array<string, numeric|string>,
- * optionalInputShape: list<CoreTaskProcessingShape>,
- * optionalInputShapeEnumValues: list<list<array{name: string, value: string}>>,
+ * optionalInputShape: array<string, CoreTaskProcessingShape>,
+ * optionalInputShapeEnumValues: array<string, list<array{name: string, value: string}>>,
* optionalInputShapeDefaults: array<string, numeric|string>,
- * outputShape: list<CoreTaskProcessingShape>,
- * outputShapeEnumValues: list<list<array{name: string, value: string}>>,
- * optionalOutputShape: list<CoreTaskProcessingShape>,
- * optionalOutputShapeEnumValues: list<list<array{name: string, value: string}>>,
+ * outputShape: array<string, CoreTaskProcessingShape>,
+ * outputShapeEnumValues: array<string, list<array{name: string, value: string}>>,
+ * optionalOutputShape: array<string, CoreTaskProcessingShape>,
+ * optionalOutputShapeEnumValues: array<string, list<array{name: string, value: string}>>,
* }
*
* @psalm-type CoreTaskProcessingIO = array<string, numeric|list<numeric>|string|list<string>>
diff --git a/core/openapi-full.json b/core/openapi-full.json
index d6f9837b1c6..4762cf0c141 100644
--- a/core/openapi-full.json
+++ b/core/openapi-full.json
@@ -635,14 +635,14 @@
"type": "string"
},
"inputShape": {
- "type": "array",
- "items": {
+ "type": "object",
+ "additionalProperties": {
"$ref": "#/components/schemas/TaskProcessingShape"
}
},
"inputShapeEnumValues": {
- "type": "array",
- "items": {
+ "type": "object",
+ "additionalProperties": {
"type": "array",
"items": {
"type": "object",
@@ -675,14 +675,14 @@
}
},
"optionalInputShape": {
- "type": "array",
- "items": {
+ "type": "object",
+ "additionalProperties": {
"$ref": "#/components/schemas/TaskProcessingShape"
}
},
"optionalInputShapeEnumValues": {
- "type": "array",
- "items": {
+ "type": "object",
+ "additionalProperties": {
"type": "array",
"items": {
"type": "object",
@@ -715,14 +715,14 @@
}
},
"outputShape": {
- "type": "array",
- "items": {
+ "type": "object",
+ "additionalProperties": {
"$ref": "#/components/schemas/TaskProcessingShape"
}
},
"outputShapeEnumValues": {
- "type": "array",
- "items": {
+ "type": "object",
+ "additionalProperties": {
"type": "array",
"items": {
"type": "object",
@@ -742,14 +742,14 @@
}
},
"optionalOutputShape": {
- "type": "array",
- "items": {
+ "type": "object",
+ "additionalProperties": {
"$ref": "#/components/schemas/TaskProcessingShape"
}
},
"optionalOutputShapeEnumValues": {
- "type": "array",
- "items": {
+ "type": "object",
+ "additionalProperties": {
"type": "array",
"items": {
"type": "object",
diff --git a/core/openapi.json b/core/openapi.json
index bf8f2478fbd..def317d722a 100644
--- a/core/openapi.json
+++ b/core/openapi.json
@@ -635,14 +635,14 @@
"type": "string"
},
"inputShape": {
- "type": "array",
- "items": {
+ "type": "object",
+ "additionalProperties": {
"$ref": "#/components/schemas/TaskProcessingShape"
}
},
"inputShapeEnumValues": {
- "type": "array",
- "items": {
+ "type": "object",
+ "additionalProperties": {
"type": "array",
"items": {
"type": "object",
@@ -675,14 +675,14 @@
}
},
"optionalInputShape": {
- "type": "array",
- "items": {
+ "type": "object",
+ "additionalProperties": {
"$ref": "#/components/schemas/TaskProcessingShape"
}
},
"optionalInputShapeEnumValues": {
- "type": "array",
- "items": {
+ "type": "object",
+ "additionalProperties": {
"type": "array",
"items": {
"type": "object",
@@ -715,14 +715,14 @@
}
},
"outputShape": {
- "type": "array",
- "items": {
+ "type": "object",
+ "additionalProperties": {
"$ref": "#/components/schemas/TaskProcessingShape"
}
},
"outputShapeEnumValues": {
- "type": "array",
- "items": {
+ "type": "object",
+ "additionalProperties": {
"type": "array",
"items": {
"type": "object",
@@ -742,14 +742,14 @@
}
},
"optionalOutputShape": {
- "type": "array",
- "items": {
+ "type": "object",
+ "additionalProperties": {
"$ref": "#/components/schemas/TaskProcessingShape"
}
},
"optionalOutputShapeEnumValues": {
- "type": "array",
- "items": {
+ "type": "object",
+ "additionalProperties": {
"type": "array",
"items": {
"type": "object",