spec upgrade keeps a boolean exclusiveMinimum / exclusiveMaximum next to `$ref`, so the 3.1 / 3.2 output fails spec validate
openapi spec upgrade of a valid 3.0 document exits 0, but when a schema has minimum + exclusiveMinimum: true (or the maximum pair) next to a $ref, the boolean is copied unchanged into the 3.1 / 3.2 output. openapi spec validate then rejects the file that upgrade just wrote.
Reproduction
fb01-order-money.yaml (valid on v1.26.4: openapi spec validate fb01-order-money.yaml exits 0):
openapi: 3.0.3
info:
title: fc2 fb01-order-money
version: "0.1"
paths: {}
components:
schemas:
Money:
type: number
format: double
Order:
type: object
required: [amount]
properties:
amount:
$ref: "#/components/schemas/Money"
minimum: 0
exclusiveMinimum: true
openapi spec upgrade fb01-order-money.yaml fb01-order-money-up-v1.26.4-default.yaml
openapi spec validate fb01-order-money-up-v1.26.4-default.yaml
Actual
Upgrade, exit 0:
Processing OpenAPI document: fb01-order-money.yaml
✅ Successfully upgraded from 3.0.3 to 3.2.0
📄 Document written to: fb01-order-money-up-v1.26.4-default.yaml
The output has openapi: 3.2.0 and still has minimum: 0 and exclusiveMinimum: true next to the $ref. Validate, exit 1:
Validating OpenAPI document: fb01-order-money-up-v1.26.4-default.yaml
❌ OpenAPI document is invalid - 1 errors:
1. [18:29] error validation-type-mismatch schema.properties.amount.exclusiveMinimum expected `number`, got `boolean`
Validation completed in 1ms
Error: openAPI document validation failed
The same happens with --version 3.1.0 and --version 3.2.0, with exclusiveMinimum: false, with the maximum pair, and in component and query-parameter schemas. Without the $ref (type: number, minimum: 0, exclusiveMinimum: true), upgrade converts it to exclusiveMinimum: 0 and the output validates.
Expected
An upgraded document that validates. The README says upgrade "Converts OpenAPI 3.0.x and 3.1.x specifications to 3.2.0" and "Updates schema formats and structures", and its Validation Workflow runs spec upgrade and then spec validate.
In 3.0 the siblings of a $ref are ignored, but in 3.1 / 3.2 they are evaluated, so the kept minimum: 0 also goes from ignored to enforced. I'm not sure whether you'd rather convert the siblings or drop them. From reading openapi/upgrade.go (not tested), upgradeSchema30to31 returns early for any schema with a $ref, so its siblings are never touched.
Versions
openapi 1.26.4 (build 8989d069dfc8c30c4938930753b4c2e03c992b10, darwin arm64 release binary): as above. openapi 1.26.3 (build 2aeb6618014d2a22c249ddffe0f8030503da1e8b) writes byte-identical output, which its spec validate also rejects; its upgrade additionally warns that the input is invalid, which is #300.
Our AI agents found this while re-checking #300 on v1.26.4, using synthetic documents.