openapistack / openapi-client-axios

JavaScript client library for consuming OpenAPI-enabled APIs with axios
https://openapistack.co
MIT License
558 stars 67 forks source link

use variables in baseURL #20

Closed Dzibeul closed 4 years ago

Dzibeul commented 4 years ago

Hi,

I use a OpenAPI file with variables in servers url :

servers:
 url: https://api.{region}.domain.com/api/v1
  variables:
    region:
      default: eu-west-2
      enum: [eu-west-2, us-east-2, us-west-1]
 url: https://api.{region}.domain.hk/api/v1
  variables:
    region:
      default: cn-southeast-1
      enum: [cn-southeast-1]

When I use the getBaseURL() function, it returns this :

https://api.{region}.domain.com/api/v1

Is there a way to pass parameters in order to build the baseURL with the {region}, or at least the default value?

Thanks

anttiviljami commented 4 years ago

Hi! Thanks for bringing this up. I actually hadn't realised this is a feature of the OAS 3 specification.

I'll try to find the time to look into this. In the meantime, you should probably just do a quick step to substitute the variables before instantiating OpenAPIClient.

anttiviljami commented 4 years ago

Fixed in #31