mirror of
https://github.com/ditkrg/rswag.git
synced 2026-01-25 15:22:56 +00:00
add formData support
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user