Skip to content

Commit 73a9382

Browse files
committed
Flag request multipart according to content-type
1 parent 5a9f449 commit 73a9382

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

modules/swagger-codegen/src/main/resources/ruby/api_client.mustache

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ module {{moduleName}}
106106
:verbose => @config.debugging
107107
}
108108

109+
req_opts.merge!(multipart: true) if header_params['Content-Type'].start_with? "multipart/"
110+
109111
# set custom cert, if provided
110112
req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert
111113

modules/swagger-codegen/src/main/resources/ruby/api_client_spec.mustache

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,23 @@ describe {{moduleName}}::ApiClient do
8181
end
8282
end
8383

84+
describe '#build_request' do
85+
let(:config) { {{moduleName}}::Configuration.new }
86+
let(:api_client) { {{moduleName}}::ApiClient.new(config) }
87+
88+
it 'does not send multipart to request' do
89+
expect(Typhoeus::Request).to receive(:new).with(anything, hash_not_including(:multipart))
90+
api_client.build_request(:get, '/test')
91+
end
92+
93+
context 'when the content type is multipart' do
94+
it 'sends multipart to request' do
95+
expect(Typhoeus::Request).to receive(:new).with(anything, hash_including(multipart: true))
96+
api_client.build_request(:get, '/test', {header_params: { 'Content-Type' => 'multipart/form-data'}})
97+
end
98+
end
99+
end
100+
84101
describe '#deserialize' do
85102
it "handles Array<Integer>" do
86103
api_client = {{moduleName}}::ApiClient.new

0 commit comments

Comments
 (0)