{"record":{"id":"357ba12f961ac50d","repo":"OpenAPITools/openapi-generator","slug":"error-allof-schema-is-not-of-the-type-schema-it","errorCode":null,"errorMessage":"Error! allOf schema is not of the type Schema: {item}","messagePattern":"Error! allOf schema is not of the type Schema: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/OpenAPINormalizer.java","lineNumber":1286,"sourceCode":"        if (schema.getAllOf().size() == 0) {\n            // no more schema in allOf so reset to null instead\n            LOGGER.info(\"Unset/Removed allOf after cleaning up allOf sub-schemas that are not yet supported.\");\n            schema.setAllOf(null);\n        }\n    }\n\n    protected Schema normalizeAllOf(Schema schema, Set<Schema> visitedSchemas) {\n        removeUnsupportedSchemasFromAllOf(schema);\n\n        refactorAllOfWithMetadataOnlySchemas(schema);\n\n        if (schema.getAllOf() == null) {\n            return schema;\n        }\n\n        for (Object item : schema.getAllOf()) {\n            if (!(item instanceof Schema)) {\n                throw new RuntimeException(\"Error! allOf schema is not of the type Schema: \" + item);\n            }\n            // normalize allOf sub schemas one by one\n            normalizeSchema((Schema) item, visitedSchemas);\n        }\n\n        // process rules here\n        processUseAllOfRefAsParent(schema);\n\n        return schema;\n    }\n\n    protected Schema normalizeAllOfWithProperties(Schema schema, Set<Schema> visitedSchemas) {\n        removeUnsupportedSchemasFromAllOf(schema);\n\n        if (schema.getAllOf() == null) {\n            return schema;\n        }\n","sourceCodeStart":1268,"sourceCodeEnd":1304,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/OpenAPINormalizer.java#L1268-L1304","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\ncomponents:\n  schemas:\n    Pet:\n      allOf:\n        - $ref: '#/components/schemas/Animal'\n        - true          # invalid boolean schema under allOf\n# after\ncomponents:\n  schemas:\n    Pet:\n      allOf:\n        - $ref: '#/components/schemas/Animal'\n        - type: object\n          properties:\n            name: { type: string }","handlingStrategy":"validation","validationCode":"// Assert every allOf member is a real Schema instance before generation\nOpenAPI api = ...;\napi.getComponents().getSchemas().forEach((name, s) -> {\n    if (s.getAllOf() != null) {\n        for (Object member : s.getAllOf()) {\n            if (!(member instanceof io.swagger.v3.oas.models.media.Schema)) {\n                throw new IllegalStateException(\"Non-schema allOf member in \" + name + \": \" + member);\n            }\n        }\n    }\n});","typeGuard":"private static boolean hasValidAllOf(Schema s) {\n    return s.getAllOf() == null || s.getAllOf().stream()\n            .allMatch(m -> m instanceof io.swagger.v3.oas.models.media.Schema);\n}","tryCatchPattern":"try {\n    generator.opts(input).generate();\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"allOf schema is not of the type Schema\")) {\n        // message prints the offending item; fix the composition list in the spec\n        throw new GenerationFailure(\"Invalid allOf member: \" + e.getMessage(), e);\n    }\n    throw e;\n}","preventionTips":["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."],"tags":["openapi-generator","openapi","allof","schema","normalizer"],"backgroundTag":"malformed-openapi-schema","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}