Arazzo-Specification icon indicating copy to clipboard operation
Arazzo-Specification copied to clipboard

Handle `servers` variable params

Open DmitryAnansky opened this issue 1 year ago • 7 comments

Hi Everyone,

I encountered a scenario that isn't explicitly covered in the documentation, and I'm hoping you can clarify it for me. It is possible to define server variables in OpenAPI like this:

servers:
  - url: 'https://api-url.example.com/organizations/{organizationId}'
    description: api server
    variables:
      organizationId:
        default: unknown
        description: >-
          Unique organization identifier.

My confusion arises from how to pass this organizationId to the step parameters. My assumption was to pass it as a parameter like this:

    steps:
      - stepId: getData
        operationId: GetData
        parameters:
          - in: path
            name: organizationId
            value: someOrg

However, it seems that this organizationId parameter doesn't actually belong to the parameters in the path, but rather to the server variables. Please let me know if you have some configuration in mind, maybe you already discussed it before.

Looking forward to your reply, Thank you.

DmitryAnansky avatar Jul 26 '24 13:07 DmitryAnansky

is it fair to assume a server url and path url would be combined into one for the purposes of the workflow? In that case, it would still pass as a path variable and should be substituted at runtime.

jeremyfiel avatar Jul 30 '24 21:07 jeremyfiel

But how about the server variables which are not path:

servers:
  - url: 'https://{organizationId}.example.com'
    description: api server
    variables:
      organizationId:
        default: unknown
        description: >-
          Unique organization identifier.

RomanHotsiy avatar Aug 12 '24 12:08 RomanHotsiy

oh that's a good question, we don't have any enum for a server variable because parameter is taken from the OAS definition, body, cookie, path, query, header, only.

I think you can use the reusable object for this use case and use an expression

version is the variable name. the servers index can be modified in the expression if more than one server exists

reference: '$.servers[0].variables.version.default'
value: <new value>

jeremyfiel avatar Aug 12 '24 15:08 jeremyfiel

actually, this may not work because the ABNF in the spec doesn't cover the servers array. i may be interpreting it incorrectly

https://spec.openapis.org/arazzo/v1.0.0#runtime-expressions

jeremyfiel avatar Aug 12 '24 15:08 jeremyfiel

I'm sure it's not covered. For now we'll just use path parameters in our implementation but would be great to cover it in the future versions of arazzo.

RomanHotsiy avatar Aug 12 '24 15:08 RomanHotsiy

Hi folks,

Apologies in delayed response here. As @RomanHotsiy hints to, this is not covered by Arazzo currently. At the moment it's left up to the runtime process (e.g. what's invoking the Arazzo Document) to determine what target host to call.

As different OADs within the sourceDescriptions can have different server variable constructs, I do think that extending the Parameters Object to cover in: server might be a solid way forward.

This is a good candidate for 1.1.0

frankkilcommins avatar Aug 13 '24 08:08 frankkilcommins

There can also be multiple servers defined in a single OAD. It seems like there should be some way for the user to indicate (via inputs maybe) which server (and if there are variables, which values) to use.

adamaltman avatar Sep 14 '24 21:09 adamaltman