Skip to content

Commit

Permalink
allow json_schemer 2.3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
klausmeyer committed Aug 22, 2024
1 parent 3ea173e commit 7b5876c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ jobs:
strategy:
fail-fast: false
matrix:
activesupport: ['6.1', '7.0', '7.1']
json_schemer: ['2.0', '2.1']
activesupport: ['6.1', '7.0', '7.1', '7.2']
json_schemer: ['2.0', '2.1', '2.2', '2.3']
ruby: ['3.1', '3.2', '3.3']
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion openapi_contracts.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Gem::Specification.new do |s|
s.files = Dir['lib/**/*', 'README.md']

s.add_dependency 'activesupport', '>= 6.1', '< 8'
s.add_dependency 'json_schemer', '>= 2', '< 2.2'
s.add_dependency 'json_schemer', '>= 2', '< 2.4'
s.add_dependency 'openapi_parameters', '>= 0.3.3', '< 0.4'
s.add_dependency 'rack', '>= 2.0.0'

Expand Down
12 changes: 11 additions & 1 deletion spec/openapi_contracts/validators/request_body_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,19 @@
}
end

let(:error_disallowed_additional_property) do
# The exact wording of the error messages changed after version 2.2 of json_schemer gem
# https://github.com/davishmcclurg/json_schemer/compare/v2.1.1...v2.3.0#diff-fbfde32a749d1a55202956b04373a19b8612259773aff9e2dadd525215c4a7f5R303
if Gem.loaded_specs['json_schemer'].version < Gem::Version.create('2.2')
'object property at `/data/id` is not defined and schema does not allow additional properties'
else
'object property at `/data/id` is a disallowed additional property'
end
end

it 'returns all errors' do
expect(subject.call).to contain_exactly(
'object property at `/data/id` is not defined and schema does not allow additional properties',
error_disallowed_additional_property,
'null at `/data/type` is not a string',
'object at `/data/attributes` is missing required properties: email'
)
Expand Down

0 comments on commit 7b5876c

Please sign in to comment.