Skip to content

Commit 6d4b48a

Browse files
author
BAASH 05
committed
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.
1 parent fbea2a0 commit 6d4b48a

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

lib/rspec_api_documentation/dsl/endpoint.rb

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,21 @@ def do_request(extra_params = {})
3838
if method == :get && !query_string.blank?
3939
path_or_query += "?#{query_string}"
4040
else
41-
formatter = RspecApiDocumentation.configuration.post_body_formatter
42-
case formatter
43-
when :json
44-
params_or_body = params.to_json
45-
when :xml
46-
params_or_body = params.to_xml
47-
when Proc
48-
params_or_body = formatter.call(params)
41+
if respond_to?(:raw_post)
42+
params_or_body = raw_post
4943
else
50-
params_or_body = params
44+
formatter = RspecApiDocumentation.configuration.post_body_formatter
45+
case formatter
46+
when :json
47+
params_or_body = params.to_json
48+
when :xml
49+
params_or_body = params.to_xml
50+
when Proc
51+
params_or_body = formatter.call(params)
52+
else
53+
params_or_body = params
54+
end
5155
end
52-
53-
params_or_body = respond_to?(:raw_post) ? raw_post : params_or_body
5456
end
5557

5658
rspec_api_documentation_client.send(method, path_or_query, params_or_body, headers)

0 commit comments

Comments
 (0)