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?
This cannot be described in OpenAPI/Swagger 2.0, but can be described in OpenAPI 3.x using oneOf
.
type: integer
oneOf:
- minimum: -20
maximum: -10
exclusiveMinimum: true
exclusiveMaximum: true
- minimum: 0
maximum: 30
exclusiveMinimum: true
exclusiveMaximum: true
type: integer
oneOf:
- exclusiveMinimum: -20
exclusiveMaximum: -10
- exclusiveMinimum: 0
exclusiveMaximum: 30
exclusiveM*
keywords were changed from boolean to numbers in JSON Schema Draft 6. OAS 3.1 uses JSON Schema 2020-12 by default.