mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-05-12 12:40:53 +00:00
Merge c2d3e6b16160d6bdb09ed053b064fe1387a7b955 into d6c46342693205f0dae441b45742d9c85d41cf33
This commit is contained in:
commit
139e6369f3
@ -355,15 +355,21 @@ public class NimClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isValidIdentifier(String identifier) {
|
||||
//see https://nim-lang.org/docs/manual.html#lexical-analysis-identifiers-amp-keywords
|
||||
return identifier.matches("^(?:[A-Z]|[a-z]|[\\x80-\\xff])(_?(?:[A-Z]|[a-z]|[\\x80-\\xff]|[0-9]))*$");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toEnumVarName(String name, String datatype) {
|
||||
name = name.replace(" ", "_");
|
||||
name = StringUtils.camelize(name);
|
||||
|
||||
if (name.matches("\\d.*")) { // starts with number
|
||||
return "`" + name + "`";
|
||||
} else {
|
||||
// starts with number or contains any character not allowed,see
|
||||
if (isValidIdentifier(name)) {
|
||||
return name;
|
||||
} else {
|
||||
return "`" + name + "`";
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user