spec validate rejects valid OpenAPI 3.0 documents that use boolean exclusiveMinimum / exclusiveMaximum
openapi spec validate (and openapi spec lint) fail with exit 1 on OpenAPI 3.0.x documents that use the boolean exclusiveMinimum or exclusiveMaximum, which is how OpenAPI 3.0 defines those keywords.
Reproduction
case-exclusiveMin.yaml:
openapi: 3.0.3
info:
title: case exclusiveMin
version: "1"
paths: {}
components:
schemas:
S:
type: number
minimum: 5
exclusiveMinimum: true
openapi spec validate case-exclusiveMin.yaml
Actual (exit 1)
Validating OpenAPI document: case-exclusiveMin.yaml
❌ OpenAPI document is invalid - 1 errors:
1. [11:25] error validation-type-mismatch schema.exclusiveMinimum expected `number`, got `boolean`
Validation completed in 1ms
Error: openAPI document validation failed
exclusiveMaximum: false gives the same error. So does the 3.0.3 example document in openapi/README.md ("Upgrade an OpenAPI document from 3.0.x to 3.2.0"), which uses exclusiveMaximum: true.
Expected
Valid, exit 0. @seriousme/openapi-schema-validator 2.12.0 reports the same file as valid 3.0.
The OpenAPI 3.0.3 Schema Object says exclusiveMinimum and exclusiveMaximum "are taken directly from the JSON Schema definition and follow the same specifications", and the official 3.0 schema has "exclusiveMinimum": { "type": "boolean", "default": false } (https://raw.githubusercontent.com/OAI/OpenAPI-Specification/3.0.3/schemas/v3.0/schema.json). The README lists "OpenAPI 3.0.0 through 3.0.4" as supported, and #52 ("fix: support OpenAPI 3.0 boolean exclusiveMinimum/exclusiveMaximum validation") meant to cover this case.
Versions
openapi 1.26.3 (build 2aeb6618014d2a22c249ddffe0f8030503da1e8b, darwin arm64 release binary; same commit as main today). Every release we tried from v1.6.5 to v1.26.3 gives the same result, including v1.7.2, the release with #52.
Thanks for the really thorough report and repro, it made this quick to track down. You were right that #52 never actually took effect for full documents: the document's OpenAPI version wasn't being passed through to schema validation, so every schema was checked against the 3.1 dialect regardless of the openapi version.
Fix is up in #303, which also makes sure plain $ref schemas in 3.0 documents keep validating once the 3.0 dialect is applied.
Thanks for the quick fix, Tristan. I re-ran our checks on v1.26.4: the case here and the README's 3.0.3 example both pass now. Two things came up along the way, filed as #310 and #311.