{"record":{"id":"13dbcb47c493713b","repo":"OpenAPITools/openapi-generator","slug":"could-not-process-model-name-please-make-sure","errorCode":null,"errorMessage":"Could not process model '{name}'.Please make sure that your schema is correct!","messagePattern":"Could not process model '(.+?)'\\.Please make sure that your schema is correct!","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java","lineNumber":530,"sourceCode":"                        LOGGER.info(\"Model {} not generated since it's an alias to map (without property) and `generateAliasAsModel` is set to false (default)\", name);\n                        continue;\n                    }\n                } else if (ModelUtils.isArraySchema(schema)) { // check to see if it's an \"array\" model\n                    if (!ModelUtils.shouldGenerateArrayModel(schema)) {\n                        // schema without property, i.e. alias to array\n                        LOGGER.info(\"Model {} not generated since it's an alias to array (without property) and `generateAliasAsModel` is set to false (default)\", name);\n                        continue;\n                    }\n                }\n\n                Map<String, Schema> schemaMap = new HashMap<>();\n                schemaMap.put(name, schema);\n                ModelsMap models = processModels(config, schemaMap);\n                models.put(\"classname\", config.toModelName(name));\n                models.putAll(config.additionalProperties());\n                allProcessedModels.put(name, models);\n            } catch (Exception e) {\n                throw new RuntimeException(\"Could not process model '\" + name + \"'\" + \".Please make sure that your schema is correct!\", e);\n            }\n        }\n\n        // loop through all models to update children models, isSelfReference, isCircularReference, etc\n        allProcessedModels = config.updateAllModels(allProcessedModels);\n\n        // post process all processed models\n        allProcessedModels = config.postProcessAllModels(allProcessedModels);\n\n        if (generateRecursiveDependentModels) {\n            for (ModelsMap modelsMap : allProcessedModels.values()) {\n                for (ModelMap mm : modelsMap.getModels()) {\n                    CodegenModel cm = mm.getModel();\n                    if (cm != null) {\n                        for (CodegenProperty variable : cm.getVars()) {\n                            generateModelsForVariable(files, allModels, unusedModels, aliasModels, processedModels, variable);\n                        }\n                        //TODO:  handle interfaces","sourceCodeStart":512,"sourceCodeEnd":548,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java#L512-L548","documentation":"DefaultGenerator.generate() loops over every entry in components/schemas, builds a single-entry map and runs processModels(config, schemaMap) plus model-name mapping and additionalProperties merging. ANY exception raised while converting that schema into a Codegen model (naming, type resolution, property processing, post-processing) is caught and rethrown as this RuntimeException with the offending model name. It is a pure wrapper: the real failure is always the chained 'Caused by' exception, and the model named in the message is the one to inspect in your spec.","triggerScenarios":"A components/schemas entry whose processing throws: dangling $ref (referenced schema missing), a schema/property name that the generator's sanitizer turns into an invalid or colliding identifier, an enum with null/empty values, additionalProperties or items nodes that are malformed, unsupported 'type'+'format' combinations hitting a generator NPE, or circular/nested allOf that breaks parent resolution. The spec parsed leniently (SwaggerParser does not fully validate) but fails during model conversion.","commonSituations":"Hand-edited YAML with a typo in a $ref path ('#/components/schemas/Categories' vs 'Category'); specs exported from Postman/Stoplight or another codegen tool producing empty 'type: object' nodes with odd defaults; schema names starting with a digit or containing characters the target language rejects; upgrading openapi-generator and hitting changed naming rules; inline schemas that worked in 3.0 but regress in a newer minor release.","solutions":["Read the full stack trace to the innermost 'Caused by:' - that names the actual defect (e.g. NullPointerException in fromProperty, ambiguous parent resolution) and the fix targets it, not this wrapper.","Validate the spec before generating: 'openapi-generator-cli validate -i spec.yaml' or the online editor; fix every reported dangling reference or malformed node.","Extract the model named in the message into a minimal one-schema spec and reproduce; this isolates whether the defect is the schema itself or its interaction with others.","If the root cause is naming (reserved word, leading digit, special characters), rename the schema/property in the spec or remap it with the generator's model-name/property-name options (e.g. --additional-properties modelNamePrefix/ modelMappings) instead of fighting the sanitizer.","If the stack trace points inside the generator (no obvious spec defect), upgrade to the latest openapi-generator - model-processing bugs on edge-case schemas are patched frequently."],"exampleFix":"# before (components/schemas)\nPet:\n  properties:\n    category:\n      $ref: '#/components/schemas/Categories'   # typo: schema is 'Category'\n# after\nPet:\n  properties:\n    category:\n      $ref: '#/components/schemas/Category'","handlingStrategy":"try-catch","validationCode":"// Validate the spec (including reference resolution) before generating\nio.swagger.v3.parser.OpenAPIParser parser = new io.swagger.v3.parser.OpenAPIParser();\nio.swagger.v3.parser.core.models.SwaggerParseResult result =\n        parser.readLocation(\"api.yaml\", null, null);\nif (result.getOpenAPI() == null || !result.getMessages().isEmpty()) {\n    throw new IllegalArgumentException(\"Invalid spec: \" + result.getMessages());\n}","typeGuard":null,"tryCatchPattern":"try {\n    generator.opts(input).generate();\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Could not process model\")) {\n        String modelName = e.getMessage().split(\"'\")[1]; // extract failing model\n        // surface modelName + root cause to the user, keep the chain\n        throw new GenerationFailure(\"Spec model failed: \" + modelName, e.getCause());\n    }\n    throw e;\n}","preventionTips":["Gate every generation run behind 'openapi-generator-cli validate' in CI.","Resolve all $refs to local components/schemas entries; avoid cross-file refs unless bundling is verified.","Pin the generator version so naming-rule changes cannot surface mid-sprint."],"tags":["openapi-generator","openapi","schema","model","yaml","code-generation"],"backgroundTag":"openapi-schema-processing-failure","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}