Skip to main content

no-mixed-number-range-constraints

Keeps each numeric range boundary unambiguous.

AttributeValue
CategorySchema
MaturityBaseline
OpenAPIOpenAPI 3.1 and 3.2
StarterOff
LenientOff
RecommendedWarning
StrictWarning
CompleteError

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:

  • minimum and exclusiveMinimum;
  • maximum and exclusiveMaximum.

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 exclusiveMinimum or exclusiveMaximum beside 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-bounds
  • integer-bounds-required
  • no-schema-type-mismatch