diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index b4edf3bb4b4e..d43064ef2b7a 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -4069,13 +4069,30 @@ public void updateCodegenPropertyEnum(CodegenProperty var) { private void updateEnumVarsWithExtensions (List> enumVars, Map vendorExtensions) { - if (vendorExtensions != null && vendorExtensions.containsKey("x-enum-varnames")) { + if (vendorExtensions == null) { + return; + } + + if (vendorExtensions.containsKey("x-enum-varnames")) { List alias = (List) vendorExtensions.get("x-enum-varnames"); int size = Math.min(enumVars.size(), alias.size()); for (int i = 0; i < size; i++) { enumVars.get(i).put("name", alias.get(i)); } } + + if (vendorExtensions.containsKey("x-enum-values")) { + List> enumValues = (List>) vendorExtensions.get("x-enum-values"); + + for (Map enumValue : enumValues) { + for (Map enumVar : enumVars) { + if (enumValue.get("numericValue").equals(enumVar.get("value"))) { + enumVar.put("name", enumValue.get("identifier").toUpperCase(Locale.ROOT)); + break; + } + } + } + } } /**