@@ -360,6 +360,10 @@ public void preprocessOpenAPI(OpenAPI openAPI) {
360360 supportingFiles .add (new SupportingFile ("request_builder.ex.mustache" ,
361361 sourceFolder (),
362362 "request_builder.ex" ));
363+
364+ supportingFiles .add (new SupportingFile ("ecto_utils.ex.mustache" ,
365+ sourceFolder (),
366+ "ecto_utils.ex" ));
363367 }
364368
365369 @ Override
@@ -454,6 +458,13 @@ public CodegenModel fromModel(String name, Schema model) {
454458 for (CodegenProperty field : ectoEnums ) {
455459 ecm .ectoEnums .add (new ExtendedCodegenProperty (field ));
456460 }
461+
462+
463+ List <CodegenProperty > ectoMaps = new ArrayList <>(ecm .ectoMaps );
464+ ecm .ectoMaps .clear ();
465+ for (CodegenProperty field : ectoMaps ) {
466+ ecm .ectoMaps .add (new ExtendedCodegenProperty (field ));
467+ }
457468
458469 return ecm ;
459470 }
@@ -945,6 +956,7 @@ class ExtendedCodegenModel extends CodegenModel {
945956 public List <CodegenProperty > ectoFields = new ArrayList <>();
946957 public List <CodegenProperty > ectoEmbeds = new ArrayList <>();
947958 public List <CodegenProperty > ectoEnums = new ArrayList <>();
959+ public List <CodegenProperty > ectoMaps = new ArrayList <>();
948960 public List <CodegenProperty > requiredEctoFields = new ArrayList <>();
949961
950962 public ExtendedCodegenModel (CodegenModel cm ) {
@@ -1009,6 +1021,9 @@ public ExtendedCodegenModel(CodegenModel cm) {
10091021 if (var .isEnum || var .isEnumRef ) {
10101022 this .ectoEnums .add (var );
10111023 }
1024+ if (var .isMap && !var .isFreeFormObject && var .additionalProperties != null && var .additionalProperties .isModel ) {
1025+ this .ectoMaps .add (var );
1026+ }
10121027 } else {
10131028 this .ectoEmbeds .add (var );
10141029 }
@@ -1018,6 +1033,8 @@ public ExtendedCodegenModel(CodegenModel cm) {
10181033
10191034 class ExtendedCodegenProperty extends CodegenProperty {
10201035 public String enumBaseType ;
1036+ public String mapValueType ;
1037+ public boolean isMapWithSchema ;
10211038
10221039 public ExtendedCodegenProperty (CodegenProperty cp ) {
10231040 super ();
@@ -1110,6 +1127,17 @@ public ExtendedCodegenProperty(CodegenProperty cp) {
11101127 this .enumBaseType = "String.t" ;
11111128 }
11121129 }
1130+ // For map properties, extract the model name from additionalProperties
1131+ if (cp .isMap && cp .additionalProperties != null ) {
1132+ // Check if the map has a schema (model) or is a free-form map
1133+ if (cp .additionalProperties .isModel ) {
1134+ // Extract just the model name without the full type declaration
1135+ this .mapValueType = cp .additionalProperties .complexType ;
1136+ this .isMapWithSchema = true ;
1137+ } else {
1138+ this .isMapWithSchema = false ;
1139+ }
1140+ }
11131141 }
11141142
11151143 public String ectoType () {
0 commit comments