Skip to content

Commit 034064b

Browse files
ccouzensautopp
authored andcommitted
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. #3039 Unfortunately, some projects relied on slashes not being expanded within path paramters: #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: / -> /
1 parent 4ac33d8 commit 034064b

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java

+1
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,7 @@ public int compare(CodegenOperation one, CodegenOperation another) {
562562
operation.put("classVarName", config.toApiVarName(tag));
563563
operation.put("importPath", config.toApiImport(tag));
564564
operation.put("classFilename", config.toApiFilename(tag));
565+
operation.put("strictSpecBehavior", config.isStrictSpecBehavior());
565566

566567
if (allModels == null || allModels.isEmpty()) {
567568
operation.put("hasModel", false);

modules/openapi-generator/src/main/resources/ruby-client/api.mustache

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ module {{moduleName}}
123123
{{/hasValidation}}
124124
{{/allParams}}
125125
# resource path
126-
local_var_path = '{{{path}}}'{{#pathParams}}.sub('{' + '{{baseName}}' + '}', CGI.escape({{paramName}}.to_s)){{/pathParams}}
126+
local_var_path = '{{{path}}}'{{#pathParams}}.sub('{' + '{{baseName}}' + '}', CGI.escape({{paramName}}.to_s){{^strictSpecBehavior}}.gsub('%2F', '/'){{/strictSpecBehavior}}){{/pathParams}}
127127

128128
# query parameters
129129
query_params = opts[:query_params] || {}

0 commit comments

Comments
 (0)