-
Notifications
You must be signed in to change notification settings - Fork 217
fix: pass workflow inputs to success and failure actions #2796
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
Open
harshit078
wants to merge
34
commits into
Redocly:main
Choose a base branch
from
harshit078:pass-workflow-input-to-actions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
5649bbd
feat: add parameters field to Success and Failure in arrazo
harshit078 7646ee8
Merge branch 'main' into pass-workflow-input-to-actions
harshit078 c46b071
feat: added spec parameters for arrazo rules in config
harshit078 613e9a3
feat: added specs parameters logic and test with changeset
harshit078 6b7e963
Merge branch 'main' into pass-workflow-input-to-actions
harshit078 a41e2aa
Merge branch 'main' into pass-workflow-input-to-actions
harshit078 e057bd1
fix: address comments and added docs
harshit078 f218352
Merge branch 'main' into pass-workflow-input-to-actions
harshit078 28c0ac1
fix: failing markdownlint failing test
harshit078 c3223dc
fix: markdownlint failing test
harshit078 f3ffcdd
fix: address comments and updated changset and used paramters interface
harshit078 db9eb6b
fix: added spec parameter test
harshit078 83a27cb
fix: minor lint fix
harshit078 ffd8f5a
Merge branch 'main' into pass-workflow-input-to-actions
harshit078 a0470a4
fix: address comment and fix verbiage
harshit078 ba3b600
Merge branch 'main' into pass-workflow-input-to-actions
harshit078 667cf82
feat: added actionParameters in replacement of parameters
harshit078 af9e4be
feat: added actionParameters for workflow actions
harshit078 8b47027
fix: updated tests
harshit078 d0fc683
feat: added mapParametersToWorkflowInputs function in run step for be…
harshit078 50a990e
feat: added mapParametersToWorkflowInput tests
harshit078 f7deff3
fix: address cursor comments
harshit078 03b6896
fix: address comments and fix linting errors
harshit078 c095135
Merge branch 'main' into pass-workflow-input-to-actions
harshit078 1ff644f
fix: linting errors
harshit078 b12d4c7
fix: failing build test
harshit078 a58b507
fix: failing lint test
harshit078 41b8546
fix: failing lint test
harshit078 ce4f733
fix: remove x-allowedReserved from actionParameter
harshit078 a14a54b
fix: updated changesets
harshit078 a1443a6
fix: updated validation for in field in parameters
harshit078 e1820da
Merge branch 'main' into pass-workflow-input-to-actions
harshit078 64f339e
fix: updated tests for in field now
harshit078 ae9e4c7
fix: failing e2e tests and added snapshots
harshit078 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| '@redocly/openapi-core': minor | ||
| '@redocly/cli': minor | ||
| --- | ||
|
|
||
| Added the `spec-parameters-in-by-context` Arazzo rule, which validates that a parameter's `in` field is specified when the parent workflow, step, success action, or failure action does not reference a `workflowId`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| '@redocly/openapi-core': minor | ||
| '@redocly/respect-core': minor | ||
| '@redocly/cli': minor | ||
| --- | ||
|
|
||
| Extended success and failure action objects to accept a `parameters` property that maps to workflow inputs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| # spec-parameters-in-by-context | ||
|
|
||
| Validates how the `in` field is used on parameters based on the parent context. | ||
|
|
||
| | Arazzo | Compatibility | | ||
| | ------ | ------------- | | ||
| | 1.x | ✅ | | ||
|
|
||
| ## Design principles | ||
|
|
||
| The `in` field on an Arazzo parameter is not a required property — omitting it carries semantics. | ||
| When a step references a `workflowId`, a parameter with no `in` field is mapped to the referenced workflow's inputs. | ||
| When `in` is specified, the parameter is sent at that request location (`header`, `query`, `path`, or `cookie`) against the targeted operation. | ||
|
|
||
| This rule enforces the following: | ||
|
|
||
| - For a step that does not reference a `workflowId` (for example, one using `operationId`, `operationPath`, or `x-operation`), and for parameters defined at the workflow level, `in` must be specified on each inline parameter. | ||
| - Parameters on success and failure actions are only valid when the action references a `workflowId` — these parameters map to the referenced workflow's inputs and the spec states that `in` MUST NOT be used on them (see the [Success Action Object](https://spec.openapis.org/arazzo/latest.html#success-action-object) and [Failure Action Object](https://spec.openapis.org/arazzo/latest.html#failure-action-object)). | ||
|
|
||
| ## Configuration | ||
|
|
||
| | Option | Type | Description | | ||
| | -------- | ------ | ------------------------------------------------------- | | ||
| | severity | string | Possible values: `off`, `warn`, `error`. Default `off`. | | ||
|
|
||
| An example configuration: | ||
|
|
||
| ```yaml | ||
| rules: | ||
| spec-parameters-in-by-context: error | ||
| ``` | ||
|
|
||
| ## Examples | ||
|
|
||
| Given the following configuration: | ||
|
|
||
| ```yaml | ||
| rules: | ||
| spec-parameters-in-by-context: error | ||
| ``` | ||
|
|
||
| Example of a **correct** step referencing an `operationId` (each parameter declares `in`): | ||
|
|
||
| ```yaml | ||
| # Correct example - operationId | ||
| workflows: | ||
| - workflowId: get-museum-hours | ||
| steps: | ||
| - stepId: list-hours | ||
| operationId: listMuseumHours | ||
| parameters: | ||
| - in: query | ||
| name: startDate | ||
| value: '2024-01-01' | ||
| ``` | ||
|
|
||
| Example of a **correct** step referencing a `workflowId` (parameters omit `in` and are mapped to the referenced workflow's inputs): | ||
|
|
||
| ```yaml | ||
| # Correct example - workflowId | ||
| workflows: | ||
| - workflowId: buy-tickets | ||
| steps: | ||
| - stepId: reuse-hours-workflow | ||
| workflowId: get-museum-hours | ||
| parameters: | ||
| - name: startDate | ||
| value: '2024-01-01' | ||
| ``` | ||
|
|
||
| Example of a **correct** success action transferring to another workflow with mapped parameters: | ||
|
|
||
| ```yaml | ||
| # Correct example - success action | ||
| workflows: | ||
| - workflowId: buy-tickets | ||
| steps: | ||
| - stepId: purchase | ||
| operationId: createTicket | ||
| onSuccess: | ||
| - name: continue-to-hours | ||
| type: goto | ||
| workflowId: get-museum-hours | ||
| parameters: | ||
| - name: startDate | ||
| value: '2024-01-01' | ||
| ``` | ||
|
|
||
| Example of an **incorrect** step referencing an `operationId` while omitting `in`: | ||
|
|
||
| ```yaml | ||
| # Incorrect example - operationId without `in` | ||
| workflows: | ||
| - workflowId: get-museum-hours | ||
| steps: | ||
| - stepId: list-hours | ||
| operationId: listMuseumHours | ||
| parameters: | ||
| - name: startDate | ||
| value: '2024-01-01' | ||
| ``` | ||
|
|
||
| Example of an **incorrect** success action defining `parameters` without referencing a `workflowId`: | ||
|
|
||
| ```yaml | ||
| # Incorrect example - action without workflowId | ||
| workflows: | ||
| - workflowId: buy-tickets | ||
| steps: | ||
| - stepId: purchase | ||
| operationId: createTicket | ||
| onSuccess: | ||
| - name: end-with-params | ||
| type: end | ||
| parameters: | ||
| - name: startDate | ||
| value: '2024-01-01' | ||
| ``` | ||
|
|
||
| ## Resources | ||
|
|
||
| - [Rule source](https://github.com/Redocly/redocly-cli/blob/main/packages/core/src/rules/arazzo/spec-parameters-in-by-context.ts) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like parameters also won't make sense when action type is
end.What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes I agree, I'll remove it. it is redundant to have it.