Skip to content

Ruby client: escape path parameters #3039

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

Merged
merged 2 commits into from
Jun 2, 2019
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 @@ -3,6 +3,7 @@
=end

require 'uri'
require 'cgi'

module {{moduleName}}
{{#operations}}
Expand Down Expand Up @@ -123,7 +124,7 @@ module {{moduleName}}
{{/hasValidation}}
{{/allParams}}
# resource path
local_var_path = '{{{path}}}'{{#pathParams}}.sub('{' + '{{baseName}}' + '}', {{paramName}}.to_s){{/pathParams}}
local_var_path = '{{{path}}}'{{#pathParams}}.sub('{' + '{{baseName}}' + '}', CGI.escape({{paramName}}.to_s)){{/pathParams}}

# query parameters
query_params = opts[:query_params] || {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
=end

require 'uri'
require 'cgi'

module Petstore
class AnotherFakeApi
Expand Down
1 change: 1 addition & 0 deletions samples/client/petstore/ruby/lib/petstore/api/fake_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
=end

require 'uri'
require 'cgi'

module Petstore
class FakeApi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
=end

require 'uri'
require 'cgi'

module Petstore
class FakeClassnameTags123Api
Expand Down
11 changes: 6 additions & 5 deletions samples/client/petstore/ruby/lib/petstore/api/pet_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
=end

require 'uri'
require 'cgi'

module Petstore
class PetApi
Expand Down Expand Up @@ -103,7 +104,7 @@ def delete_pet_with_http_info(pet_id, opts = {})
fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.delete_pet"
end
# resource path
local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', pet_id.to_s)
local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down Expand Up @@ -290,7 +291,7 @@ def get_pet_by_id_with_http_info(pet_id, opts = {})
fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.get_pet_by_id"
end
# resource path
local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', pet_id.to_s)
local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down Expand Up @@ -414,7 +415,7 @@ def update_pet_with_form_with_http_info(pet_id, opts = {})
fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.update_pet_with_form"
end
# resource path
local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', pet_id.to_s)
local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down Expand Up @@ -480,7 +481,7 @@ def upload_file_with_http_info(pet_id, opts = {})
fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.upload_file"
end
# resource path
local_var_path = '/pet/{petId}/uploadImage'.sub('{' + 'petId' + '}', pet_id.to_s)
local_var_path = '/pet/{petId}/uploadImage'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down Expand Up @@ -552,7 +553,7 @@ def upload_file_with_required_file_with_http_info(pet_id, required_file, opts =
fail ArgumentError, "Missing the required parameter 'required_file' when calling PetApi.upload_file_with_required_file"
end
# resource path
local_var_path = '/fake/{petId}/uploadImageWithRequiredFile'.sub('{' + 'petId' + '}', pet_id.to_s)
local_var_path = '/fake/{petId}/uploadImageWithRequiredFile'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down
5 changes: 3 additions & 2 deletions samples/client/petstore/ruby/lib/petstore/api/store_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
=end

require 'uri'
require 'cgi'

module Petstore
class StoreApi
Expand Down Expand Up @@ -43,7 +44,7 @@ def delete_order_with_http_info(order_id, opts = {})
fail ArgumentError, "Missing the required parameter 'order_id' when calling StoreApi.delete_order"
end
# resource path
local_var_path = '/store/order/{order_id}'.sub('{' + 'order_id' + '}', order_id.to_s)
local_var_path = '/store/order/{order_id}'.sub('{' + 'order_id' + '}', CGI.escape(order_id.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down Expand Up @@ -167,7 +168,7 @@ def get_order_by_id_with_http_info(order_id, opts = {})
end

# resource path
local_var_path = '/store/order/{order_id}'.sub('{' + 'order_id' + '}', order_id.to_s)
local_var_path = '/store/order/{order_id}'.sub('{' + 'order_id' + '}', CGI.escape(order_id.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down
7 changes: 4 additions & 3 deletions samples/client/petstore/ruby/lib/petstore/api/user_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
=end

require 'uri'
require 'cgi'

module Petstore
class UserApi
Expand Down Expand Up @@ -219,7 +220,7 @@ def delete_user_with_http_info(username, opts = {})
fail ArgumentError, "Missing the required parameter 'username' when calling UserApi.delete_user"
end
# resource path
local_var_path = '/user/{username}'.sub('{' + 'username' + '}', username.to_s)
local_var_path = '/user/{username}'.sub('{' + 'username' + '}', CGI.escape(username.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down Expand Up @@ -277,7 +278,7 @@ def get_user_by_name_with_http_info(username, opts = {})
fail ArgumentError, "Missing the required parameter 'username' when calling UserApi.get_user_by_name"
end
# resource path
local_var_path = '/user/{username}'.sub('{' + 'username' + '}', username.to_s)
local_var_path = '/user/{username}'.sub('{' + 'username' + '}', CGI.escape(username.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down Expand Up @@ -465,7 +466,7 @@ def update_user_with_http_info(username, body, opts = {})
fail ArgumentError, "Missing the required parameter 'body' when calling UserApi.update_user"
end
# resource path
local_var_path = '/user/{username}'.sub('{' + 'username' + '}', username.to_s)
local_var_path = '/user/{username}'.sub('{' + 'username' + '}', CGI.escape(username.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
=end

require 'uri'
require 'cgi'

module Petstore
class AnotherFakeApi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
=end

require 'uri'
require 'cgi'

module Petstore
class DefaultApi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
=end

require 'uri'
require 'cgi'

module Petstore
class FakeApi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
=end

require 'uri'
require 'cgi'

module Petstore
class FakeClassnameTags123Api
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
=end

require 'uri'
require 'cgi'

module Petstore
class PetApi
Expand Down Expand Up @@ -103,7 +104,7 @@ def delete_pet_with_http_info(pet_id, opts = {})
fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.delete_pet"
end
# resource path
local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', pet_id.to_s)
local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down Expand Up @@ -290,7 +291,7 @@ def get_pet_by_id_with_http_info(pet_id, opts = {})
fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.get_pet_by_id"
end
# resource path
local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', pet_id.to_s)
local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down Expand Up @@ -414,7 +415,7 @@ def update_pet_with_form_with_http_info(pet_id, opts = {})
fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.update_pet_with_form"
end
# resource path
local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', pet_id.to_s)
local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down Expand Up @@ -480,7 +481,7 @@ def upload_file_with_http_info(pet_id, opts = {})
fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.upload_file"
end
# resource path
local_var_path = '/pet/{petId}/uploadImage'.sub('{' + 'petId' + '}', pet_id.to_s)
local_var_path = '/pet/{petId}/uploadImage'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down Expand Up @@ -552,7 +553,7 @@ def upload_file_with_required_file_with_http_info(pet_id, required_file, opts =
fail ArgumentError, "Missing the required parameter 'required_file' when calling PetApi.upload_file_with_required_file"
end
# resource path
local_var_path = '/fake/{petId}/uploadImageWithRequiredFile'.sub('{' + 'petId' + '}', pet_id.to_s)
local_var_path = '/fake/{petId}/uploadImageWithRequiredFile'.sub('{' + 'petId' + '}', CGI.escape(pet_id.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
=end

require 'uri'
require 'cgi'

module Petstore
class StoreApi
Expand Down Expand Up @@ -43,7 +44,7 @@ def delete_order_with_http_info(order_id, opts = {})
fail ArgumentError, "Missing the required parameter 'order_id' when calling StoreApi.delete_order"
end
# resource path
local_var_path = '/store/order/{order_id}'.sub('{' + 'order_id' + '}', order_id.to_s)
local_var_path = '/store/order/{order_id}'.sub('{' + 'order_id' + '}', CGI.escape(order_id.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down Expand Up @@ -167,7 +168,7 @@ def get_order_by_id_with_http_info(order_id, opts = {})
end

# resource path
local_var_path = '/store/order/{order_id}'.sub('{' + 'order_id' + '}', order_id.to_s)
local_var_path = '/store/order/{order_id}'.sub('{' + 'order_id' + '}', CGI.escape(order_id.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
=end

require 'uri'
require 'cgi'

module Petstore
class UserApi
Expand Down Expand Up @@ -225,7 +226,7 @@ def delete_user_with_http_info(username, opts = {})
fail ArgumentError, "Missing the required parameter 'username' when calling UserApi.delete_user"
end
# resource path
local_var_path = '/user/{username}'.sub('{' + 'username' + '}', username.to_s)
local_var_path = '/user/{username}'.sub('{' + 'username' + '}', CGI.escape(username.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down Expand Up @@ -283,7 +284,7 @@ def get_user_by_name_with_http_info(username, opts = {})
fail ArgumentError, "Missing the required parameter 'username' when calling UserApi.get_user_by_name"
end
# resource path
local_var_path = '/user/{username}'.sub('{' + 'username' + '}', username.to_s)
local_var_path = '/user/{username}'.sub('{' + 'username' + '}', CGI.escape(username.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down Expand Up @@ -471,7 +472,7 @@ def update_user_with_http_info(username, user, opts = {})
fail ArgumentError, "Missing the required parameter 'user' when calling UserApi.update_user"
end
# resource path
local_var_path = '/user/{username}'.sub('{' + 'username' + '}', username.to_s)
local_var_path = '/user/{username}'.sub('{' + 'username' + '}', CGI.escape(username.to_s))

# query parameters
query_params = opts[:query_params] || {}
Expand Down