Class: OpenapiFirst::RuntimeResponse

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

Instance Method Summary collapse

Constructor Details

#initialize(operation, rack_response) ⇒ RuntimeResponse

Returns a new instance of RuntimeResponse.



7
8
9
10
# File 'lib/openapi_first/runtime_response.rb', line 7

def initialize(operation, rack_response)
  @operation = operation
  @rack_response = rack_response
end

Instance Method Details

#descriptionObject



12
13
14
# File 'lib/openapi_first/runtime_response.rb', line 12

def description
  response_definition&.description
end

#validateObject



16
17
18
# File 'lib/openapi_first/runtime_response.rb', line 16

def validate
  ResponseValidation::Validator.new(@operation).validate(@rack_response)
end

#validate!Object



20
21
22
23
# File 'lib/openapi_first/runtime_response.rb', line 20

def validate!
  error = validate
  error&.raise!
end