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

chore: suggest multilevel parameters #155

Merged

Conversation

DmitryAnansky
Copy link
Contributor

@DmitryAnansky DmitryAnansky commented Feb 22, 2024

This pull request proposes the introduction of additional options for defining parameters at different levels within the workflow specification.
According to current suggestion the only level that can have parameters defined is Step level.
This suggestion aims to provide more flexibility by allowing parameters definitions at the root and workflow levels as well.

The particular use-case can be found in the ExtendedParametersExample.workflow.yaml with JWT authentication token applied to all the Step API calls. This modification eliminates the need for duplicating parameters across individual steps, enhancing overall maintainability.

Same can be applied to Workflow level parameters.

workflowsSpec: 1.0.0
info:
  title: Public Zoo API
  version: '1.0'
sourceDescriptions:
  - name: animals
    type: openapi
    url: ./animals.yaml
parameters:
  - in: header
    name: Authorization
    value: Bearer someSecretToken
workflows:
  - workflowId: animal-workflow
    parameters:
      - in: cookie
        name: workflowLevelParamOne
        value: someValue
      - in: header
        name: workflowLevelParamTwo
        value: someValue
    steps:
      - stepId: post-step
        parameters:
          - in: cookie
            name: authentication
            value: SUPER_SECRET
        operationId: animals.postAnimal
      - stepId: get-step
        operationId: animals.getRandomAnimal

Please let me know what do you think about this idea,
Thanks.

@DmitryAnansky DmitryAnansky marked this pull request as draft February 22, 2024 15:42
@DmitryAnansky DmitryAnansky reopened this Feb 22, 2024
@DmitryAnansky DmitryAnansky force-pushed the chore/parameters-extended-suggestion branch from ba766c6 to 4134bfa Compare February 22, 2024 16:08
@DmitryAnansky DmitryAnansky marked this pull request as ready for review February 22, 2024 16:09
@lornajane
Copy link
Contributor

I had a bit of a dig through the slack channel history because I know I've seen this conversation before and to summarise: the expectation is that the same flows might be used with different parameters, so these would be supplied by the tool that uses the workflow rather than being coupled to the workflow.

So if you describe a flow where a user gets a list of items and edits the first one, you'd then execute the flow using parameters that are: a list, an empty list, an invalid user token, users with different access levels, etc.

My questions:

  1. Is this a fair explanation of why the parameters are only set at step level (to get around the fact that it is harder to inject them to there)?
  2. Is there a reason we wouldn't want to support them at other levels?
  3. Does anyone have any concerns about us using x-parameters for this use case until we support parameters in more places?

@lornajane
Copy link
Contributor

I'll also note that there's some connection with workflows[$id].inputs to think about if we support parameters at a per-workflow level (see https://github.com/OAI/sig-workflows/blob/main/versions/1.0.0.md#fixed-fields-3)

@frankkilcommins
Copy link
Collaborator

@lornajane - I'll try to answer below.

I had a bit of a dig through the slack channel history because I know I've seen this conversation before and to summarise: the expectation is that the same flows might be used with different parameters, so these would be supplied by the tool that uses the workflow rather than being coupled to the workflow.

I don't see a problem here, this would just be that the calling code would invoke the workflow with a different Inputs object instance

So if you describe a flow where a user gets a list of items and edits the first one, you'd then execute the flow using parameters that are: a list, an empty list, an invalid user token, users with different access levels, etc.

Here I would imagine that the workflow would have a defined Inputs object that takes an array of whatever and a string for the user token, then you run the workflow with different combinations of data for the Inputs object.

Example Inputs Object:

    Inputs:
      type: object
      properties:
        list: 
          type: array
          items:
            type: object
            properties:
              foo:
                type: string
              bar:
                type: integer
        token:
          type: string  
  1. Is this a fair explanation of why the parameters are only set at step level (to get around the fact that it is harder to inject them to there)?

I believe the use case you laid out is possible by supplying the appropriate Input object values to the workflow (e.g. to run with different datasets). Theoretically, you could even pass in an Input object with counter property and a nested array containing all datasets and set up the workflow such that it loops through the data by defining an imaginative successCriteria to force iteration and setting the inputs data. Not sure such dark arts are warranted however.

  1. Is there a reason we wouldn't want to support them at other levels?

One goal is to ensure that we can be very deterministic about what parameters on a step MUST be mappable to an API operation. Finding the scenario where 100% of the steps use a parameter might not be overly common. If indeed it's the case, defining the parameter with the components section and having a $ref to the parameter explicitly where it's applicable IMO is a verboseness we can live with for now.
If the very common situation that come to mind is an Authentication scenario, then I'd almost expect the Auth dance to be define in it's own independent workflow and referenced as the current workflow's first step.

  1. Does anyone have any concerns about us using x-parameters for this use case until we support parameters in more places?

I'd like to dive deeper to understand what is the true use case / gap here that cannot be achieved using a combination of the reusable Inputs, reusable parameters, and chained workflows (see https://github.com/OAI/sig-workflows/blob/main/versions/1.0.0.md#components-object). Then we can determine if this is in/out of scope and a decision on your own extension can then be taken.

@RomanHotsiy
Copy link

I'd like to dive deeper to understand what is the true use case

One use case is to to provide an authorization header for all the steps in a whole workflows file.
Reusable parameters would require me to reference reusable parameter in every single step.

This is similar to how parameters are allowed on Operation object but also on the Path item object.

@frankkilcommins
Copy link
Collaborator

I'd like to dive deeper to understand what is the true use case

One use case is to to provide an authorization header for all the steps in a whole workflows file. Reusable parameters would require me to reference reusable parameter in every single step.

This is similar to how parameters are allowed on Operation object but also on the Path item object.

OK - I understand. Let me do some analysis so see what ratio of OAD's I can find that utilize params at the path item object level.

@frankkilcommins
Copy link
Collaborator

@RomanHotsiy @lornajane @DmitryAnansky I'm supportive of the proposal to have the ability to define parameters at the workflow level which will then be automatically applied to each step in the workflow should the need arise to have this behaviour.

I'd opt to hold off on the root level parameters to be used by all steps in all workflows for now until we have more feedback from the community on whether such a situation is very common.

Copy link
Collaborator

@frankkilcommins frankkilcommins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. As suggested in last PR comment, let's limit to Workflow.parameters for now.
I'll submited a PR on your branch to adjust the Step.Parameters verbiage to align with the changes - See DmitryAnansky#1

versions/1.0.0.md Outdated Show resolved Hide resolved
versions/1.0.0.md Outdated Show resolved Hide resolved
examples/1.0.0/ExtendedParametersExample.workflow.yaml Outdated Show resolved Hide resolved
@frankkilcommins frankkilcommins added the implementor-draft In scope for first version label Mar 13, 2024
DmitryAnansky and others added 3 commits March 26, 2024 15:16
Co-authored-by: Frank Kilcommins <fkilcommins@gmail.com>
Co-authored-by: Frank Kilcommins <fkilcommins@gmail.com>
Co-authored-by: Frank Kilcommins <fkilcommins@gmail.com>
@frankkilcommins
Copy link
Collaborator

@DmitryAnansky thanks for committing the changes. Could you merge DmitryAnansky#1 into your fork so that it's included in this PR?

@frankkilcommins frankkilcommins merged commit 6e2769f into OAI:main Mar 27, 2024
1 check passed
@frankkilcommins
Copy link
Collaborator

I will create a separate PR to merge changes in DmitryAnansky#1 to the workflows main branch (issue #167 )

frankkilcommins added a commit that referenced this pull request Mar 28, 2024
…170)

