Class: OpenapiFirst::ResponseValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/openapi_first/response_validator.rb

Overview

Entry point for response validators

Constant Summary collapse

VALIDATORS =
[
  Validators::ResponseHeaders,
  Validators::ResponseBody
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(response_definition, openapi_version:) ⇒ ResponseValidator

Returns a new instance of ResponseValidator.



14
15
16
17
18
# File 'lib/openapi_first/response_validator.rb', line 14

def initialize(response_definition, openapi_version:)
  @validators = VALIDATORS.filter_map do |klass|
    klass.for(response_definition, openapi_version:)
  end
end

Instance Method Details

#call(parsed_response) ⇒ Object



20
21
22
23
24
25
# File 'lib/openapi_first/response_validator.rb', line 20

def call(parsed_response)
  catch FAILURE do
    @validators.each { |v| v.call(parsed_response) }
    nil
  end
end