问题
I want to describe in Swagger 2.0 a parameter defined as follows :
The parameter takes a valid value in the intervals : -20 < parameter < -10 or 0 < parameter < 30
The parameter is invalid if : -10 ≤ parameter ≤ 0
This means that it has two valid intervals and thus two max and mins values to define. Does Swagger specification support that kind of definitions?
回答1:
This cannot be described in OpenAPI/Swagger 2.0, but can be described in OpenAPI 3.0 using oneOf
.
# openapi: 3.0.0
type: integer
oneOf:
- minimum: -20
maximum: -10
exclusiveMinimum: true
exclusiveMaximum: true
- minimum: 0
maximum: 30
exclusiveMinimum: true
exclusiveMaximum: true
来源:https://stackoverflow.com/questions/58874658/describe-a-multiple-range-parameter-with-swagger