Class: OpenapiFirst::ResponseValidator
- Inherits:
-
Object
- Object
- OpenapiFirst::ResponseValidator
- 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
- #call(parsed_response) ⇒ Object
-
#initialize(content_schema:, headers:) ⇒ ResponseValidator
constructor
A new instance of ResponseValidator.
Constructor Details
#initialize(content_schema:, headers:) ⇒ ResponseValidator
Returns a new instance of ResponseValidator.
14 15 16 17 18 |
# File 'lib/openapi_first/response_validator.rb', line 14 def initialize(content_schema:, headers:) @validators = [] @validators << Validators::ResponseBody.new(content_schema) if content_schema @validators << Validators::ResponseHeaders.new(headers) if headers&.any? 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 |