Merge branch 'add-formData-support' of https://github.com/thg303/rswag into thg303-add-formData-support

This commit is contained in:
domaindrivendev
2017-07-21 14:25:29 -07:00
12 changed files with 125 additions and 27 deletions

View File

@@ -138,15 +138,21 @@ module Rswag
end
end
def build_form_payload(parameters, example)
#See http://seejohncode.com/2012/04/29/quick-tip-testing-multipart-uploads-with-rspec/
# Rather that serializing with the appropriate encoding (e.g. multipart/form-data),
# Rails test infrastructure allows us to send the values directly as a hash
# PROS: simple to implement, CONS: serialization/deserialization is bypassed in test
tuples = parameters
.select { |p| p[:in] == :formData }
.map { |p| [ p[:name], example.send(p[:name]) ] }
Hash[ tuples ]
end
def build_json_payload(parameters, example)
body_param = parameters.select { |p| p[:in] == :body }.first
body_param ? example.send(body_param[:name]).to_json : nil
end
def build_form_payload(parameters, example)
nil
# TODO:
end
end
end
end