Skip to content

Commit 33772ba

Browse files
authored
Merge pull request #832 from fjtirado/Fix_#712
[Fix #712] Describe merge behaviour for non object
2 parents b3422f4 + 049b4e8 commit 33772ba

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

specification.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ The second way would be to directly filter only the "veggie like" vegetables wit
438438
| fromStateData | Workflow expression that filters state data that can be used by the action | string | no |
439439
| useResults | If set to `false`, action data results are not added/merged to state data. In this case 'results' and 'toStateData' should be ignored. Default is `true`. | boolean | no |
440440
| results | Workflow expression that filters the actions data results | string | no |
441-
| toStateData | Workflow expression that selects a state data element to which the action results should be added/merged into. If not specified denotes the top-level state data element | string | no |
441+
| toStateData | Workflow expression that selects a state data element to which the action results should be added/merged. If not specified denotes the top-level state data element. In case it is not specified and the result of the action is not an object, that result should be merged as the value of an automatically generated key. That key name will be the result of concatenating the action name with `-output` suffix. | string | no |
442442

443443
<details><summary><strong>Click to view example definition</strong></summary>
444444
<p>
@@ -564,6 +564,26 @@ into. With this, after our action executes the state data would be:
564564
}
565565
```
566566

567+
To illustrate the merge of non-JSON for both objects, let's assume that, in the previous example, the action definition is the follows
568+
569+
```json
570+
"actions":[
571+
{
572+
"name": "fetch-only-pasta",
573+
"functionRef": "breadAndPastaTypesFunction",
574+
"actionDataFilter": {
575+
"results": "${ .pasta[1] ]",
576+
}
577+
}
578+
]
579+
```
580+
Since there is no `toStateData` attribute and the result is not a JSON object but a string, the model would be:
581+
582+
```json
583+
{
584+
"fetch-only-pasta-output": "spaghetti"
585+
}
586+
```
567587
In the case action results should not be added/merged to state data, we can set the `useResults` property to `false`.
568588
In this case, the `results` and `toStateData` properties should be ignored, and nothing is added/merged to state data.
569589
If `useResults` is not specified (or it's value set to `true`), action results, if available, should be added/merged to state data.

0 commit comments

Comments
 (0)