Skip to content

Commit f8ccd47

Browse files
Merge pull request #10 from department-of-veterans-affairs/sjc-ruby-3-json-schema-4.1.1
drop rails 4 support, upgrade json-schema, Ruby 3 compatibility
2 parents 5f40ee0 + 8bcbd40 commit f8ccd47

File tree

9 files changed

+27
-67
lines changed

9 files changed

+27
-67
lines changed

.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.7.3
1+
3.2.2

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,17 @@
33
## About
44

55
The repo is a fork of [apivore 1.6.2](https://github.com/westfieldlabs/apivore/tree/0ccda01d79c8760a6efa2df38b68d58832e47665) for use with [vets-api](https://github.com/department-of-veterans-affairs/vets-api). `apivore` is [no longer being maintained](https://github.com/westfieldlabs/apivore/issues/121) and is incompatible with Rails 6. The code here has been changed to remove that restriction.
6+
7+
### Version Compatibility
8+
9+
- Ruby 3
10+
- Rails 5+
11+
12+
Tested with Ruby 3.2.2
13+
14+
## CHANGELOG
15+
16+
### v2.0.0
17+
- Drop support for Rails 4
18+
- Upgraded json-schema version to 4+
19+
- Ruby 3 compatible

apivore.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
1616

1717
s.add_runtime_dependency 'actionpack', '>= 4'
1818
s.add_runtime_dependency 'hashie', '~> 5.0'
19-
s.add_runtime_dependency 'json-schema', '~> 3.0'
19+
s.add_runtime_dependency 'json-schema', '~> 4.0'
2020
s.add_runtime_dependency 'rspec', '~> 3'
2121
s.add_runtime_dependency 'rspec-expectations', '~> 3.1'
2222
s.add_runtime_dependency 'rspec-mocks', '~> 3.1'

lib/apivore/rails_shim.rb

Lines changed: 0 additions & 13 deletions
This file was deleted.

lib/apivore/swagger.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ class Swagger < Hashie::Mash
77
NONVERB_PATH_ITEMS = %q(parameters)
88

99
def validate
10-
case version
10+
case openapi_version
1111
when '2.0'
1212
schema = File.read(File.expand_path("../../../data/swagger_2.0_schema.json", __FILE__))
1313
else
14-
raise "Unknown/unsupported Swagger version to validate against: #{version}"
14+
raise "Unknown/unsupported Swagger version to validate against: #{openapi_version}"
1515
end
1616
JSON::Validator.fully_validate(schema, self)
1717
end
1818

19-
def version
19+
def openapi_version
2020
swagger
2121
end
2222

lib/apivore/validator.rb

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
require 'action_controller'
22
require 'action_dispatch'
3-
require 'apivore/rails_shim'
43

54
module Apivore
65
class Validator
@@ -19,14 +18,11 @@ def matches?(swagger_checker)
1918
pre_checks(swagger_checker)
2019

2120
unless has_errors?
22-
send(
23-
method,
24-
*RailsShim.action_dispatch_request_args(
25-
full_path(swagger_checker),
26-
params: params['_data'] || {},
27-
headers: params['_headers'] || {}
28-
)
29-
)
21+
data = params['_data'] || {}
22+
headers = params['_headers'] || {}
23+
24+
send(method, full_path(swagger_checker), params: data, headers: headers)
25+
3026
swagger_checker.response = response
3127
post_checks(swagger_checker)
3228

lib/apivore/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
module Apivore
44
# Forked from https://rubygems.org/gems/apivore at 1.6.2
5-
VERSION = '1.6.2.1.vsp'
5+
VERSION = '2.0.0.vsp'
66
end

spec/apivore_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88

99
subject { swagger }
1010
it { should be_an_instance_of(Apivore::Swagger) }
11-
it { should respond_to(:version) }
11+
it { should respond_to(:openapi_version) }
1212
it { should respond_to(:validate) }
1313
it { should respond_to(:each_response) }
1414
it { should respond_to(:base_path) }
1515

1616
describe 'swagger version' do
17-
subject { swagger.version }
17+
subject { swagger.openapi_version }
1818
it { should == '2.0' }
1919
end
2020

spec/rails_shim_spec.rb

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)