diff --git a/api/src/main/resources/schema/workflow.yaml b/api/src/main/resources/schema/workflow.yaml index 86e33868..bba84e95 100644 --- a/api/src/main/resources/schema/workflow.yaml +++ b/api/src/main/resources/schema/workflow.yaml @@ -202,6 +202,7 @@ $defs: call: type: string const: asyncapi + enum: [asyncapi] with: type: object title: AsyncApiArguments @@ -247,6 +248,7 @@ $defs: call: type: string const: grpc + enum: [grpc] with: type: object title: GRPCArguments @@ -301,7 +303,8 @@ $defs: properties: call: type: string - const: http + const: http + enum: [http] with: type: object title: HTTPArguments @@ -350,6 +353,7 @@ $defs: call: type: string const: openapi + enum: [openapi] with: type: object title: OpenAPIArguments @@ -1351,4 +1355,4 @@ $defs: type: string title: RuntimeExpression description: A runtime expression. - pattern: "^\\s*\\$\\{.+\\}\\s*$" \ No newline at end of file + pattern: "^\\s*\\$\\{.+\\}\\s*$" diff --git a/api/src/test/java/io/serverlessworkflow/api/ApiTest.java b/api/src/test/java/io/serverlessworkflow/api/ApiTest.java index ac5f7532..0a32173d 100644 --- a/api/src/test/java/io/serverlessworkflow/api/ApiTest.java +++ b/api/src/test/java/io/serverlessworkflow/api/ApiTest.java @@ -18,6 +18,7 @@ import static io.serverlessworkflow.api.WorkflowReader.readWorkflowFromClasspath; import static org.assertj.core.api.Assertions.assertThat; +import io.serverlessworkflow.api.types.CallFunction; import io.serverlessworkflow.api.types.CallHTTP; import io.serverlessworkflow.api.types.CallTask; import io.serverlessworkflow.api.types.Task; @@ -27,6 +28,24 @@ public class ApiTest { + @Test + void testCallFunctionAPIWithoutArguments() throws IOException { + Workflow workflow = readWorkflowFromClasspath("features/callFunction.yaml"); + assertThat(workflow.getDo()).isNotEmpty(); + assertThat(workflow.getDo().get(0).getName()).isNotNull(); + assertThat(workflow.getDo().get(0).getTask()).isNotNull(); + Task task = workflow.getDo().get(0).getTask(); + CallTask callTask = task.getCallTask(); + assertThat(callTask).isNotNull(); + assertThat(callTask.get()).isInstanceOf(CallFunction.class); + if (callTask.get() instanceof CallFunction) { + CallFunction functionCall = callTask.getCallFunction(); + assertThat(functionCall).isNotNull(); + assertThat(callTask.getCallAsyncAPI()).isNull(); + assertThat(functionCall.getWith()).isNull(); + } + } + @Test void testCallHTTPAPI() throws IOException { Workflow workflow = readWorkflowFromClasspath("features/callHttp.yaml"); diff --git a/api/src/test/resources/features/callFunction.yaml b/api/src/test/resources/features/callFunction.yaml new file mode 100644 index 00000000..695ad25c --- /dev/null +++ b/api/src/test/resources/features/callFunction.yaml @@ -0,0 +1,18 @@ +document: + dsl: 1.0.0-alpha1 + namespace: default + name: http-call-with-response-output + +use: + functions: + getPet: + call: http + with: + method: get + endpoint: + uri: https://petstore.swagger.io/v2/pet/{petId} + output: response + +do: + - getPetFunctionCall: + call: getPet