@@ -417,7 +417,18 @@ private void gatherInlineModels(Schema schema, String modelPrefix) {
417417 if (schema .getAllOf ().size () == 1 ) {
418418 // handle earlier in this function when looping through properties
419419 } else if (schema .getAllOf ().size () > 1 ) {
420- LOGGER .warn ("allOf schema `{}` containing multiple types (not model) is not supported at the moment." , schema .getName ());
420+ // Check if there is only one "non metadata" schema.
421+ // For example, there may be an `description` only schema that is used to override the descrption.
422+ // In these cases, we can simply discard those schemas.
423+ List <Schema > nonMetadataOnlySchemas = schema .getAllOf ().stream ()
424+ .filter (v -> isMetadataOnlySchema ((Schema ) v ))
425+ .toList ();
426+
427+ if (nonMetadataOnlySchemas .size () == 1 ) {
428+ schema .setAllOf (nonMetadataOnlySchemas );
429+ } else {
430+ LOGGER .warn ("allOf schema `{}` containing multiple types (not model) is not supported at the moment." , schema .getName ());
431+ }
421432 } else {
422433 LOGGER .error ("allOf schema `{}` contains no items." , schema .getName ());
423434 }
@@ -473,6 +484,31 @@ private void gatherInlineModels(Schema schema, String modelPrefix) {
473484 }
474485 }
475486
487+ /**
488+ * Returns true if a schema is only metadata and not an actual type.
489+ * For example, a schema that only has a `description` without any `properties` or `$ref` defined.
490+ *
491+ * @param schema the schema
492+ * @return if the schema is only metadata and not an actual type
493+ */
494+ boolean isMetadataOnlySchema (Schema schema ) {
495+ return schema .get$ref () != null ||
496+ schema .getProperties () != null ||
497+ schema .getType () != null ||
498+ schema .getAdditionalProperties () != null ||
499+ schema .getAllOf () != null ||
500+ schema .getAnyOf () != null ||
501+ schema .getOneOf () != null ||
502+ schema .getPrefixItems () != null ||
503+ schema .getItems () != null ||
504+ schema .getTypes () != null ||
505+ schema .getPatternProperties () != null ||
506+ schema .getContains () != null ||
507+ schema .get$dynamicAnchor () != null ||
508+ schema .get$anchor () != null ||
509+ schema .getContentSchema () != null ;
510+ }
511+
476512 /**
477513 * Flatten inline models in content
478514 *
0 commit comments