Class: OpenapiFirst::ResponseParser

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

Overview

Parse a response

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
  @json = /json/i.match?(content_type)
end

Instance Method Details

#parse(rack_response) ⇒ Object



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

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