Class: OpenapiFirst::Validators::ResponseHeaders
- Inherits:
-
Object
- Object
- OpenapiFirst::Validators::ResponseHeaders
- Defined in:
- lib/openapi_first/validators/response_headers.rb
Instance Attribute Summary collapse
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
Class Method Summary collapse
Instance Method Summary collapse
- #call(parsed_request) ⇒ Object
-
#initialize(schema) ⇒ ResponseHeaders
constructor
A new instance of ResponseHeaders.
Constructor Details
#initialize(schema) ⇒ ResponseHeaders
Returns a new instance of ResponseHeaders.
13 14 15 |
# File 'lib/openapi_first/validators/response_headers.rb', line 13 def initialize(schema) @schema = schema end |
Instance Attribute Details
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
17 18 19 |
# File 'lib/openapi_first/validators/response_headers.rb', line 17 def schema @schema end |
Class Method Details
.for(response_definition) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/openapi_first/validators/response_headers.rb', line 6 def self.for(response_definition) schema = response_definition&.headers_schema return unless schema&.value new(schema) end |
Instance Method Details
#call(parsed_request) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/openapi_first/validators/response_headers.rb', line 19 def call(parsed_request) validation = Schema::ValidationResult.new( schema.validate(parsed_request.headers) ) Failure.fail!(:invalid_response_header, errors: validation.errors) if validation.error? end |