From ec94a672d72720530ffcfce92f9695d8b9a09e27 Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Wed, 8 May 2024 09:20:25 +0200 Subject: [PATCH] fix(ocs): change /tasktypes response to combine optional and non-optional IO slots Signed-off-by: Marcel Klehr --- .../TaskProcessingApiController.php | 12 ++++++---- core/ResponseDefinitions.php | 5 ++--- core/openapi.json | 22 +++++-------------- 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/core/Controller/TaskProcessingApiController.php b/core/Controller/TaskProcessingApiController.php index 9e0d7947a3a..6c06d17cef0 100644 --- a/core/Controller/TaskProcessingApiController.php +++ b/core/Controller/TaskProcessingApiController.php @@ -83,10 +83,14 @@ class TaskProcessingApiController extends \OCP\AppFramework\OCSController { $serializedTaskTypes[$key] = [ 'name' => $taskType['name'], 'description' => $taskType['description'], - 'inputShape' => array_map(fn (ShapeDescriptor $descriptor) => $descriptor->jsonSerialize(), $taskType['inputShape']), - 'optionalInputShape' => array_map(fn (ShapeDescriptor $descriptor) => $descriptor->jsonSerialize(), $taskType['optionalInputShape']), - 'outputShape' => array_map(fn (ShapeDescriptor $descriptor) => $descriptor->jsonSerialize(), $taskType['outputShape']), - 'optionalOutputShape' => array_map(fn (ShapeDescriptor $descriptor) => $descriptor->jsonSerialize(), $taskType['optionalOutputShape']), + 'inputShape' => array_map(fn (ShapeDescriptor $descriptor) => + $descriptor->jsonSerialize() + ['mandatory' => true], $taskType['inputShape']) + + array_map(fn (ShapeDescriptor $descriptor) => + $descriptor->jsonSerialize() + ['mandatory' => false], $taskType['optionalInputShape']), + 'outputShape' => array_map(fn (ShapeDescriptor $descriptor) => + $descriptor->jsonSerialize() + ['mandatory' => true], $taskType['outputShape']) + + array_map(fn (ShapeDescriptor $descriptor) => + $descriptor->jsonSerialize() + ['mandatory' => false], $taskType['optionalOutputShape']), ]; } diff --git a/core/ResponseDefinitions.php b/core/ResponseDefinitions.php index bd6879796be..98227d22edb 100644 --- a/core/ResponseDefinitions.php +++ b/core/ResponseDefinitions.php @@ -180,16 +180,15 @@ namespace OCA\Core; * @psalm-type CoreTaskProcessingShape = array{ * name: string, * description: string, - * type: int + * type: int, + * mandatory: bool, * } * * @psalm-type CoreTaskProcessingTaskType = array{ * name: string, * description: string, * inputShape: CoreTaskProcessingShape[], - * optionalInputShape: CoreTaskProcessingShape[], * outputShape: CoreTaskProcessingShape[], - * optionalOutputShape: CoreTaskProcessingShape[], * } * * @psalm-type CoreTaskProcessingTask = array{ diff --git a/core/openapi.json b/core/openapi.json index eeb366f3031..3a98e1c1ff2 100644 --- a/core/openapi.json +++ b/core/openapi.json @@ -471,7 +471,8 @@ "required": [ "name", "description", - "type" + "type", + "mandatory" ], "properties": { "name": { @@ -483,6 +484,9 @@ "type": { "type": "integer", "format": "int64" + }, + "mandatory": { + "type": "boolean" } } }, @@ -599,9 +603,7 @@ "name", "description", "inputShape", - "optionalInputShape", - "outputShape", - "optionalOutputShape" + "outputShape" ], "properties": { "name": { @@ -616,23 +618,11 @@ "$ref": "#/components/schemas/TaskProcessingShape" } }, - "optionalInputShape": { - "type": "array", - "items": { - "$ref": "#/components/schemas/TaskProcessingShape" - } - }, "outputShape": { "type": "array", "items": { "$ref": "#/components/schemas/TaskProcessingShape" } - }, - "optionalOutputShape": { - "type": "array", - "items": { - "$ref": "#/components/schemas/TaskProcessingShape" - } } } },