Skip to content

Commit b6eb81c

Browse files
committed
Move path unescaping from DefaultGenerator to Ruby api template.
1 parent 344e1b1 commit b6eb81c

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,6 @@ private File processTemplateToFile(Map<String, Object> templateData, String temp
631631
String templateFile = getFullTemplateFile(config, templateName);
632632
String template = readTemplate(templateFile);
633633
Template tmpl = Mustache.compiler()
634-
.escapeHTML(false)
635634
.withLoader(new Mustache.TemplateLoader() {
636635
@Override
637636
public Reader getTemplate(String name) {

modules/swagger-codegen/src/main/resources/ruby/api.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ module {{moduleName}}
8989
{{/hasValidation}}
9090
{{/allParams}}
9191
# resource path
92-
local_var_path = "{{path}}".sub('{format}','json'){{#pathParams}}.sub('{' + '{{baseName}}' + '}', {{paramName}}.to_s){{/pathParams}}
92+
local_var_path = "{{{path}}}".sub('{format}','json'){{#pathParams}}.sub('{' + '{{baseName}}' + '}', {{paramName}}.to_s){{/pathParams}}
9393

9494
# query parameters
9595
query_params = {}

modules/swagger-codegen/src/test/java/io/swagger/codegen/DefaultGeneratorTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ public void testGenerateUniqueOperationIds() {
223223
}
224224

225225
@Test
226-
public void testGenerateWithHtmlEntity() throws Exception {
226+
public void testGenerateRubyClientWithHtmlEntity() throws Exception {
227227
final File output = folder.getRoot();
228228

229229
final Swagger swagger = new SwaggerParser().read("src/test/resources/2_0/pathWithHtmlEntity.yaml");
@@ -239,6 +239,7 @@ public void testGenerateWithHtmlEntity() throws Exception {
239239
for (File file : files) {
240240
if (file.getName().equals("default_api.rb")) {
241241
apiFileGenerated = true;
242+
// Ruby client should set the path unescaped in the api file
242243
assertTrue(FileUtils.readFileToString(file, StandardCharsets.UTF_8).contains("local_var_path = \"/foo=bar\""));
243244
}
244245
}

0 commit comments

Comments
 (0)