Skip to content

Commit 454adec

Browse files
authored
Fix isFreeFormObject check for allOf, oneOf, anyOf (#2044)
* fix free form object detection * refator
1 parent 931c03b commit 454adec

File tree

1 file changed

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

1 file changed

+9
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,15 @@ public static boolean isFreeFormObject(Schema schema) {
534534
return false;
535535
}
536536

537+
// not free-form if allOf, anyOf, oneOf is not empty
538+
if (schema instanceof ComposedSchema) {
539+
ComposedSchema cs = (ComposedSchema) schema;
540+
List<Schema> interfaces = getInterfaces(cs);
541+
if (interfaces != null && !interfaces.isEmpty()) {
542+
return false;
543+
}
544+
}
545+
537546
// has at least one property
538547
if ("object".equals(schema.getType())) {
539548
// no properties

0 commit comments

Comments
 (0)