Move path unescaping from DefaultGenerator to Ruby api template.

This commit is contained in:
Cliffano Subagio 2016-06-29 09:46:41 +10:00
parent 344e1b12e4
commit b6eb81cbef
3 changed files with 3 additions and 3 deletions

View File

@ -631,7 +631,6 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
String templateFile = getFullTemplateFile(config, templateName);
String template = readTemplate(templateFile);
Template tmpl = Mustache.compiler()
.escapeHTML(false)
.withLoader(new Mustache.TemplateLoader() {
@Override
public Reader getTemplate(String name) {

View File

@ -89,7 +89,7 @@ module {{moduleName}}
{{/hasValidation}}
{{/allParams}}
# resource path
local_var_path = "{{path}}".sub('{format}','json'){{#pathParams}}.sub('{' + '{{baseName}}' + '}', {{paramName}}.to_s){{/pathParams}}
local_var_path = "{{{path}}}".sub('{format}','json'){{#pathParams}}.sub('{' + '{{baseName}}' + '}', {{paramName}}.to_s){{/pathParams}}
# query parameters
query_params = {}

View File

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