Skip to content
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

Make serialized workflow compatible with schema #224

Merged

Conversation

fjtirado
Copy link
Collaborator

Before the PR, the file resulting of executing this code

Workflow workflow = new Workflow("HelloWorld", "Hello World", "1.0", Arrays.asList(
             new InjectState(START_STATE, Type.INJECT).withData(new ObjectMapper().createObjectNode().put("response","Hello World!!!")).withEnd(new End())))
             .withStart(new Start().withStateName(START_STATE));
try (Writer writer = new FileWriter("helloworld.json")) {
        new JsonObjectMapper().writeValue(writer, workflow);
        } catch (IOException io) {
            throw new UncheckedIOException(io);
        }

was


{
  "id" : "HelloWorld",
  "name" : "HelloWorld",
  "version" : "1_0",
  "start" : "inject_0",
  "expressionLang" : "jq",
  "events" : [ ],
  "functions" : [ ],
  "retries" : [ ],
  "errors" : [ ],
  "secrets" : [ ],
  "states" : [ {
    "data" : {
      "response" : "Hello World!!!"
    },
    "usedForCompensation" : false,
    "name" : "inject_0",
    "type" : "inject",
    "end" : true,
    "onErrors" : [ ]
  } ]
}

which is not compatible with json schema (becasuse, for example, events, functions, retries, errores, secrets should be not present or has at least 1 element)

After the change, the result is

{
  "id" : "HelloWorld",
  "name" : "HelloWorld",
  "version" : "1_0",
  "start" : "inject_0",
  "expressionLang" : "jq",
  "states" : [ {
    "data" : {
      "response" : "Hello World!!!"
    },
    "usedForCompensation" : false,
    "name" : "inject_0",
    "type" : "inject",
    "end" : true
  } ]
}

which is schema compatible

@fjtirado fjtirado requested a review from tsurdilo as a code owner March 31, 2023 16:06
Signed-off-by: Francisco Javier Tirado Sarti <[email protected]>
@fjtirado fjtirado force-pushed the serializer_compatible_with_schema branch from 506a82b to 00049ef Compare March 31, 2023 16:07
@fjtirado
Copy link
Collaborator Author

@ricardozanini Can we please take a look to this quick (and so needed for editor) fix?

@tsurdilo tsurdilo merged commit 5dc0378 into serverlessworkflow:main May 25, 2023
ricardozanini pushed a commit to ricardozanini/sdk-java that referenced this pull request Jul 4, 2023
ricardozanini pushed a commit to ricardozanini/sdk-java that referenced this pull request Jul 4, 2023
Signed-off-by: Francisco Javier Tirado Sarti <[email protected]>
Signed-off-by: Ricardo Zanini <[email protected]>
tsurdilo pushed a commit that referenced this pull request Jul 4, 2023
Signed-off-by: Francisco Javier Tirado Sarti <[email protected]>
Signed-off-by: Ricardo Zanini <[email protected]>
Co-authored-by: Francisco Javier Tirado Sarti <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants