Skip to content

Commit

Permalink
Error on anything above OpenAPI 3.1 as well + changelog (#419)
Browse files Browse the repository at this point in the history
Follows up #418 with a small future compatibility change so that if an
OpenAPI version is anything equal or greater than 3.1 the error is
produced. Also, add a changelog entry about it.
  • Loading branch information
brandur authored May 4, 2024
1 parent dab46d2 commit 0e21c89
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions lib/committee/drivers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ def self.load_from_data(hash, schema_path = nil, parser_options: {})
return Committee::Drivers::OpenAPI3::Driver.new.parse(openapi)
end

if hash['openapi']&.start_with?('3.1.')
raise OpenAPI3Unsupported.new('Committee does not support OpenAPI 3.1 yet')
if (version = hash['openapi'])
if Gem::Version.new(version) >= Gem::Version.new("3.1")
raise OpenAPI3Unsupported.new('Committee does not support OpenAPI 3.1+ yet')
end
end

driver = if hash['swagger'] == '2.0'
Expand Down
8 changes: 4 additions & 4 deletions test/drivers_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@
assert_kind_of Committee::Drivers::OpenAPI3::Schema, s
end

it 'fails to load OpenAPI 3.1' do
it 'fails to load OpenAPI 3.1+' do
e = assert_raises(Committee::OpenAPI3Unsupported) do
Committee::Drivers.load_from_file(open_api_3_1_schema_path, parser_options:{strict_reference_validation: true})
end
assert_equal 'Committee does not support OpenAPI 3.1 yet', e.message
assert_equal 'Committee does not support OpenAPI 3.1+ yet', e.message
end

it 'fails to load OpenAPI 3 with invalid reference' do
Expand Down Expand Up @@ -146,11 +146,11 @@
assert_kind_of Committee::Drivers::HyperSchema::Schema, s
end

it 'fails to load OpenAPI 3.1' do
it 'fails to load OpenAPI 3.1+' do
e = assert_raises(Committee::OpenAPI3Unsupported) do
Committee::Drivers.load_from_data(open_api_3_1_data)
end
assert_equal 'Committee does not support OpenAPI 3.1 yet', e.message
assert_equal 'Committee does not support OpenAPI 3.1+ yet', e.message
end
end
end
Expand Down

0 comments on commit 0e21c89

Please sign in to comment.