@@ -770,24 +770,42 @@ protected void patchProperty(Map<String, CodegenModel> enumRefs, CodegenModel mo
770770
771771 property .name = patchPropertyName (model , property .name , null );
772772
773+ patchNestedMaps (property );
774+
775+ // HOTFIX: https://github.com/OpenAPITools/openapi-generator/issues/14944
776+ if (property .datatypeWithEnum .equals ("decimal" )) {
777+ property .isDecimal = true ;
778+ }
779+ }
780+
781+ private void patchNestedMaps (CodegenProperty property ) {
782+ // Process nested types before making any replacements to ensure we have the correct inner type
783+ if (property .items != null ) {
784+ patchNestedMaps (property .items );
785+ }
786+
773787 String [] nestedTypes = {"List" , "Collection" , "ICollection" , "Dictionary" };
788+
789+ if (property .datatypeWithEnum != null ) {
790+ String originalType = property .datatypeWithEnum ;
791+
792+ for (String nestedType : nestedTypes ) {
793+ // fix incorrect data types for maps of maps
794+ if (property .items != null ) {
795+ if (property .datatypeWithEnum .contains (", " + nestedType + ">" )) {
796+ property .datatypeWithEnum = property .datatypeWithEnum .replace (", " + nestedType + ">" , ", " + property .items .datatypeWithEnum + ">" );
797+ }
774798
775- Arrays .stream (nestedTypes ).forEach (nestedType -> {
776- // fix incorrect data types for maps of maps
777- if (property .datatypeWithEnum .contains (", " + nestedType + ">" ) && property .items != null ) {
778- property .datatypeWithEnum = property .datatypeWithEnum .replace (", " + nestedType + ">" , ", " + property .items .datatypeWithEnum + ">" );
779- property .dataType = property .datatypeWithEnum ;
799+ if (property .datatypeWithEnum .contains ("<" + nestedType + ">" )) {
800+ property .datatypeWithEnum = property .datatypeWithEnum .replace ("<" + nestedType + ">" , "<" + property .items .datatypeWithEnum + ">" );
801+ }
802+ }
780803 }
781804
782- if ( property . datatypeWithEnum . contains ( "<" + nestedType + ">" ) && property . items != null ) {
783- property . datatypeWithEnum = property . datatypeWithEnum . replace ( "<" + nestedType + ">" , "<" + property .items . datatypeWithEnum + ">" );
805+ // Only update dataType if we actually made changes
806+ if (! originalType . equals ( property .datatypeWithEnum )) {
784807 property .dataType = property .datatypeWithEnum ;
785808 }
786- });
787-
788- // HOTFIX: https://github.com/OpenAPITools/openapi-generator/issues/14944
789- if (property .datatypeWithEnum .equals ("decimal" )) {
790- property .isDecimal = true ;
791809 }
792810 }
793811
0 commit comments