在Swagger中,如何指定多个主机?

use*_*740 6 swagger

我可以使用多个主机,例如:

host1: petstore.test.com
host2: petstore1.test.com
host3: petstore2.dev.com
Run Code Online (Sandbox Code Playgroud)

现在我的YAML文件只有一个主机URL.

例如:

host: petstore.test.com
basePath: /
Run Code Online (Sandbox Code Playgroud)

Hel*_*len 10

OpenAPI/Swagger 2.0仅支持具有多个方案(HTTP/HTTPS /等)的单个主机,因此您可以有效地拥有两个仅在方案中不同的主机:

host: petstore.test.com
schemes:
  - http
  - https
Run Code Online (Sandbox Code Playgroud)

最新版本OpenAPI 3.0支持多个主机:

servers:
  - url: https://petstore.prd.com
    description: Production server

  - url: {scheme}://petstore.dev.com/subpath
    description: Development server
    templates:
      scheme:
        enum:
          - http
          - https
        default: https
Run Code Online (Sandbox Code Playgroud)