forked from loafle/openapi-generator-original
[All generators] Supports of hyphen-case to camelCase (#6399)
* Supports of hyphen-case to camelCase * Add unit tests for the new section in the camelize function.
This commit is contained in:
committed by
wing328
parent
29a3a4b336
commit
0cf82d7ae3
@@ -3251,7 +3251,7 @@ public class DefaultCodegen {
|
||||
word = m.replaceAll(rep);
|
||||
}
|
||||
|
||||
// Remove all underscores
|
||||
// Remove all underscores (underscore_case to camelCase)
|
||||
p = Pattern.compile("(_)(.)");
|
||||
m = p.matcher(word);
|
||||
while (m.find()) {
|
||||
@@ -3259,6 +3259,14 @@ public class DefaultCodegen {
|
||||
m = p.matcher(word);
|
||||
}
|
||||
|
||||
// Remove all hyphens (hyphen-case to camelCase)
|
||||
p = Pattern.compile("(-)(.)");
|
||||
m = p.matcher(word);
|
||||
while (m.find()) {
|
||||
word = m.replaceFirst(m.group(2).toUpperCase());
|
||||
m = p.matcher(word);
|
||||
}
|
||||
|
||||
if (lowercaseFirstLetter && word.length() > 0) {
|
||||
word = word.substring(0, 1).toLowerCase() + word.substring(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user