Skip to content

Commit

Permalink
fix: Use extra single value enum where const is used due to lack of s…
Browse files Browse the repository at this point in the history
…upport from jsonschema2pojo

Signed-off-by: Vinícius Moraes Lopes <[email protected]>
  • Loading branch information
uasouz committed Aug 23, 2024
1 parent 51f4a3e commit d316319
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
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

0 comments on commit d316319

Please sign in to comment.