File tree Expand file tree Collapse file tree
modules/openapi-generator/src/main/java/org/openapitools/codegen/languages Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -731,6 +731,24 @@ public ModelsMap postProcessModels(ModelsMap objs) {
731731 }
732732 }
733733
734+ // Fix for enum wrapping when NOT extracting enums to separate files
735+ // Since v7.20.0, all enums are wrapped in messages but field references
736+ // weren't updated to use .Enum suffix when not extracted
737+ boolean isDirectEnumForFix = property .isEnum ;
738+ boolean isArrayOfEnumsForFix = property .isArray && property .items != null && property .items .isEnum ;
739+
740+ if ((isDirectEnumForFix || isArrayOfEnumsForFix ) && !this .extractEnumsToSeparateFiles ) {
741+ // For enums that are wrapped but not extracted, update the data type to use .Enum suffix
742+ CodegenProperty enumPropertyForFix = isArrayOfEnumsForFix ? property .items : property ;
743+ String enumTypeName = enumPropertyForFix .dataType ;
744+
745+ if (StringUtils .isNotBlank (enumTypeName )) {
746+ // Update x-protobuf-data-type to reference the wrapped enum's inner Enum
747+ String wrappedEnumType = enumTypeName + "." + ENUM_WRAPPER_INNER_NAME ;
748+ property .vendorExtensions .put ("x-protobuf-data-type" , wrappedEnumType );
749+ }
750+ }
751+
734752 // Check if this property is an enum or an array of enums.
735753 //
736754 // This handles two distinct cases:
You can’t perform that action at this time.
0 commit comments