File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
modules/openapi-generator/src/main/java/org/openapitools/codegen/languages Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -355,15 +355,21 @@ public String toEnumName(CodegenProperty property) {
355355 }
356356 }
357357
358+ private boolean isValidIdentifier (String identifier ) {
359+ //see https://nim-lang.org/docs/manual.html#lexical-analysis-identifiers-amp-keywords
360+ return identifier .matches ("^(?:[A-Z]|[a-z]|[\\ x80-\\ xff])(_?(?:[A-Z]|[a-z]|[\\ x80-\\ xff]|[0-9]))*$" );
361+ }
362+
358363 @ Override
359364 public String toEnumVarName (String name , String datatype ) {
360365 name = name .replace (" " , "_" );
361366 name = StringUtils .camelize (name );
362367
363- if (name .matches ("\\ d.*" )) { // starts with number
364- return "`" + name + "`" ;
365- } else {
368+ // starts with number or contains any character not allowed,see
369+ if (isValidIdentifier (name )) {
366370 return name ;
371+ } else {
372+ return "`" + name + "`" ;
367373 }
368374 }
369375
You can’t perform that action at this time.
0 commit comments