@@ -110,17 +110,19 @@ protected CodegenModel processComposedSchema(String codegenModelName, CodegenPro
110
110
}
111
111
}
112
112
this .addInterfaces (schemas , composedModel , allModels );
113
- codegenProperty .datatype = composedModel .getName ();
114
- codegenProperty .datatypeWithEnum = composedModel .getName ();
115
- codegenProperty .baseType = composedModel .getName ();
116
- codegenProperty .complexType = composedModel .getName ();
113
+ codegenProperty .datatype = composedModel .getClassname ();
114
+ codegenProperty .datatypeWithEnum = composedModel .getClassname ();
115
+ codegenProperty .baseType = composedModel .getClassname ();
116
+ codegenProperty .complexType = composedModel .getClassname ();
117
117
return composedModel ;
118
118
}
119
119
120
120
protected CodegenModel processArrayItemSchema (CodegenModel codegenModel , ArraySchema arraySchema , Map <String , CodegenModel > allModels ) {
121
121
final Schema itemsSchema = arraySchema .getItems ();
122
122
if (itemsSchema instanceof ComposedSchema ) {
123
- return this .processComposedSchema (codegenModel .name + ARRAY_ITEMS_SUFFIX , (ComposedSchema ) itemsSchema , allModels );
123
+ final CodegenModel composedModel = this .processComposedSchema (codegenModel .name + ARRAY_ITEMS_SUFFIX , (ComposedSchema ) itemsSchema , allModels );
124
+ this .updateParentModel (codegenModel , composedModel .name , arraySchema );
125
+ return composedModel ;
124
126
}
125
127
return null ;
126
128
}
@@ -129,6 +131,9 @@ protected CodegenModel processArrayItemSchema(String codegenModelName, CodegenPr
129
131
final Schema itemsSchema = arraySchema .getItems ();
130
132
if (itemsSchema instanceof ComposedSchema ) {
131
133
final CodegenModel composedModel = this .processComposedSchema (codegenModelName + ARRAY_ITEMS_SUFFIX , codegenProperty .items , (ComposedSchema ) itemsSchema , allModels );
134
+ if (composedModel == null ) {
135
+ return null ;
136
+ }
132
137
this .updatePropertyDataType (codegenProperty , composedModel .name , arraySchema );
133
138
return composedModel ;
134
139
}
@@ -199,6 +204,21 @@ protected void updatePropertyDataType(CodegenProperty codegenProperty, String sc
199
204
codegenProperty .setDatatype (this .codegenConfig .getTypeDeclaration (arraySchema ));
200
205
codegenProperty .setDatatypeWithEnum (codegenProperty .getDatatype ());
201
206
207
+ codegenProperty .defaultValue = this .codegenConfig .toDefaultValue (arraySchema );
208
+ codegenProperty .defaultValueWithParam = this .codegenConfig .toDefaultValueWithParam (codegenProperty .baseName , arraySchema );
209
+
210
+ arraySchema .setItems (items );
211
+ }
212
+
213
+ protected void updateParentModel (CodegenModel codegenModel , String schemaName , ArraySchema arraySchema ) {
214
+ final Schema items = arraySchema .getItems ();
215
+ final Schema refSchema = new Schema ();
216
+ refSchema .set$ref ("#/components/schemas/" + schemaName );
217
+ arraySchema .setItems (refSchema );
218
+
219
+ this .codegenConfig .addParentContainer (codegenModel , codegenModel .name , arraySchema );
220
+ codegenModel .defaultValue = this .codegenConfig .toDefaultValue (arraySchema );
221
+
202
222
arraySchema .setItems (items );
203
223
}
204
224
}
0 commit comments