Class: OpenapiFirst::ValidatedResponse
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- OpenapiFirst::ValidatedResponse
- Extended by:
- Forwardable
- Defined in:
- lib/openapi_first/validated_response.rb
Overview
A validated response. It can be valid or not.
Instance Attribute Summary collapse
-
#error ⇒ Failure?
readonly
A Failure object if the response is invalid.
-
#response_definition ⇒ Response?
readonly
The response definition if this response is defined in the API description.
Instance Method Summary collapse
-
#initialize(original_response, error:, parsed_values: nil, response_definition: nil) ⇒ ValidatedResponse
constructor
A new instance of ValidatedResponse.
-
#invalid? ⇒ Boolean
Checks if the response is invalid.
-
#parsed_body ⇒ Hash<String,anything>
The parsed body.
-
#parsed_headers ⇒ Hash<String,anything>
The parsed headers.
-
#valid? ⇒ Boolean
Checks if the response is valid.
Constructor Details
#initialize(original_response, error:, parsed_values: nil, response_definition: nil) ⇒ ValidatedResponse
Returns a new instance of ValidatedResponse.
11 12 13 14 15 16 |
# File 'lib/openapi_first/validated_response.rb', line 11 def initialize(original_response, error:, parsed_values: nil, response_definition: nil) super(original_response) @error = error @parsed_values = parsed_values @response_definition = response_definition end |
Instance Attribute Details
#error ⇒ Failure? (readonly)
A Failure object if the response is invalid
20 21 22 |
# File 'lib/openapi_first/validated_response.rb', line 20 def error @error end |
#response_definition ⇒ Response? (readonly)
The response definition if this response is defined in the API description
24 25 26 |
# File 'lib/openapi_first/validated_response.rb', line 24 def response_definition @response_definition end |
Instance Method Details
#invalid? ⇒ Boolean
Checks if the response is invalid.
44 45 46 |
# File 'lib/openapi_first/validated_response.rb', line 44 def invalid? !valid? end |
#parsed_body ⇒ Hash<String,anything>
The parsed body
34 |
# File 'lib/openapi_first/validated_response.rb', line 34 def_delegator :@parsed_values, :body, :parsed_body |
#parsed_headers ⇒ Hash<String,anything>
The parsed headers
29 |
# File 'lib/openapi_first/validated_response.rb', line 29 def_delegator :@parsed_values, :headers, :parsed_headers |
#valid? ⇒ Boolean
Checks if the response is valid.
38 39 40 |
# File 'lib/openapi_first/validated_response.rb', line 38 def valid? error.nil? end |