Skip to content

Commit 5cf206b

Browse files
authored
Merge pull request #173 from tsurdilo/annotations40x
[4.0.x] Adding support for annotations prop
2 parents 423f01e + 8daef86 commit 5cf206b

File tree

5 files changed

+40
-0
lines changed

5 files changed

+40
-0
lines changed

api/src/main/java/io/serverlessworkflow/api/serializers/WorkflowSerializer.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ public void serialize(Workflow workflow, JsonGenerator gen, SerializerProvider p
6363
gen.writeStringField("version", workflow.getVersion());
6464
}
6565

66+
if (workflow.getAnnotations() != null && !workflow.getAnnotations().isEmpty()) {
67+
gen.writeObjectField("annotations", workflow.getAnnotations());
68+
}
69+
6670
if (workflow.getDataInputSchema() != null) {
6771
if (workflow.getDataInputSchema().getSchema() != null
6872
&& workflow.getDataInputSchema().getSchema().length() > 0

api/src/main/resources/schema/workflow.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@
2727
"type": "string",
2828
"description": "Workflow version"
2929
},
30+
"annotations": {
31+
"type": "array",
32+
"description": "List of helpful terms describing the workflows intended purpose, subject areas, or other important qualities",
33+
"minItems": 1,
34+
"items": {
35+
"type": "string"
36+
}
37+
},
3038
"dataInputSchema": {
3139
"$ref": "datainputschema/datainputschema.json",
3240
"description": "Workflow data input schema"

api/src/test/java/io/serverlessworkflow/api/test/MarkupToWorkflowTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,4 +838,18 @@ public void testFunctionInvoke(String workflowLocation) {
838838
assertNotNull(action3.getEventRef().getInvoke());
839839
assertEquals(EventRef.Invoke.ASYNC, action3.getEventRef().getInvoke());
840840
}
841+
842+
@ParameterizedTest
843+
@ValueSource(strings = {"/features/annotations.json", "/features/annotations.yml"})
844+
public void testAnnotations(String workflowLocation) {
845+
Workflow workflow = Workflow.fromSource(WorkflowTestUtils.readWorkflowFile(workflowLocation));
846+
847+
assertNotNull(workflow);
848+
assertNotNull(workflow.getId());
849+
assertNotNull(workflow.getName());
850+
851+
assertNotNull(workflow.getAnnotations());
852+
List<String> annotations = workflow.getAnnotations();
853+
assertEquals(4, annotations.size());
854+
}
841855
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"id" : "test-workflow",
3+
"name" : "test-workflow-name",
4+
"version" : "1.0",
5+
"annotations": ["a", "b", "c", "d"]
6+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
id: test-workflow
2+
name: test-workflow-name
3+
version: '1.0'
4+
annotations:
5+
- a
6+
- b
7+
- c
8+
- d

0 commit comments

Comments
 (0)