From 14cfa80061ebc781586c3650be0f6cb33b161edd Mon Sep 17 00:00:00 2001 From: William Cheng Date: Sun, 3 Feb 2019 01:11:33 +0800 Subject: [PATCH 1/2] fix free form object detection --- .../java/org/openapitools/codegen/utils/ModelUtils.java | 8 ++++++++ 1 file changed, 8 insertions(+) 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..ed90d1e0b267 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,14 @@ 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; + if (getInterfaces(cs) != null && !getInterfaces(cs).isEmpty()) { + return false; + } + } + // has at least one property if ("object".equals(schema.getType())) { // no properties From 87aeb02a332b962d444351c6268b579446a38495 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Sun, 3 Feb 2019 01:20:55 +0800 Subject: [PATCH 2/2] refator --- .../main/java/org/openapitools/codegen/utils/ModelUtils.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 ed90d1e0b267..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 @@ -537,7 +537,8 @@ public static boolean isFreeFormObject(Schema schema) { // not free-form if allOf, anyOf, oneOf is not empty if (schema instanceof ComposedSchema) { ComposedSchema cs = (ComposedSchema) schema; - if (getInterfaces(cs) != null && !getInterfaces(cs).isEmpty()) { + List interfaces = getInterfaces(cs); + if (interfaces != null && !interfaces.isEmpty()) { return false; } }