Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [Unreleased]

### Features

- 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 #228.

## [2.5.0] - 2025-12-08

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# JSONSchemer

JSON Schema validator. Supports drafts 4, 6, 7, 2019-09, 2020-12, OpenAPI 3.0, and OpenAPI 3.1.
JSON Schema validator. Supports drafts 4, 6, 7, 2019-09, 2020-12, OpenAPI 3.0, OpenAPI 3.1, and OpenAPI 3.2.

## Installation

Expand Down
2 changes: 1 addition & 1 deletion lib/json_schemer/openapi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def initialize(document, **options)

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/
Comment on lines 7 to 12
Expand Down
21 changes: 21 additions & 0 deletions test/open_api_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,27 @@ class OpenAPITest < Minitest::Test
'hungry' => 'kinda'
}

def test_openapi_3_2_accepted
openapi = JSONSchemer.openapi({
'openapi' => '3.2.0',
'info' => { 'title' => 'Test', 'version' => '1.0' },
'paths' => {},
'components' => {
'schemas' => {
'Widget' => {
'type' => 'object',
'properties' => {
'name' => { 'type' => 'string' }
}
}
}
}
})
schema = openapi.schema('Widget')
assert(schema.valid?({ 'name' => 'hello' }))
refute(schema.valid?({ 'name' => 42 }))
end

def test_discriminator_specification_example
openapi = {
'openapi' => '3.1.0',
Expand Down