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

[RUBY] Replace deprecated URI.encode to support ruby 2.7 without warnings #10445

Merged
merged 4 commits into from
Sep 2, 2020
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
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}}
class ApiClient
Expand Down Expand Up @@ -55,7 +55,7 @@ module {{moduleName}}
:message => response.return_message)
else
fail ApiError.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 @@ -260,7 +260,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
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}}
class Configuration
Expand Down Expand Up @@ -167,7 +167,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
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ 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'

s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0'
s.add_development_dependency 'vcr', '~> 3.0', '>= 3.0.1'
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/ruby/.swagger-codegen/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.4.3-SNAPSHOT
2.4.16-SNAPSHOT
4 changes: 2 additions & 2 deletions samples/client/petstore/ruby/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,11 @@ Class | Method | HTTP request | Description
- [Petstore::ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
- [Petstore::ArrayTest](docs/ArrayTest.md)
- [Petstore::Capitalization](docs/Capitalization.md)
- [Petstore::Cat](docs/Cat.md)
- [Petstore::Category](docs/Category.md)
- [Petstore::ClassModel](docs/ClassModel.md)
- [Petstore::Client](docs/Client.md)
- [Petstore::Dog](docs/Dog.md)
- [Petstore::EnumArrays](docs/EnumArrays.md)
- [Petstore::EnumClass](docs/EnumClass.md)
- [Petstore::EnumTest](docs/EnumTest.md)
Expand All @@ -145,8 +147,6 @@ Class | Method | HTTP request | Description
- [Petstore::SpecialModelName](docs/SpecialModelName.md)
- [Petstore::Tag](docs/Tag.md)
- [Petstore::User](docs/User.md)
- [Petstore::Cat](docs/Cat.md)
- [Petstore::Dog](docs/Dog.md)


## Documentation for Authorization
Expand Down
6 changes: 3 additions & 3 deletions samples/client/petstore/ruby/lib/petstore.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.4.3-SNAPSHOT
Swagger Codegen version: 2.4.16-SNAPSHOT

=end

Expand All @@ -25,9 +25,11 @@
require 'petstore/models/array_of_number_only'
require 'petstore/models/array_test'
require 'petstore/models/capitalization'
require 'petstore/models/cat'
require 'petstore/models/category'
require 'petstore/models/class_model'
require 'petstore/models/client'
require 'petstore/models/dog'
require 'petstore/models/enum_arrays'
require 'petstore/models/enum_class'
require 'petstore/models/enum_test'
Expand All @@ -51,8 +53,6 @@
require 'petstore/models/special_model_name'
require 'petstore/models/tag'
require 'petstore/models/user'
require 'petstore/models/cat'
require 'petstore/models/dog'

# APIs
require 'petstore/api/another_fake_api'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.4.3-SNAPSHOT
Swagger Codegen version: 2.4.16-SNAPSHOT

=end

Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/ruby/lib/petstore/api/fake_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.4.3-SNAPSHOT
Swagger Codegen version: 2.4.16-SNAPSHOT

=end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.4.3-SNAPSHOT
Swagger Codegen version: 2.4.16-SNAPSHOT

=end

Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/ruby/lib/petstore/api/pet_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.4.3-SNAPSHOT
Swagger Codegen version: 2.4.16-SNAPSHOT

=end

Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/ruby/lib/petstore/api/store_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.4.3-SNAPSHOT
Swagger Codegen version: 2.4.16-SNAPSHOT

=end

Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/ruby/lib/petstore/api/user_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.4.3-SNAPSHOT
Swagger Codegen version: 2.4.16-SNAPSHOT

=end

Expand Down
10 changes: 6 additions & 4 deletions samples/client/petstore/ruby/lib/petstore/api_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.4.3-SNAPSHOT
Swagger Codegen version: 2.4.16-SNAPSHOT

=end

Expand All @@ -15,7 +15,7 @@
require 'logger'
require 'tempfile'
require 'typhoeus'
require 'uri'
require 'addressable/uri'

module Petstore
class ApiClient
Expand Down Expand Up @@ -63,7 +63,7 @@ def call_api(http_method, path, opts = {})
:message => response.return_message)
else
fail ApiError.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 @@ -112,6 +112,8 @@ def build_request(http_method, path, opts = {})
: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 @@ -264,7 +266,7 @@ def sanitize_filename(filename)
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
2 changes: 1 addition & 1 deletion samples/client/petstore/ruby/lib/petstore/api_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.4.3-SNAPSHOT
Swagger Codegen version: 2.4.16-SNAPSHOT

=end

Expand Down
6 changes: 3 additions & 3 deletions samples/client/petstore/ruby/lib/petstore/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.4.3-SNAPSHOT
Swagger Codegen version: 2.4.16-SNAPSHOT

=end

require 'uri'
require 'addressable/uri'

module Petstore
class Configuration
Expand Down Expand Up @@ -175,7 +175,7 @@ def base_path=(base_path)

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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.4.3-SNAPSHOT
Swagger Codegen version: 2.4.16-SNAPSHOT

=end

Expand Down Expand Up @@ -192,5 +192,6 @@ def _to_hash(value)
value
end
end

end
end
3 changes: 2 additions & 1 deletion samples/client/petstore/ruby/lib/petstore/models/animal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.4.3-SNAPSHOT
Swagger Codegen version: 2.4.16-SNAPSHOT

=end

Expand Down Expand Up @@ -195,5 +195,6 @@ def _to_hash(value)
value
end
end

end
end
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.4.3-SNAPSHOT
Swagger Codegen version: 2.4.16-SNAPSHOT

=end

Expand Down Expand Up @@ -170,5 +170,6 @@ def _to_hash(value)
value
end
end

end
end
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.4.3-SNAPSHOT
Swagger Codegen version: 2.4.16-SNAPSHOT

=end

Expand Down Expand Up @@ -197,5 +197,6 @@ def _to_hash(value)
value
end
end

end
end
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.4.3-SNAPSHOT
Swagger Codegen version: 2.4.16-SNAPSHOT

=end

Expand Down Expand Up @@ -181,5 +181,6 @@ def _to_hash(value)
value
end
end

end
end
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.4.3-SNAPSHOT
Swagger Codegen version: 2.4.16-SNAPSHOT

=end

Expand Down Expand Up @@ -181,5 +181,6 @@ def _to_hash(value)
value
end
end

end
end
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.4.3-SNAPSHOT
Swagger Codegen version: 2.4.16-SNAPSHOT

=end

Expand Down Expand Up @@ -203,5 +203,6 @@ def _to_hash(value)
value
end
end

end
end
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.4.3-SNAPSHOT
Swagger Codegen version: 2.4.16-SNAPSHOT

=end

Expand Down Expand Up @@ -225,5 +225,6 @@ def _to_hash(value)
value
end
end

end
end
3 changes: 2 additions & 1 deletion samples/client/petstore/ruby/lib/petstore/models/cat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.4.3-SNAPSHOT
Swagger Codegen version: 2.4.16-SNAPSHOT

=end

Expand Down Expand Up @@ -204,5 +204,6 @@ def _to_hash(value)
value
end
end

end
end
3 changes: 2 additions & 1 deletion samples/client/petstore/ruby/lib/petstore/models/category.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.4.3-SNAPSHOT
Swagger Codegen version: 2.4.16-SNAPSHOT

=end

Expand Down Expand Up @@ -188,5 +188,6 @@ def _to_hash(value)
value
end
end

end
end
Loading