* chore: suggest multilevel parameters (#155)

* chore: suggest multilevel parameters

* Update versions/1.0.0.md

Co-authored-by: Frank Kilcommins <fkilcommins@gmail.com>

* Update examples/1.0.0/ExtendedParametersExample.workflow.yaml

Co-authored-by: Frank Kilcommins <fkilcommins@gmail.com>

* Update versions/1.0.0.md

Co-authored-by: Frank Kilcommins <fkilcommins@gmail.com>

---------

Co-authored-by: Frank Kilcommins <fkilcommins@gmail.com>

* Remove references to WHATWG to avoid confusion (#145)

* Remove references to WHATWG to avoid confusion

* Correct relative reference wording

* Section 4.2 not 4.1!

* Simplify URI wording

* Adjust Step Parameters desc to cater for Workflow parameters addition (#169)

* feat: add `dependsOn` capability for workflow level (#164)

* feat: add `dependsOn` capability for workflow level

* chore: typo fix

* chore: grammer fix

* feat: Add Request Body Object (#162)

* feat: Add Request Body Object

* chore: fix typos in examples

* Clarity on referencing Components Parameters (#149)

* Clarity on referencing Components Parameters

* Remove Reference Object to avoid clash with JSON Schema keyword. Replace with expression based referencing

* chore: keep fixed field link names consistent

* chore: Name component parameters as type Reusable Parameter Object

* chore: adjust Workflow level parameters to use Reusable Parameter Objects

---------

Co-authored-by: Dmytro Anansky <dmytro@redocly.com>
Co-authored-by: Nick Denny <nick@apimetrics.com>
frankkilcommins added a commit that referenced this pull request Apr 3, 2024
* feat: adding support for share success and failure actions

* Merging latest 'main' changes in to Action Object Extensions branch (#170)

* chore: suggest multilevel parameters (#155)

* chore: suggest multilevel parameters

* Update versions/1.0.0.md

Co-authored-by: Frank Kilcommins <fkilcommins@gmail.com>

* Update examples/1.0.0/ExtendedParametersExample.workflow.yaml

Co-authored-by: Frank Kilcommins <fkilcommins@gmail.com>

* Update versions/1.0.0.md

Co-authored-by: Frank Kilcommins <fkilcommins@gmail.com>

---------

Co-authored-by: Frank Kilcommins <fkilcommins@gmail.com>

* Remove references to WHATWG to avoid confusion (#145)

* Remove references to WHATWG to avoid confusion

* Correct relative reference wording

* Section 4.2 not 4.1!

* Simplify URI wording

* Adjust Step Parameters desc to cater for Workflow parameters addition (#169)

* feat: add `dependsOn` capability for workflow level (#164)

* feat: add `dependsOn` capability for workflow level

* chore: typo fix

* chore: grammer fix

* feat: Add Request Body Object (#162)

* feat: Add Request Body Object

* chore: fix typos in examples

* Clarity on referencing Components Parameters (#149)

* Clarity on referencing Components Parameters

* Remove Reference Object to avoid clash with JSON Schema keyword. Replace with expression based referencing

* chore: keep fixed field link names consistent

* chore: Name component parameters as type Reusable Parameter Object

* chore: adjust Workflow level parameters to use Reusable Parameter Objects

---------

Co-authored-by: Dmytro Anansky <dmytro@redocly.com>
Co-authored-by: Nick Denny <nick@apimetrics.com>

* Add Reusable Object and referencing ability

* chore: fix yaml example indentation

* chore: fix JSON examples

* chore: fix typo in `workflowStepActions`

---------

Co-authored-by: Dmytro Anansky <dmytro@redocly.com>
Co-authored-by: Nick Denny <nick@apimetrics.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
implementor-draft In scope for first version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants