现在我的 OpenAPI 2.0 YAML 文件只有一个主机 URL:
host: petstore.test.com
basePath: /
我可以像这样使用多个主机吗?host1: petstore.test.com
host2: petstore1.test.com
host3: petstore2.dev.com
最佳答案
OpenAPI 2.0 (Swagger 2.0) 仅支持具有多个方案(HTTP/HTTPS/等)的单个主机,因此您可以有效地拥有两个仅在方案上有所不同的主机:
host: petstore.test.com
schemes:
- http
- https
最新版本,OpenAPI 3.0 , 支持 multiple hosts具有不同的方案和基本路径: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
有关更多示例,请参阅 this answer .
关于swagger - 如何在 OpenAPI (Swagger) 中指定多个主机?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40583604/