Skip to content

Add single value enum when using const keyword for compatiblity #413

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions api/src/main/resources/schema/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ $defs:
call:
type: string
const: asyncapi
enum: [asyncapi]
with:
type: object
title: AsyncApiArguments
Expand Down Expand Up @@ -247,6 +248,7 @@ $defs:
call:
type: string
const: grpc
enum: [grpc]
with:
type: object
title: GRPCArguments
Expand Down Expand Up @@ -301,7 +303,8 @@ $defs:
properties:
call:
type: string
const: http
const: http
enum: [http]
with:
type: object
title: HTTPArguments
Expand Down Expand Up @@ -350,6 +353,7 @@ $defs:
call:
type: string
const: openapi
enum: [openapi]
with:
type: object
title: OpenAPIArguments
Expand Down Expand Up @@ -1351,4 +1355,4 @@ $defs:
type: string
title: RuntimeExpression
description: A runtime expression.
pattern: "^\\s*\\$\\{.+\\}\\s*$"
pattern: "^\\s*\\$\\{.+\\}\\s*$"
19 changes: 19 additions & 0 deletions api/src/test/java/io/serverlessworkflow/api/ApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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");
Expand Down
18 changes: 18 additions & 0 deletions api/src/test/resources/features/callFunction.yaml
Original file line number Diff line number Diff line change
@@ -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
Loading