Skip to content

Commit 7ebb3d0

Browse files
krumbs8749darw-soptim
authored andcommitted
fix: testAnyType
1 parent 4a314c0 commit 7ebb3d0

File tree

1 file changed

+17
-8
lines changed
  • modules/openapi-generator/src/main/java/org/openapitools/codegen/utils

1 file changed

+17
-8
lines changed

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

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,15 +1440,24 @@ public static Schema unaliasSchema(OpenAPI openAPI,
14401440
Schema<?> unwrapped = unaliasSchema(openAPI, copyObj, schemaMappings);
14411441
return mergeSiblingFields(schema, unwrapped);
14421442
}
1443-
}
1444-
1445-
// Primitive fallback alias
1446-
{
1447-
// ↳ fully unwrap a simple/primitive alias
1448-
Schema copyPrim = deepCopy(ref); // deep-copy primitive definition
1443+
} else {
1444+
boolean isFreeFormAny =
1445+
!isArraySchema(ref) &&
1446+
!isMapSchema(ref) &&
1447+
!isEnumSchema(ref) &&
1448+
!isComposedSchema(ref) &&
1449+
(ref.getProperties() == null || ref.getProperties().isEmpty()) &&
1450+
ref.getDefault() == null &&
1451+
ref.getExample() == null &&
1452+
!isGenerateAliasAsModel(ref);
1453+
1454+
if (isFreeFormAny) {
1455+
return unaliasSchema(openAPI, ref, schemaMappings);
1456+
}
1457+
Schema<?> copyPrim = deepCopy(ref);
14491458
if (copyPrim == null) return ref;
1450-
copyPrim.set$ref(null); // clear its $ref to avoid recursion
1451-
Schema unwrapped = unaliasSchema(openAPI, copyPrim, schemaMappings);
1459+
copyPrim.set$ref(null); // clear its $ref to avoid recursion
1460+
Schema<?> unwrapped = unaliasSchema(openAPI, copyPrim, schemaMappings);
14521461
return mergeSiblingFields(schema, unwrapped);
14531462
}
14541463
}

0 commit comments

Comments
 (0)