swagger-api/swagger-js

How to set Setting Server Template Variables?

ItsReddi opened this issue · 0 comments

  • Swagger-Client version: latest
  • Swagger/OpenAPI version: OpenAPI 3.0

Content & configuration

Swagger/OpenAPI definition:

"servers": [
    {
      "description": "environment",
      "url": "{protocol}://{server}",
      "variables": {
        "protocol": {
          "enum": [
            "http",
            "https"
          ],
          "default": "https"
        },
        "server": {
          "enum": [
            "some.production.domain/api",
            "some.other.domain/otherapi"
          ],
          "default": "some.production.domain/api"
        }
      }
    }
  ]

Swagger-Client usage:

client = new SwaggerClient({
      url: "https://url-to-swagger.json",
      servers: {
        protocol: "http",
        server: "some.other.domain/otherapi",
      }
    ...options
})

How can we help?

The Problem is, that the server template variables are not set. Only the default will be used.
Specification: https://swagger.io/docs/specification/api-host-and-base-path/

There is something mentioned on per OAS Tag that modifying the server is possible there.
But how to set the template variables globally?