diff --git a/Dockerfile b/Dockerfile index d9fb036..8cdb98c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,7 @@ COPY . ${APP_DIR} RUN mvn clean package -FROM swaggerapi/swagger-codegen-cli:2.4.5 +FROM swaggerapi/swagger-codegen-cli:2.4.27 # Setup environment ENV APP_DIR /usr/src/app diff --git a/pom.xml b/pom.xml index 85bf365..1a48963 100644 --- a/pom.xml +++ b/pom.xml @@ -118,8 +118,18 @@ UTF-8 - 2.4.19 + 2.4.27 1.0.0 - 4.8.1 + 4.13.1 + + + + false + + central + Central Repository + https://repo.maven.apache.org/maven2 + + diff --git a/src/main/java/uk/co/wimit/codegen/languages/RubyClientGenerator.java b/src/main/java/uk/co/wimit/codegen/languages/RubyClientGenerator.java index e8a2e71..14cd376 100644 --- a/src/main/java/uk/co/wimit/codegen/languages/RubyClientGenerator.java +++ b/src/main/java/uk/co/wimit/codegen/languages/RubyClientGenerator.java @@ -582,7 +582,7 @@ public String toEnumVarName(String name, String datatype) { varName = varName.replaceAll("-", "MINUS_"); varName = varName.replaceAll("\\+", "PLUS_"); varName = varName.replaceAll("\\.", "_DOT_"); - return varName; + return "N" + varName; } // string diff --git a/src/main/resources/ruby-client/base_object.mustache b/src/main/resources/ruby-client/base_object.mustache index 7818e2f..b14ae7e 100644 --- a/src/main/resources/ruby-client/base_object.mustache +++ b/src/main/resources/ruby-client/base_object.mustache @@ -6,7 +6,7 @@ self.class.swagger_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the the attribute + # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) diff --git a/src/main/resources/ruby-client/client.mustache b/src/main/resources/ruby-client/client.mustache index 8dbccfd..7159d7a 100644 --- a/src/main/resources/ruby-client/client.mustache +++ b/src/main/resources/ruby-client/client.mustache @@ -7,7 +7,7 @@ require 'json' require 'logger' require 'tempfile' require 'typhoeus' -require 'uri' +require 'addressable/uri' module {{moduleName}} module API @@ -56,7 +56,7 @@ module {{moduleName}} :message => response.return_message) else fail API::Error.new(:code => response.code, - :response_headers => response.headers, + :response_headers => response.headers.to_h, :response_body => response.body), response.status_message end @@ -107,6 +107,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 @@ -262,7 +264,7 @@ module {{moduleName}} def build_request_url(path) # Add leading and trailing slashes to path path = "/#{path}".gsub(/\/+/, '/') - URI.encode(@config.base_url + path) + Addressable::URI.encode(@config.base_url + path) end # Builds the HTTP request body diff --git a/src/main/resources/ruby-client/client_spec.mustache b/src/main/resources/ruby-client/client_spec.mustache index ef005d8..6ac38d3 100644 --- a/src/main/resources/ruby-client/client_spec.mustache +++ b/src/main/resources/ruby-client/client_spec.mustache @@ -81,6 +81,23 @@ RSpec.describe {{moduleName}}::API::Client do end end + describe '#build_request' do + let(:config) { {{moduleName}}::API::Configuration.new } + let(:client) { {{moduleName}}::API::Client.new(config) } + + it 'does not send multipart to request' do + expect(Typhoeus::Request).to receive(:new).with(anything, hash_not_including(:multipart)) + 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)) + client.build_request(:get, '/test', header_params: { 'Content-Type' => 'multipart/form-data' }) + end + end + end + describe '#deserialize' do it "handles Array" do client = {{moduleName}}::API::Client.new diff --git a/src/main/resources/ruby-client/configuration.mustache b/src/main/resources/ruby-client/configuration.mustache index 0cd5a2f..8cf6b18 100644 --- a/src/main/resources/ruby-client/configuration.mustache +++ b/src/main/resources/ruby-client/configuration.mustache @@ -2,7 +2,7 @@ {{> api_info}} =end -require 'uri' +require 'addressable/uri' module {{moduleName}} module API @@ -168,7 +168,7 @@ module {{moduleName}} def base_url url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') - URI.encode(url) + Addressable::URI.encode(url) end # Gets API key (with prefix if set). diff --git a/src/main/resources/ruby-client/gemspec.mustache b/src/main/resources/ruby-client/gemspec.mustache index 7f4e45b..8385491 100644 --- a/src/main/resources/ruby-client/gemspec.mustache +++ b/src/main/resources/ruby-client/gemspec.mustache @@ -31,4 +31,5 @@ Gem::Specification.new do |s| s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1' s.add_runtime_dependency 'json', '~> 2.1', '>= 2.1.0' + s.add_runtime_dependency 'addressable', '~> 2.3', '>= 2.3.0' end