Ruby-client: Don't encode slashes if strict-spec false (#3204)

URL-special characters such as /,?,% should be encoded when inside path
parameters. I changed the Ruby-client to do so.
https://github.com/OpenAPITools/openapi-generator/pull/3039

Unfortunately, some projects relied on slashes not being expanded within
path paramters:
https://github.com/OpenAPITools/openapi-generator/issues/3119

With this commit, these projects can now pass `--strict-spec false` to
not have / converted to %2F.

strict spec not specified: / -> %2F
--strict-spec true: / -> %2F
--strict-spec false: / -> /
This commit is contained in:
Chris Couzens 2019-06-24 16:30:00 +01:00 committed by Akira Tanimura
parent 4ac33d80f0
commit 034064be4c
2 changed files with 2 additions and 1 deletions

View File

@ -562,6 +562,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
operation.put("classVarName", config.toApiVarName(tag));
operation.put("importPath", config.toApiImport(tag));
operation.put("classFilename", config.toApiFilename(tag));
operation.put("strictSpecBehavior", config.isStrictSpecBehavior());
if (allModels == null || allModels.isEmpty()) {
operation.put("hasModel", false);

View File

@ -123,7 +123,7 @@ module {{moduleName}}
{{/hasValidation}}
{{/allParams}}
# resource path
local_var_path = '{{{path}}}'{{#pathParams}}.sub('{' + '{{baseName}}' + '}', CGI.escape({{paramName}}.to_s)){{/pathParams}}
local_var_path = '{{{path}}}'{{#pathParams}}.sub('{' + '{{baseName}}' + '}', CGI.escape({{paramName}}.to_s){{^strictSpecBehavior}}.gsub('%2F', '/'){{/strictSpecBehavior}}){{/pathParams}}
# query parameters
query_params = opts[:query_params] || {}