Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade swagger codegen to version 2.4.27 #2

Merged
merged 7 commits into from
Jun 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 12 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,18 @@
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<swagger-codegen-version>2.4.19</swagger-codegen-version>
<swagger-codegen-version>2.4.27</swagger-codegen-version>
<maven-plugin-version>1.0.0</maven-plugin-version>
<junit-version>4.8.1</junit-version>
<junit-version>4.13.1</junit-version>
</properties>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
</repositories>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/ruby-client/base_object.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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) })
Expand Down
8 changes: 5 additions & 3 deletions src/main/resources/ruby-client/client.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require 'json'
require 'logger'
require 'tempfile'
require 'typhoeus'
require 'uri'
require 'addressable/uri'

module {{moduleName}}
module API
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions src/main/resources/ruby-client/client_spec.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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<Integer>" do
client = {{moduleName}}::API::Client.new
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/ruby-client/configuration.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{{> api_info}}
=end

require 'uri'
require 'addressable/uri'

module {{moduleName}}
module API
Expand Down Expand Up @@ -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).
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/ruby-client/gemspec.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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