Reputation: 65
Reviewing the swagger documentation specifically the annotations I did not find how to define the host and basePath properties. Any idea where to set them?
documentation consulted: Swagger-2.X---Annotations
Here is a json generated with the variables: petstore.swagger.io/v2/swagger.json
Upvotes: 5
Views: 17342
Reputation: 3233
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"
} ]
Upvotes: 6