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

@@ -158,6 +158,17 @@ module Rswag
end
end
context "'formData' parameter" do
before do
api_metadata[:operation][:parameters] << { name: 'comment', in: :formData, type: 'string' }
allow(example).to receive(:comment).and_return('Some comment')
end
it 'returns the example value as a hash' do
expect(body).to eq({"comment" => "Some comment"})
end
end
context "referenced 'body' parameter" do
before do
api_metadata[:operation][:parameters] << { '$ref' => '#/parameters/comment' }
@@ -171,6 +182,20 @@ module Rswag
expect(body).to eq("{\"text\":\"Some comment\"}")
end
end
context "referenced 'formData' parameter" do
before do
api_metadata[:operation][:parameters] << { '$ref' => '#/parameters/comment' }
global_metadata[:parameters] = {
'comment' => { name: 'comment', in: :formData, type: 'string' }
}
allow(example).to receive(:comment).and_return('Some comment')
end
it 'returns the example value as a json string' do
expect(body).to eq({"comment" => "Some comment"})
end
end
end
describe '#build_headers' do