Class: OpenapiFirst::ResponseParser
- Inherits:
-
Object
- Object
- OpenapiFirst::ResponseParser
- Defined in:
- lib/openapi_first/response_parser.rb
Overview
Parse a response
Instance Method Summary collapse
-
#initialize(headers:, content_type:) ⇒ ResponseParser
constructor
A new instance of ResponseParser.
- #parse(rack_response) ⇒ Object
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 |