diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index 1ab927a6a26c..5b6c12647702 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -2688,6 +2688,9 @@ protected void updateModelForAnyType(CodegenModel m, Schema schema) { addAdditionPropertiesToCodeGenModel(m, schema); m.isMap = true; } + if (m.parent == null && !Objects.equals(m.dataType, "Object")) { + m.parent = m.dataType; + } if (schema.getProperties() != null || schema.getRequired() != null && !(schema instanceof ComposedSchema)) { // passing null to allProperties and allRequired as there's no parent addVars(m, unaliasPropertySchema(schema.getProperties()), schema.getRequired(), null, null);