Swagger- Schemes HTTP and HTTPS with different por

2019-03-01 08:05发布

问题:

How does one specify multiple schema with different ports? Specifically, I want to have HTTP on port 81 and HTTPS on port 444.

swagger: '2.0'
info:
  version: 1.0.0
  title: API for gateways
  description: API for gateways to access server (port 81 for http and 444 for https)
schemes:
  - http
  - https
host: gateway.example.com:81
basePath: /1.0
paths:

回答1:

This is possible in OpenAPI 3.0, but not in OpenAPI/Swagger 2.0.

openapi: 3.0.0
servers:
  - url: 'http://gateway.example.com:81'
  - url: 'https://gateway.example.com:444'