Class: OpenapiFirst::ValidatedResponse

Inherits:
SimpleDelegator
  • Object
show all
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

Instance Method Summary collapse

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

#errorObject (readonly)

Returns the value of attribute error.



18
19
20
# File 'lib/openapi_first/validated_response.rb', line 18

def error
  @error
end

#parsed_valuesObject (readonly)

Returns the value of attribute parsed_values.



18
19
20
# File 'lib/openapi_first/validated_response.rb', line 18

def parsed_values
  @parsed_values
end

#response_definitionObject (readonly)

Returns the value of attribute response_definition.



18
19
20
# File 'lib/openapi_first/validated_response.rb', line 18

def response_definition
  @response_definition
end

Instance Method Details

#invalid?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/openapi_first/validated_response.rb', line 29

def invalid?
  !valid?
end

#valid?Boolean

Checks if the response is valid.

Returns:

  • (Boolean)

    true if the response is valid, false otherwise.



25
26
27
# File 'lib/openapi_first/validated_response.rb', line 25

def valid?
  error.nil?
end