Skip to content

Commit a3ca359

Browse files
committed
Fix enum variant name generation
Datatypes like `Vec<foo::bar::Baz>` would end up as `Baz` instead of `VecOfBaz`
1 parent 0c52540 commit a3ca359

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustAxumServerCodegen.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,8 +615,9 @@ private void postProcessOneOfModels(List<ModelMap> allModels) {
615615
for (CodegenProperty model : csOneOf) {
616616
// Generate a valid name for the enum variant.
617617
// Mainly needed for primitive types.
618-
String[] modelParts = model.dataType.replace("<", "Of").replace(">", "").split("::");
619-
model.datatypeWithEnum = camelize(modelParts[modelParts.length - 1]);
618+
619+
model.datatypeWithEnum = camelize(model.dataType.replaceAll("(?:\\w+::)+(\\w+)", "$1")
620+
.replace("<", "Of").replace(">", ""));
620621

621622
// Primitive type is not properly set, this overrides it to guarantee adequate model generation.
622623
if (!model.getDataType().matches(String.format(Locale.ROOT, ".*::%s", model.getDatatypeWithEnum()))) {

0 commit comments

Comments
 (0)