diff --git a/modules/swagger-codegen/src/main/resources/ruby/api_client.mustache b/modules/swagger-codegen/src/main/resources/ruby/api_client.mustache index c7a23c0243c..840d2f2850a 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/api_client.mustache @@ -106,6 +106,8 @@ module {{moduleName}} :verbose => @config.debugging } + req_opts.merge!(multipart: true) if header_params['Content-Type'].start_with? "multipart/" + # set custom cert, if provided req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert diff --git a/modules/swagger-codegen/src/main/resources/ruby/api_client_spec.mustache b/modules/swagger-codegen/src/main/resources/ruby/api_client_spec.mustache index b887b92f31a..4291fc60509 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/api_client_spec.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/api_client_spec.mustache @@ -81,6 +81,23 @@ describe {{moduleName}}::ApiClient do end end + describe '#build_request' do + let(:config) { {{moduleName}}::Configuration.new } + let(:api_client) { {{moduleName}}::ApiClient.new(config) } + + it 'does not send multipart to request' do + expect(Typhoeus::Request).to receive(:new).with(anything, hash_not_including(:multipart)) + api_client.build_request(:get, '/test') + end + + context 'when the content type is multipart' do + it 'sends multipart to request' do + expect(Typhoeus::Request).to receive(:new).with(anything, hash_including(multipart: true)) + api_client.build_request(:get, '/test', {header_params: { 'Content-Type' => 'multipart/form-data'}}) + end + end + end + describe '#deserialize' do it "handles Array" do api_client = {{moduleName}}::ApiClient.new