diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java index d2775775ea84..99337b2ad646 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java @@ -534,6 +534,15 @@ public static boolean isFreeFormObject(Schema schema) { return false; } + // not free-form if allOf, anyOf, oneOf is not empty + if (schema instanceof ComposedSchema) { + ComposedSchema cs = (ComposedSchema) schema; + List interfaces = getInterfaces(cs); + if (interfaces != null && !interfaces.isEmpty()) { + return false; + } + } + // has at least one property if ("object".equals(schema.getType())) { // no properties