add formData support

This commit is contained in:
ali.q
2017-04-15 01:34:05 +04:30
committed by ali
parent 25d8adaf8b
commit 182ee093f4
12 changed files with 154 additions and 18 deletions

View File

@@ -27,6 +27,7 @@ module Rswag
end
def build_body(example)
return build_form_data(example) if parameters_in(:formData).present?
body_parameter = parameters_in(:body).first
body_parameter.nil? ? '' : example.send(body_parameter[:name]).to_json
end
@@ -93,6 +94,10 @@ module Rswag
"#{name}=#{value.join(',')}" # csv is default
end
end
def build_form_data(example)
Hash[parameters_in(:formData).map { |p| [p[:name][/^\w+[^\[]/, 0], example.send(p[:name][/^\w+[^\[]/, 0])] }]
end
end
end
end