no-mixed-number-range-constraints
Keeps each numeric range boundary unambiguous.
| Attribute | Value |
|---|---|
| Category | Schema |
| Maturity | Baseline |
| OpenAPI | OpenAPI 3.1 and 3.2 |
| Starter | Off |
| Lenient | Off |
| Recommended | Warning |
| Strict | Warning |
| Complete | Error |
Intent
OpenAPI 3.1 uses numeric exclusiveMinimum and exclusiveMaximum values. Declaring an inclusive and exclusive value for the same boundary creates two competing limits.
Flags
This rule reports a schema containing either pair as numbers:
minimumandexclusiveMinimum;maximumandexclusiveMaximum.
Each conflicting lower or upper boundary produces its own finding.
Does not flag
- A schema using only one constraint for each boundary.
- OpenAPI 3.0 boolean
exclusiveMinimumorexclusiveMaximumbeside its numeric boundary. - OpenAPI 2.0 or 3.0 documents; this rule applies only to 3.1/3.2 numeric exclusive bounds.
See it fail
openapi: 3.1.0
info:
title: Pricing API
version: 1.0.0
paths: {}
components:
schemas:
Price:
type: number
minimum: 0
exclusiveMinimum: 0
Specmatic reports:
Schema should not have both `minimum` and `exclusiveMinimum`. Use one or the other.
Fix it
Keep minimum when zero is valid:
Price:
type: number
minimum: 0
Keep exclusiveMinimum when the value must be greater than zero:
Price:
type: number
exclusiveMinimum: 0
Configure
specmatic-linter.yaml
profiles:
default:
rules:
extends:
- recommended
override:
no-mixed-number-range-constraints: error
Nearby rules
invalid-numeric-boundsinteger-bounds-requiredno-schema-type-mismatch