forked from loafle/openapi-generator-original
Handle special characters in parameter names in ruby client
This commit is contained in:
parent
6d58d44542
commit
4477009ef8
@ -196,8 +196,10 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toVarName(String name) {
|
public String toVarName(String name) {
|
||||||
// replace - with _ e.g. created-at => created_at
|
// remove trailing special characters, e.g. "post[created-at]!!" => "post[created-at"
|
||||||
name = name.replaceAll("-", "_");
|
name = name.replaceAll("\\W+\\z", "");
|
||||||
|
// replace special characters with _, e.g. "post[created-at" => "post_created_at"
|
||||||
|
name = name.replaceAll("\\W+", "_");
|
||||||
|
|
||||||
// if it's all uppper case, convert to lower case
|
// if it's all uppper case, convert to lower case
|
||||||
if (name.matches("^[A-Z_]*$")) {
|
if (name.matches("^[A-Z_]*$")) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user