API Server templating using variables
1.0Various ways to define API servers in the spec including variables
servers:
- url: 'http://example.com/api'
description: Test server (just for example)
- url: '/api'
- url: '{protocol}://dev.com/api/{version}'
variables:
protocol:
description: Protocol (with enum)
default: https
enum:
- http
- https
version:
description: API Version (without enum)
default: v1
- url: '{protocol}://{environment}.example.com/{version}'
variables:
environment:
default: api # Production server
description: >
Server choices:
* `api` Production (this is the default).
* `api.qa` QA server.
* `api.dev` Development server.
enum:
- api # Production server
- api.dev # Development server
- api.qa # Testing server
protocol:
default: https
enum:
- http
- https
version:
default: v2
enum:
- v1
- v2
Servers
- http://example.com/api - Test server (just for example)
- https://dev.com/api/v1 -
- https://api.example.com/v2 -