Class: OpenapiFirst::ResponseParser

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

Overview

Parse a response

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(headers:, content_type:) ⇒ ResponseParser

Returns a new instance of ResponseParser.



8
9
10
11
# File 'lib/openapi_first/response_parser.rb', line 8

def initialize(headers:, content_type:)
  @headers = headers
  @content_type = content_type
end

Instance Attribute Details

#content_typeObject (readonly)

Returns the value of attribute content_type.



13
14
15
# File 'lib/openapi_first/response_parser.rb', line 13

def content_type
  @content_type
end

#headersObject (readonly)

Returns the value of attribute headers.



13
14
15
# File 'lib/openapi_first/response_parser.rb', line 13

def headers
  @headers
end

Instance Method Details

#parse(rack_response) ⇒ Object



15
16
17
18
19
20
# File 'lib/openapi_first/response_parser.rb', line 15

def parse(rack_response)
  ParsedResponse.new(
    body: parse_body(rack_response),
    headers: parse_headers(rack_response)
  )
end