@@ -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 }
@@ -939,6 +950,7 @@ class ExtendedCodegenModel extends CodegenModel {
939950 public List <CodegenProperty > ectoFields = new ArrayList <>();
940951 public List <CodegenProperty > ectoEmbeds = new ArrayList <>();
941952 public List <CodegenProperty > ectoEnums = new ArrayList <>();
953+ public List <CodegenProperty > ectoMaps = new ArrayList <>();
942954 public List <CodegenProperty > requiredEctoFields = new ArrayList <>();
943955
944956 public ExtendedCodegenModel (CodegenModel cm ) {
@@ -1003,6 +1015,9 @@ public ExtendedCodegenModel(CodegenModel cm) {
10031015 if (var .isEnum || var .isEnumRef ) {
10041016 this .ectoEnums .add (var );
10051017 }
1018+ if (var .isMap && !var .isFreeFormObject && var .additionalProperties != null && var .additionalProperties .isModel ) {
1019+ this .ectoMaps .add (var );
1020+ }
10061021 } else {
10071022 this .ectoEmbeds .add (var );
10081023 }
@@ -1012,6 +1027,8 @@ public ExtendedCodegenModel(CodegenModel cm) {
10121027
10131028 class ExtendedCodegenProperty extends CodegenProperty {
10141029 public String enumBaseType ;
1030+ public String mapValueType ;
1031+ public boolean isMapWithSchema ;
10151032
10161033 public ExtendedCodegenProperty (CodegenProperty cp ) {
10171034 super ();
@@ -1104,6 +1121,17 @@ public ExtendedCodegenProperty(CodegenProperty cp) {
11041121 this .enumBaseType = "String.t" ;
11051122 }
11061123 }
1124+ // For map properties, extract the model name from additionalProperties
1125+ if (cp .isMap && cp .additionalProperties != null ) {
1126+ // Check if the map has a schema (model) or is a free-form map
1127+ if (cp .additionalProperties .isModel ) {
1128+ // Extract just the model name without the full type declaration
1129+ this .mapValueType = cp .additionalProperties .complexType ;
1130+ this .isMapWithSchema = true ;
1131+ } else {
1132+ this .isMapWithSchema = false ;
1133+ }
1134+ }
11071135 }
11081136
11091137 public String ectoType () {
0 commit comments