Redocly/redocly-cli

Support better means to set environment variables

kpervin opened this issue · 4 comments

Is your feature request related to a problem? Please describe.

Currently there is only a single way to load environment variables into the config, and that is via the envVariable field in the resolve.http.headers array. However, you cannot load these into apis.{config}.root or into the resolve.http.headers[num].matches field.

Describe the solution you'd like

A means of loading env variables akin to GraphQL Config. They use a library called string-env-interpolation (ref to line in their source).

Hi @kpervin! Sorry for the delay. Could you clarify your suggestion? Do you want to be able to provide env variables for apis? Or to change the env syntax? Maybe you could provide an example of such config?

It would be nice to be able to provide env variables for pretty much the whole config, apart from the reserved key fields. For example:

apis:
  v4:
    root: https://${DOMAIN}/v3/api-docs/User%20API%20v4
    x-openapi-ts:
      output: ./src/v4.d.ts
  v3:
    root: https://${DOMAIN}/v3/api-docs/UserV3
    x-openapi-ts:
      output: ./src/v3.d.ts
resolve:
  http:
    headers:
      - matches: https://${DOMAIN}/**
        name: Authorization
        envVariable: ${API_KEY}

Oh, I see. Thanks for the clarification!

Thanks for the suggestion, but the config files are intentionally static. I would recommend you add some pre-processing scripts of your own to pick up environment variables if that's an important part of your workflow. We're not planning to implement support for environment variables at this time - which I know isn't what you were hoping for, but it's important to us to be clear about what you can expect.