OpenAPITools/openapi-generator · error · RuntimeException
Error! allOf schema is not of the type Schema: {item}
Error message
Error! allOf schema is not of the type Schema: {item} What it means
normalizeAllOf iterates schema.getAllOf() (statically List<Schema>, but generic erasure and lenient deserialization can smuggle other values) and requires every element to pass 'item instanceof Schema' before recursing into normalizeSchema. Any non-Schema element - a null that survived the earlier null-skip logic, a raw map/scalar from malformed YAML/JSON under allOf, or a programmatically inserted arbitrary object - triggers this error, printing the offending item.
Source
Thrown at modules/openapi-generator/src/main/java/org/openapitools/codegen/OpenAPINormalizer.java:1286
if (schema.getAllOf().size() == 0) {
// no more schema in allOf so reset to null instead
LOGGER.info("Unset/Removed allOf after cleaning up allOf sub-schemas that are not yet supported.");
schema.setAllOf(null);
}
}
protected Schema normalizeAllOf(Schema schema, Set<Schema> visitedSchemas) {
removeUnsupportedSchemasFromAllOf(schema);
refactorAllOfWithMetadataOnlySchemas(schema);
if (schema.getAllOf() == null) {
return schema;
}
for (Object item : schema.getAllOf()) {
if (!(item instanceof Schema)) {
throw new RuntimeException("Error! allOf schema is not of the type Schema: " + item);
}
// normalize allOf sub schemas one by one
normalizeSchema((Schema) item, visitedSchemas);
}
// process rules here
processUseAllOfRefAsParent(schema);
return schema;
}
protected Schema normalizeAllOfWithProperties(Schema schema, Set<Schema> visitedSchemas) {
removeUnsupportedSchemasFromAllOf(schema);
if (schema.getAllOf() == null) {
return schema;
}
View on GitHub (pinned to fcec517be3)
Solutions
- Look at the printed item value - it shows exactly what sits in the allOf list; locate that node in the spec.
- Make every allOf entry a proper schema object or a $ref: '- $ref: ...' or '- type: object; properties: {...}'.
- Remove boolean/scalar schemas from allOf (OpenAPI 3.0/3.1 documents must not contain them under composition keywords).
- If constructing the model programmatically, insert 'new Schema()' instances (or parsed nodes), never raw Maps or nulls.
- Validate with a strict JSON-Schema-for-OpenAPI validator to catch composition-type errors before generation.
Example fix
# before
components:
schemas:
Pet:
allOf:
- $ref: '#/components/schemas/Animal'
- true # invalid boolean schema under allOf
# after
components:
schemas:
Pet:
allOf:
- $ref: '#/components/schemas/Animal'
- type: object
properties:
name: { type: string } Defensive patterns
Strategy: validation
Validate before calling
// Assert every allOf member is a real Schema instance before generation
OpenAPI api = ...;
api.getComponents().getSchemas().forEach((name, s) -> {
if (s.getAllOf() != null) {
for (Object member : s.getAllOf()) {
if (!(member instanceof io.swagger.v3.oas.models.media.Schema)) {
throw new IllegalStateException("Non-schema allOf member in " + name + ": " + member);
}
}
}
}); Type guard
private static boolean hasValidAllOf(Schema s) {
return s.getAllOf() == null || s.getAllOf().stream()
.allMatch(m -> m instanceof io.swagger.v3.oas.models.media.Schema);
} Try / catch
try {
generator.opts(input).generate();
} catch (RuntimeException e) {
if (e.getMessage() != null && e.getMessage().contains("allOf schema is not of the type Schema")) {
// message prints the offending item; fix the composition list in the spec
throw new GenerationFailure("Invalid allOf member: " + e.getMessage(), e);
}
throw e;
} Prevention
- Ban boolean/scalar entries under allOf in your spec lint rules.
- When converting JSON Schema, rewrite composition members to schema objects or refs.
- Build programmatic models with Schema instances only.
When it happens
Trigger: A spec with allOf entries that are scalars, strings, booleans (JSON-Schema-style boolean schemas are not valid OpenAPI 3.x), or malformed maps that did not deserialize to a Schema subclass; code that builds the OpenAPI tree by hand and adds LinkedHashMap/String entries into getAllOf(); YAML indentation mistakes placing a scalar under allOf.
Common situations: Hand-merging specs and leaving a stray value under allOf; converting JSON Schema (which allows boolean schemas) to OpenAPI without rewriting composition entries; tooling that emits '- true' or '- {}'-adjacent artifacts under allOf.
Related errors
- Unknown schema type found in normalizer: {schema}
- Error! oneOf schema is not of the type Schema: {item}
- Error! anyOf schema is not of the type Schema: {item}
- Could not process model '{name}'.Please make sure that your
- Could not process operation: Tag: {tag} Operation: {oper
AI-assisted analysis of OpenAPITools/openapi-generator@fcec517be3 (2026-08-22).
Data as JSON: /api/errors/357ba12f961ac50d.
Report an issue: GitHub.