Skip to content

Commit

Permalink
Ruby 3 KwArgs: Monkeypatch ApiVore (#12003)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericboehs authored Mar 7, 2023
1 parent 085a6ef commit 37bbfd0
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions config/initializers/apivore_validator_monkeypatch.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# frozen_string_literal: true

module Apivore
class Validator
def matches?(swagger_checker)
pre_checks(swagger_checker)

unless has_errors?
args = RailsShim.action_dispatch_request_args(
full_path(swagger_checker),
params: params['_data'] || {},
headers: params['_headers'] || {}
)
send(method, args[0], **args[1])
swagger_checker.response = response
post_checks(swagger_checker)

if has_errors? && response.body.length.positive?
errors << "\nResponse body:\n #{JSON.pretty_generate(JSON.parse(response.body))}"
end

swagger_checker.remove_tested_end_point_response(
path, method, expected_response_code
)
end

!has_errors?
end
end
end

0 comments on commit 37bbfd0

Please sign in to comment.