Skip to content

fix(openapi): emit OpenAPI 3.1 schemas instead of 3.0 ones - #63

Merged
DASPRiD merged 1 commit into
mainfrom
fix/openapi-3.1-schemas
Sep 28, 2026
Merged

DASPRiD merged 1 commit into
mainfrom
fix/openapi-3.1-schemas

Conversation

@DASPRiD

@DASPRiD DASPRiD commented Sep 28, 2026

Copy link
Copy Markdown
Owner

Request bodies and query parameters were converted with zod's openapi-3.0 target, although every
builder documents its output as OpenAPI 3.1. Under 3.1 that output is misread: nullable: true is
ignored, so a validator rejects null where the schema allows it, and a boolean exclusiveMinimum
fails the meta-schema. Conversions now use JSON Schema 2020-12, which OpenAPI 3.1 builds on,
without the root $schema the conversion adds.

Resource and relationship type fields are written as const rather than a single-value enum,
matching what the conversion emits for literals.

Specs generated with this version change shape: literals become const, nullable primitives
type: [..., "null"] and other nullable schemas an anyOf with { type: "null" }, exclusive
bounds numbers, tuples prefixItems, and extracted definitions move from definitions to $defs.
Snapshot tests of a generated spec need updating, and request body and query parameter output no
longer fits an OpenAPI 3.0 document.

Refs to $defs still break once a schema is embedded; that predates this change and is tracked in #62.

Request bodies and query parameters were converted with zod's openapi-3.0 target, although every
builder documents its output as OpenAPI 3.1. Under 3.1 that output is misread: `nullable: true` is
ignored, so a validator rejects null where the schema allows it, and a boolean `exclusiveMinimum`
fails the meta-schema. Conversions now use JSON Schema 2020-12, which OpenAPI 3.1 builds on,
without the root `$schema` the conversion adds.

Resource and relationship `type` fields are written as `const` rather than a single-value `enum`,
matching what the conversion emits for literals.

Specs generated with this version change shape: literals become `const`, nullable primitives
`type: [..., "null"]` and other nullable schemas an `anyOf` with `{ type: "null" }`, exclusive
bounds numbers, tuples `prefixItems`, and extracted definitions move from `definitions` to `$defs`.
Snapshot tests of a generated spec need updating, and request body and query parameter output no
longer fits an OpenAPI 3.0 document.
@DASPRiD
DASPRiD merged commit aee81c4 into main Sep 28, 2026
6 checks passed
@codecov

codecov Bot commented Sep 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (70e25d7) to head (19c41f1).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #63   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           29        30    +1     
  Lines         4049      4058    +9     
  Branches       405       406    +1     
=========================================
+ Hits          4049      4058    +9     
Components Coverage Δ
Server 100.00% <ø> (ø)
OpenAPI 100.00% <100.00%> (ø)
Integration: Koa 100.00% <ø> (ø)
Integration: Taxum 100.00% <ø> (ø)
Client 100.00% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@automated-pr-bot automated-pr-bot Bot mentioned this pull request Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant