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

[Fix #712] Describe merge behaviour for non object #832

Merged
merged 4 commits into from
May 15, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion specification.md
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ The second way would be to directly filter only the "veggie like" vegetables wit
| fromStateData | Workflow expression that filters state data that can be used by the action | string | no |
| 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 |
| results | Workflow expression that filters the actions data results | string | no |
| 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 |
| 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. In case it is not specified and the result of the action is not an object, that result should be merged as value of `response` key. If that `response` key already exist in the model, its value will be overwritten. | string | no |
fjtirado marked this conversation as resolved.
Show resolved Hide resolved
ricardozanini marked this conversation as resolved.
Show resolved Hide resolved

<details><summary><strong>Click to view example definition</strong></summary>
<p>
Expand Down Expand Up @@ -565,6 +565,27 @@ into. With this, after our action executes the state data would be:
}
```

To illustrate merge of not json both object, let`s assume that, in previous example, the action definition is at follows
fjtirado marked this conversation as resolved.
Show resolved Hide resolved

```json
"actions":[
{
"name": "fetch_only_pasta",
fjtirado marked this conversation as resolved.
Show resolved Hide resolved
"functionRef": "breadAndPastaTypesFunction",
"actionDataFilter": {
"results": "${ .pasta[1] ]",
}
}
]
}
fjtirado marked this conversation as resolved.
Show resolved Hide resolved
```
Since there is not `toStateData` and the result is not a json object but an string, the state would be

```json
{
"response": "spaghetti"
}
```
In the case action results should not be added/merged to state data, we can set the `useResults` property to `false`.
In this case, the `results` and `toStateData` properties should be ignored, and nothing is added/merged to state data.
If `useResults` is not specified (or it's value set to `true`), action results, if available, should be added/merged to state data.
Expand Down
Loading