mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-05-12 20:50:55 +00:00
fix for stripping prefix on single enums (#7726)
This commit is contained in:
parent
1947220159
commit
e73eeb4fdf
@ -263,12 +263,14 @@ public class DefaultCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the common prefix of variables for enum naming
|
* Returns the common prefix of variables for enum naming if
|
||||||
|
* two or more variables are present
|
||||||
*
|
*
|
||||||
* @param vars List of variable names
|
* @param vars List of variable names
|
||||||
* @return the common prefix for naming
|
* @return the common prefix for naming
|
||||||
*/
|
*/
|
||||||
public String findCommonPrefixOfVars(List<Object> vars) {
|
public String findCommonPrefixOfVars(List<Object> vars) {
|
||||||
|
if (vars.size() > 1) {
|
||||||
try {
|
try {
|
||||||
String[] listStr = vars.toArray(new String[vars.size()]);
|
String[] listStr = vars.toArray(new String[vars.size()]);
|
||||||
String prefix = StringUtils.getCommonPrefix(listStr);
|
String prefix = StringUtils.getCommonPrefix(listStr);
|
||||||
@ -276,9 +278,11 @@ public class DefaultCodegen {
|
|||||||
// e.g. ["status-on", "status-off"] => "status-" (not "status-o")
|
// e.g. ["status-on", "status-off"] => "status-" (not "status-o")
|
||||||
return prefix.replaceAll("[a-zA-Z0-9]+\\z", "");
|
return prefix.replaceAll("[a-zA-Z0-9]+\\z", "");
|
||||||
} catch (ArrayStoreException e) {
|
} catch (ArrayStoreException e) {
|
||||||
return "";
|
// do nothing, just return default value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the enum default value in the language specified format
|
* Return the enum default value in the language specified format
|
||||||
|
Loading…
x
Reference in New Issue
Block a user