Skip to content

Commit 96a6ecd

Browse files
committed
Reverted attempts to reuse recursive type-finding code.
1 parent 61263ff commit 96a6ecd

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2490,7 +2490,13 @@ protected void updateModelForComposedSchema(CodegenModel m, Schema schema, Map<S
24902490
if (StringUtils.isBlank(interfaceSchema.get$ref())) {
24912491
// primitive type
24922492
String languageType = getTypeDeclaration(interfaceSchema);
2493-
addImports(m.imports, fromProperty(languageType, interfaceSchema));
2493+
CodegenProperty interfaceProperty = fromProperty(languageType, interfaceSchema);
2494+
if (ModelUtils.isArraySchema(interfaceSchema) || ModelUtils.isMapSchema(interfaceSchema)) {
2495+
while (interfaceProperty != null) {
2496+
addImport(m, interfaceProperty.complexType);
2497+
interfaceProperty = interfaceProperty.items;
2498+
}
2499+
}
24942500

24952501
if (composed.getAnyOf() != null) {
24962502
if (m.anyOf.contains(languageType)) {
@@ -6371,7 +6377,11 @@ public CodegenParameter fromFormProperty(String name, Schema propertySchema, Set
63716377
// default to csv:
63726378
codegenParameter.collectionFormat = StringUtils.isEmpty(collectionFormat) ? "csv" : collectionFormat;
63736379

6374-
addImports(imports, arrayInnerProperty);
6380+
// recursively add import
6381+
while (arrayInnerProperty != null) {
6382+
imports.add(arrayInnerProperty.baseType);
6383+
arrayInnerProperty = arrayInnerProperty.items;
6384+
}
63756385
} else {
63766386
// referenced schemas
63776387
;
@@ -6398,7 +6408,10 @@ public CodegenParameter fromFormProperty(String name, Schema propertySchema, Set
63986408
codegenParameter.enumName = codegenProperty.enumName;
63996409
}
64006410

6401-
addImports(imports, codegenProperty);
6411+
// import
6412+
if (codegenProperty.complexType != null) {
6413+
imports.add(codegenProperty.complexType);
6414+
}
64026415

64036416
setParameterExampleValue(codegenParameter);
64046417
// set nullable

0 commit comments

Comments
 (0)