feat: add OpenAPI 3.2 support#230
Open
aaronlippold wants to merge 4 commits into
Open
Conversation
OpenAPI 3.2.0 uses the same JSON Schema dialect as 3.1 — no breaking changes, only additive features (structured tags, streaming, OAuth device flow). The version regex in OpenAPI#initialize now accepts 3.2.x versions and routes them through the existing 3.1 codepath. Fixes davishmcclurg#228 Authored by: Aaron Lippold<lippold@gmail.com>
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR adds OpenAPI 3.2 support by treating it as compatible with the existing OpenAPI 3.1 JSON Schema dialect handling, and updates documentation accordingly.
Changes:
- Accept OpenAPI
3.2.xversion strings in the OpenAPI loader. - Add a Minitest case confirming basic schema validation works for an OpenAPI 3.2 document.
- Update README and CHANGELOG to advertise OpenAPI 3.2 support.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| test/open_api_test.rb | Adds coverage ensuring an OpenAPI 3.2 document can be loaded and validated. |
| lib/json_schemer/openapi.rb | Expands version detection to route OpenAPI 3.2 through the existing 3.1 codepath. |
| README.md | Documents OpenAPI 3.2 as supported. |
| CHANGELOG.md | Adds an Unreleased entry noting the new OpenAPI 3.2 feature. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
7
to
12
| version = document['openapi'] | ||
| case version | ||
| when /\A3\.1\.\d+\z/ | ||
| when /\A3\.[12]\.\d+\z/ | ||
| @document_schema = JSONSchemer.openapi31_document | ||
| meta_schema = document.fetch('jsonSchemaDialect') { OpenAPI31::BASE_URI.to_s } | ||
| when /\A3\.0\.\d+\z/ |
Add explicit note in the OpenAPI section explaining that 3.0, 3.1, and 3.2 are all supported, and that 3.2 shares the 3.1 dialect. Authored by: Aaron Lippold<lippold@gmail.com>
The openapi.rb regex fix allows 3.2 documents to be parsed, but the document meta schema in openapi31/document.rb still had a pattern constraint of ^3\.1\.\d+ which caused document.valid? to return false for 3.2.0 documents. Updated to ^3\.[12]\.\d+ so both the parser and the meta schema accept 3.2. Added assertion to existing test: openapi.valid? must be true. Authored by: Aaron Lippold<lippold@gmail.com>
Update the document meta-schema (document.rb) with all structural fields added in OpenAPI 3.2.0: - OpenAPI Object: $self (uri-reference) - Server Object: name (string) - Path Item Object: query (operation) + additionalOperations (map) - Components Object: mediaTypes (map) + patternProperties regex - Example Object: dataValue (any) + serializedValue (string) - Parameter Object in: add querystring enum value - New media-type-or-reference $defs entry for Components.mediaTypes Add 8 tests: boundary versions (3.2.1 accepted, 3.3.0 rejected), and one per new field verifying document validation passes. 208 tests, 54472 assertions, 0 failures. 100% line + branch coverage. Authored by: Aaron Lippold<lippold@gmail.com>
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Full OpenAPI 3.2.0 support — both schema validation and document structure validation.
Schema validation
OAS 3.2.0 uses the same JSON Schema dialect as 3.1 (
https://spec.openapis.org/oas/3.1/dialect/base). The version regex inOpenAPI#initializenow accepts3.2.xversions and routes them through the existing 3.1 codepath. Schema validation works identically.Document structure validation (
openapi.valid?)The document meta-schema in
document.rbhas been updated with all structural fields added in OAS 3.2.0:$self(uri-reference)name(string)query(operation),additionalOperations(map of operations)mediaTypes(map of media type or reference)dataValue(any),serializedValue(string)querystringadded toinenumNew
media-type-or-reference$defsentry added forComponents.mediaTypes. The ComponentspatternPropertiesregex updated to includemediaTypes.Changes verified against the published specification
All new fields verified against the published spec at
spec.openapis.org/oas/v3.2.0.html(the HTML is the source of truth per the spec's own statement). The GitHub release notes describe the full 3.2 line roadmap — some features listed there (e.g.,discriminator.defaultMapping, multipartitemSchema) are not in the 3.2.0 publication.Test plan
3.2.1accepted,3.3.0rejectedopenapi.valid?passesFixes #228