lib/rspec_api_docs/formatter/resource/example.rb in rspec-api-docs-0.14.0 vs lib/rspec_api_docs/formatter/resource/example.rb in rspec-api-docs-1.0.0
- old
+ new
@@ -60,11 +60,11 @@
request_headers: request_headers(request.env),
request_query_parameters: request.params,
request_content_type: request.content_type,
response_status: response.status,
response_status_text: response_status_text(response.status),
- response_body: response_body(response.body),
+ response_body: response_body(response.body, content_type: response.content_type),
response_headers: response_headers(response.headers),
response_content_type: response.content_type,
}
end
end
@@ -130,11 +130,11 @@
body_content = body.read
body.rewind if body.respond_to?(:rewind)
body_content.empty? ? nil : body_content
end
- def response_body(body)
- unless body.empty?
+ def response_body(body, content_type:)
+ unless body.empty? || content_type != 'application/json'
parsed_body = JSON.parse(body, symbolize_names: true)
response_fields.each do |f|
unless f.example.nil?
DeepHashSet.call(parsed_body, f.scope + [f.name], f.example)
end