forked from loafle/openapi-generator-original
Ruby client: escape path parameters
Path parameters should be escaped when encoded into the path.
In the path '/pet/{petId}' let's pretend petId is a string instead of a
number.
If the user uses "Bobby" as the petId then they correctly get the path
'/pet/Bobby'.
But if they put 'Bobby/Tables' as the petId then they used to get the
path '/pet/Bobby/Tables' which will be interpreted by the server as a
different route.
Using CGI::Escape they now get '/pet/Bobby%2FTables' which is correct.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
=end
|
||||
|
||||
require 'uri'
|
||||
require 'cgi'
|
||||
|
||||
module {{moduleName}}
|
||||
{{#operations}}
|
||||
@@ -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] || {}
|
||||
|
||||
Reference in New Issue
Block a user