From 6d4b48a5f66329ecaa14448bf1acd5766f339510 Mon Sep 17 00:00:00 2001 From: BAASH 05 Date: Wed, 20 Aug 2014 11:03:39 +1000 Subject: [PATCH] Update endpoint.rb If the raw_post is stipulated don't calculate the params. I did this because when I want the default posts to be JSON, setting the config makes sense. When I set the config and want to override it (for attachments) then I need the formatting bit of code to not be called because converting the attachment to JSON didn't work. --- lib/rspec_api_documentation/dsl/endpoint.rb | 24 +++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/rspec_api_documentation/dsl/endpoint.rb b/lib/rspec_api_documentation/dsl/endpoint.rb index 319363b1..64f939ee 100644 --- a/lib/rspec_api_documentation/dsl/endpoint.rb +++ b/lib/rspec_api_documentation/dsl/endpoint.rb @@ -38,19 +38,21 @@ def do_request(extra_params = {}) if method == :get && !query_string.blank? path_or_query += "?#{query_string}" else - formatter = RspecApiDocumentation.configuration.post_body_formatter - case formatter - when :json - params_or_body = params.to_json - when :xml - params_or_body = params.to_xml - when Proc - params_or_body = formatter.call(params) + if respond_to?(:raw_post) + params_or_body = raw_post else - params_or_body = params + formatter = RspecApiDocumentation.configuration.post_body_formatter + case formatter + when :json + params_or_body = params.to_json + when :xml + params_or_body = params.to_xml + when Proc + params_or_body = formatter.call(params) + else + params_or_body = params + end end - - params_or_body = respond_to?(:raw_post) ? raw_post : params_or_body end rspec_api_documentation_client.send(method, path_or_query, params_or_body, headers)