feat: add OpenAPI 3.2 support#479
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds OpenAPI 3.2 support by treating 3.2 documents as using the same JSON Schema dialect handling as OpenAPI 3.1, and updates tests/docs accordingly.
Changes:
- Extend meta-schema/dialect detection to accept
openapi: 3.2.x - Add a spec asserting a 3.2.0 document parses successfully
- Update README + changelog to document 3.2 support
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| spec/definition_spec.rb | Adds coverage verifying a minimal OpenAPI 3.2 document parses and exposes expected properties |
| lib/openapi_first/builder.rb | Expands version matching so 3.2 uses the OpenAPI 3.1 JSON Schema dialect path |
| README.md | Documents support for OpenAPI 3.2 |
| CHANGELOG.md | Notes the new OpenAPI 3.2 support and references the motivating issue |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| version = document['openapi'] | ||
| case version | ||
| when /\A3\.1\.\d+\z/ | ||
| when /\A3\.[12]\.\d+\z/ |
| # openapi_first | ||
|
|
||
| openapi_first is a Ruby gem for request / response validation and contract-testing against an [OpenAPI](https://www.openapis.org/) 3.0 or 3.1 Openapi API description (OAD). It makes an APIFirst workflow easy and reliable. | ||
| openapi_first is a Ruby gem for request / response validation and contract-testing against an [OpenAPI](https://www.openapis.org/) 3.0, 3.1, or 3.2 Openapi API description (OAD). It makes an APIFirst workflow easy and reliable. |
|
|
||
| ## Unreleased | ||
|
|
||
| - Add OpenAPI 3.2 support. OAS 3.2 uses the same JSON Schema dialect as 3.1 (no breaking changes), so the 3.1 codepath handles it correctly. Fixes #469. |
|
Hey @aaronlippold, thanks for looking into this. I was always struggling a bit with OAS 3.2, because I did not really understand what changes are included and what openapi_first needs to implement in order to support it. Here are some things from the release page where I think we need to do something:
I have listed these points in the related issue as well. |
|
I’ll take a look tonight
…--------
Aaron Lippold
***@***.***
260-255-4779
twitter/aim/yahoo,etc.
'aaronlippold'
On Tue, May 26, 2026 at 17:05 Andreas Haller ***@***.***> wrote:
*ahx* left a comment (ahx/openapi_first#479)
<#479 (comment)>
Hey @aaronlippold <https://github.com/aaronlippold>, thanks for looking
into this. I was always a struggling with OAS 3.2, because I did not really
understand what changes are included and what openapi_first needs to
implement in order to support it. Here are some things from the release
page <https://github.com/OAI/OpenAPI-Specification/releases/tag/3.2.0>
where I don't know what to do with:
1. discriminator and the new field defaultMapping – Does that just
work?
2. "Additions to support multipart media types"
2.1 New itemSchema field
2.2 New fields prefixEncoding and itemEncoding
3. Support for additional HTTP methods – Under an additionalOperations
entry in a Path, use any other methods not listed as keys using the correct
capitalization, e.g. LINK. Do NOT add HEAD under this, use the existing
sibling head.
I have listed these points in the related issue
<#469> as well.
—
Reply to this email directly, view it on GitHub
<#479?email_source=notifications&email_token=AALK42H6THYXXHUDYQKPJYT44YBKVA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTINJUHA4DGOJUGA4KM4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-4548839408>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AALK42BHZV3WPJ3OA4XG5QL44YBKVAVCNFSM6AAAAACZNUCDFSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DKNBYHAZTSNBQHA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
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 Builder#detect_meta_schema now accepts 3.2.x versions and routes them through the existing 3.1 codepath. Fixes ahx#469 Authored by: Aaron Lippold<lippold@gmail.com>
bin/setup runs bundle install but doesn't initialize the spec/data/train-travel-api submodule. Developers cloning the repo and running bin/setup then bundle exec rake see 6 test failures from missing fixture files. Adding git submodule update --init --recursive to bin/setup prevents this. Authored by: Aaron Lippold<lippold@gmail.com>
Process operations defined under path_item.additionalOperations (OAS 3.2.0 field for non-standard HTTP methods like COPY, LINK). Extract register_operation helper from the REQUEST_METHODS loop to share logic between standard methods and additionalOperations. Method keys from additionalOperations are downcased to match the router's internal UPPERCASE convention (router.route_at upcases). 3 tests: COPY method routed, GET still works, undefined LINK rejected. 570 examples, 0 failures, 100% line + branch coverage. Authored by: Aaron Lippold<lippold@gmail.com>
d3b5a4d to
090fecb
Compare
- Fix "Openapi" → "OpenAPI" in README (Copilot caught this) - Reword CHANGELOG: list version acceptance, additionalOperations support, and note that multipart streaming fields and discriminator.defaultMapping are NOT in the published 3.2.0 spec (they appear in release notes but not the final specification) - Link issue ahx#469 in CHANGELOG for consistency Authored by: Aaron Lippold<lippold@gmail.com>
|
Hey @ahx — sorry for the delay, wanted to do this properly. I went through the published OAS 3.2.0 spec (the HTML is the source of truth per the spec's own statement) and here's what I found for each of your three questions: 1.
|
| Object | New Field | Type |
|---|---|---|
| OpenAPI Object | $self |
string (uri-reference) |
| Server Object | name |
string |
| Path Item Object | query |
Operation Object |
| Path Item Object | additionalOperations |
Map[string, Operation] |
| Components Object | mediaTypes |
Map[string, Media Type | Reference] |
| Example Object | dataValue |
Any |
| Example Object | serializedValue |
string |
Parameter in |
"querystring" |
new enum value |
Everything else (Tag, Response, Security Scheme, OAuth Flows, XML, Encoding, Media Type) is unchanged from 3.1.0 in the published spec.
I've updated the json_schemer document meta-schema with all these fields in PR #230, so openapi.valid? now passes for 3.2.0 documents using any of these new fields.
Let me know if you'd like anything changed or if there's something I missed!
I don't understand. |
Summary
OpenAPI 3.2.0 support — version acceptance,
additionalOperationsrouting, and rebased on v3.4.3.Version acceptance
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 inBuilder#detect_meta_schemanow accepts3.2.xversions and routes them through the existing 3.1 codepath.additionalOperationssupportOAS 3.2.0 adds
additionalOperationsto the Path Item Object for non-standard HTTP methods (e.g.COPY,LINK).Builder#routernow iteratesadditionalOperationsafter the standardREQUEST_METHODSloop, registering each operation through a sharedregister_operationhelper extracted from the existing loop (DRY refactor).Other changes
bin/setup: addedgit submodule update --init --recursivefor test fixture setupVerified against the published specification
All changes verified against the published spec at
spec.openapis.org/oas/v3.2.0.html. The GitHub release notes describe the full 3.2 line roadmap — some features listed there (discriminator.defaultMapping, multipartitemSchema) are not in the 3.2.0 publication. See comment for the complete 3.2.0 field audit.Companion PR
json_schemer PR #230 adds all 3.2.0 structural fields to the document meta-schema, so
openapi.valid?passes for 3.2.0 documents.Test plan
additionalOperations(COPY routed, GET unaffected, undefined LINK rejected)Fixes #469