Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on anything above OpenAPI 3.1 as well + changelog #419

Merged
merged 1 commit into from
May 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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: 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