Skip to content

Commit bb7a0d8

Browse files
refactor: only make do an array
Signed-off-by: Matthias Pichler <m.pichler@warrify.com>
1 parent 74fd0c8 commit bb7a0d8

File tree

4 files changed

+54
-69
lines changed

4 files changed

+54
-69
lines changed

dsl-reference.md

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ Allows workflows to iterate over a collection of items, executing a defined set
542542
| for.in | `string` | `yes` | A [runtime expression](#runtime-expressions) used to get the collection to enumerate. |
543543
| for.at | `string` | `no` | The name of the variable used to store the index of the current item being enumerated.<br>Defaults to `index`. |
544544
| while | `string` | `no` | A [runtime expression](#runtime-expressions) that represents the condition, if any, that must be met for the iteration to continue. |
545-
| do | [`task[]`](#task) | `yes` | The task(s) to perform for each item in the collection. |
545+
| do | [`task`](#task) | `yes` | The task to perform for each item in the collection. |
546546

547547
##### Examples
548548

@@ -560,12 +560,12 @@ do:
560560
at: index
561561
while: .vet != null
562562
do:
563-
- name: checkForFleas
564-
listen:
565-
to:
566-
one:
567-
with:
568-
type: com.fake.petclinic.pets.checkup.completed.v2
563+
name: checkForFleas
564+
listen:
565+
to:
566+
one:
567+
with:
568+
type: com.fake.petclinic.pets.checkup.completed.v2
569569
output:
570570
to: '.pets + [{ "id": $pet.id }]'
571571
```
@@ -911,7 +911,7 @@ Serves as a mechanism within workflows to handle errors gracefully, potentially
911911

912912
| Name | Type | Required | Description|
913913
|:--|:---:|:---:|:---|
914-
| try | [`task[]`](#task) | `yes` | The task(s) to perform. |
914+
| try | [`task`](#task) | `yes` | The task(s) to perform. |
915915
| catch | [`catch`](#catch) | `yes` | Configures the errors to catch and how to handle them. |
916916

917917
##### Examples
@@ -925,10 +925,10 @@ document:
925925
do:
926926
- name: processOrder
927927
try:
928-
- call: http
929-
with:
930-
method: get
931-
uri: https://
928+
call: http
929+
with:
930+
method: get
931+
uri: https://
932932
catch:
933933
errors:
934934
with:
@@ -958,7 +958,7 @@ Defines the configuration of a catch clause, which a concept used to catch error
958958
| when | `string`| `no` | A runtime expression used to determine whether or not to catch the filtered error |
959959
| exceptWhen | `string` | `no` | A runtime expression used to determine whether or not to catch the filtered error |
960960
| retry | [`retryPolicy`](#retry) | `no` | The retry policy to use, if any, when catching errors |
961-
| do | [`task[]`](#task) | `no` | The definition of the task(s) to run when catching an error |
961+
| do | [`task`](#task) | `no` | The definition of the task to run when catching an error |
962962

963963
#### Wait
964964

@@ -1195,8 +1195,8 @@ Extensions enable the execution of tasks prior to those they extend, offering th
11951195
|----------|:----:|:--------:|-------------|
11961196
| extend | `string` | `yes` | The type of task to extend<br>Supported values are: `call`, `composite`, `emit`, `extension`, `for`, `listen`, `raise`, `run`, `set`, `switch`, `try`, `wait` and `all` |
11971197
| when | `string` | `no` | A runtime expression used to determine whether or not the extension should apply in the specified context |
1198-
| before | [`task[]`](#task) | `no` | The task(s) to execute, if any, before the extended task |
1199-
| after | [`task[]`](#task) | `no` | The task(s) to execute, if any, after the extended task |
1198+
| before | [`task`](#task) | `no` | The task to execute, if any, before the extended task |
1199+
| after | [`task`](#task) | `no` | The task to execute, if any, after the extended task |
12001200

12011201
#### Examples
12021202

@@ -1212,19 +1212,19 @@ use:
12121212
- name: logging
12131213
extend: all
12141214
before:
1215-
- call: http
1216-
with:
1217-
method: post
1218-
uri: https://fake.log.collector.com
1219-
body:
1220-
message: "${ \"Executing task '\($task.reference)'...\" }"
1215+
call: http
1216+
with:
1217+
method: post
1218+
uri: https://fake.log.collector.com
1219+
body:
1220+
message: "${ \"Executing task '\($task.reference)'...\" }"
12211221
after:
1222-
- call: http
1223-
with:
1224-
method: post
1225-
uri: https://fake.log.collector.com
1226-
body:
1227-
message: "${ \"Executed task '\($task.reference)'...\" }"
1222+
call: http
1223+
with:
1224+
method: post
1225+
uri: https://fake.log.collector.com
1226+
body:
1227+
message: "${ \"Executed task '\($task.reference)'...\" }"
12281228
do:
12291229
- name: get
12301230
call: http
@@ -1246,14 +1246,14 @@ use:
12461246
extend: http
12471247
when: ($task.with.uri != null and ($task.with.uri | startswith("https://mocked.service.com"))) or ($task.with.endpoint.uri != null and ($task.with.endpoint.uri | startswith("https://mocked.service.com")))
12481248
before:
1249-
- set:
1250-
statusCode: 200
1251-
headers:
1252-
Content-Type: application/json
1253-
content:
1254-
foo:
1255-
bar: baz
1256-
then: exit #using this, we indicate to the workflow we want to exit the extended task, thus just returning what we injected
1249+
set:
1250+
statusCode: 200
1251+
headers:
1252+
Content-Type: application/json
1253+
content:
1254+
foo:
1255+
bar: baz
1256+
then: exit #using this, we indicate to the workflow we want to exit the extended task, thus just returning what we injected
12571257
do:
12581258
- name: get
12591259
call: http

examples/accumulate-room-readings.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ do:
3030
each: reading
3131
in: .readings
3232
do:
33-
- call: openapi
34-
with:
35-
document:
36-
uri: http://myorg.io/ordersservices.json
37-
operationId: logreading
33+
call: openapi
34+
with:
35+
document:
36+
uri: http://myorg.io/ordersservices.json
37+
operationId: logreading
3838
- name: generateReport
3939
call: openapi
4040
with:

examples/mock-service-extension.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ use:
99
extend: call
1010
when: ($task.with.endpoint != null and ($task.with.endpoint | startswith("https://mocked.service.com"))) or ($task.with.endpoint.uri != null and ($task.with.endpoint.uri | startswith("https://mocked.service.com")))
1111
before:
12-
- set:
13-
statusCode: 200
14-
headers:
15-
Content-Type: application/json
16-
content:
17-
foo:
18-
bar: baz
19-
then: exit #using this, we indicate to the workflow we want to exit the extended task, thus just returning what we injected
12+
set:
13+
statusCode: 200
14+
headers:
15+
Content-Type: application/json
16+
content:
17+
foo:
18+
bar: baz
19+
then: exit #using this, we indicate to the workflow we want to exit the extended task, thus just returning what we injected
2020
do:
2121
- name: get
2222
call: http

schema/workflow.yaml

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -355,10 +355,7 @@ $defs:
355355
type: string
356356
description: A runtime expression that represents the condition, if any, that must be met for the iteration to continue.
357357
do:
358-
type: array
359-
minItems: 1
360-
items:
361-
$ref: '#/$defs/task'
358+
$ref: '#/$defs/task'
362359
description: Allows workflows to iterate over a collection of items, executing a defined set of subtasks for each item in the collection. This task type is instrumental in handling scenarios such as batch processing, data transformation, and repetitive operations across datasets.
363360
required: [ for, do ]
364361
listenTask:
@@ -513,11 +510,8 @@ $defs:
513510
type: object
514511
properties:
515512
try:
516-
description: The tasks to perform.
517-
type: array
518-
minItems: 1
519-
items:
520-
- $ref: '#/$defs/task'
513+
description: The task to perform.
514+
$ref: '#/$defs/task'
521515
catch:
522516
type: object
523517
properties:
@@ -537,10 +531,7 @@ $defs:
537531
description: The retry policy to use, if any, when catching errors.
538532
do:
539533
description: The definition of the task to run when catching an error.
540-
type: array
541-
minItems: 1
542-
items:
543-
$ref: '#/$defs/task'
534+
$ref: '#/$defs/task'
544535
required: [ try, catch ]
545536
description: Serves as a mechanism within workflows to handle errors gracefully, potentially retrying failed tasks before proceeding with alternate ones.
546537
waitTask:
@@ -765,16 +756,10 @@ $defs:
765756
description: A runtime expression, if any, used to determine whether or not the extension should apply in the specified context.
766757
before:
767758
description: The task to execute before the extended task, if any.
768-
type: array
769-
minItems: 1
770-
items:
771-
$ref: '#/$defs/task'
759+
$ref: '#/$defs/task'
772760
after:
773761
description: The task to execute after the extended task, if any.
774-
type: array
775-
minItems: 1
776-
items:
777-
$ref: '#/$defs/task'
762+
$ref: '#/$defs/task'
778763
required: [ extend ]
779764
description: The definition of a an extension.
780765
externalResource:

0 commit comments

Comments
 (0)