mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-21 08:17:08 +00:00
* escape string interpolation notation of Ruby (#2261) * update samples (#2261)
This commit is contained in:
committed by
William Cheng
parent
88abea1755
commit
1d02f0374b
@@ -33,10 +33,10 @@ import java.util.Locale;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
abstract class AbstractRubyCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
abstract public class AbstractRubyCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractRubyCodegen.class);
|
||||
|
||||
AbstractRubyCodegen() {
|
||||
public AbstractRubyCodegen() {
|
||||
super();
|
||||
|
||||
setReservedWordsLowerCase(
|
||||
@@ -177,7 +177,7 @@ abstract class AbstractRubyCodegen extends DefaultCodegen implements CodegenConf
|
||||
|
||||
@Override
|
||||
public String escapeUnsafeCharacters(String input) {
|
||||
return input.replace("=end", "=_end").replace("=begin", "=_begin");
|
||||
return input.replace("=end", "=_end").replace("=begin", "=_begin").replace("#{", "\\#{");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package org.openapitools.codegen.ruby;
|
||||
|
||||
import org.openapitools.codegen.languages.AbstractRubyCodegen;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Tests for AbstractRubyCodegen
|
||||
*/
|
||||
public class AbstractRubyCodegenTest {
|
||||
private AbstractRubyCodegen codegen;
|
||||
|
||||
@BeforeMethod
|
||||
public void setup() {
|
||||
codegen = new AbstractRubyCodegen() {
|
||||
};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEscapeUnsafeCharacters() {
|
||||
Assert.assertEquals(codegen.escapeUnsafeCharacters("=begin"), "=_begin");
|
||||
Assert.assertEquals(codegen.escapeUnsafeCharacters("=end"), "=_end");
|
||||
Assert.assertEquals(codegen.escapeUnsafeCharacters("#{x}"), "\\#{x}");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user