Swagger 2.x supports OpenAPI Specification 3.0 (see here for reference), where host, basePath and schemes keywords have been replaced by the server element.
In OpenAPI 3.0, you can use an array of server elements to specify one or more base URLs for your API.
A server URL has the following structure:
scheme://host[:port][/basePath]
You can register the servers using the annotation @Server:
Alternatively you can define the servers in your Swagger configuration file e.g:
YAML
servers:
- url: https://api.example.com/v1
description: example
JSON
"servers" : [ {
"url" : "https://api.example.com/v1",
"description" : "example"
} ]