{"record":{"id":"c9ae96d9b2afe30e","repo":"OpenAPITools/openapi-generator","slug":"could-not-generate-supporting-file-support","errorCode":null,"errorMessage":"Could not generate supporting file '{support}'","messagePattern":"Could not generate supporting file '(.+?)'","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java","lineNumber":1128,"sourceCode":"                        once(LOGGER).debug(\"Output directory {} not created. It {}.\", outputFolder, of.exists() ? \"already exists.\" : \"may not have appropriate permissions.\");\n                    }\n                }\n\n\n                boolean shouldGenerate = true;\n                if (supportingFilesToGenerate != null && !supportingFilesToGenerate.isEmpty()) {\n                    shouldGenerate = supportingFilesToGenerate.contains(support.getDestinationFilename());\n                }\n\n                File written = processTemplateToFile(bundle, support.getTemplateFile(), outputFilename, shouldGenerate, CodegenConstants.SUPPORTING_FILES);\n                if (written != null) {\n                    files.add(written);\n                    if (config.isEnablePostProcessFile() && !dryRun) {\n                        config.postProcessFile(written, \"supporting-file\");\n                    }\n                }\n            } catch (Exception e) {\n                throw new RuntimeException(\"Could not generate supporting file '\" + support + \"'\", e);\n            }\n        }\n\n        // Consider .openapi-generator-ignore a supporting file\n        // Output .openapi-generator-ignore if it doesn't exist and wasn't explicitly created by a generator\n        // and the option openapiGeneratorIgnoreList is not set\n        if (config.openapiGeneratorIgnoreList() == null || config.openapiGeneratorIgnoreList().isEmpty()) {\n            final String openapiGeneratorIgnore = \".openapi-generator-ignore\";\n            String ignoreFileNameTarget = config.outputFolder() + File.separator + openapiGeneratorIgnore;\n            File ignoreFile = new File(ignoreFileNameTarget);\n            if (generateMetadata) {\n                try {\n                    boolean shouldGenerate = !ignoreFile.exists();\n                    if (shouldGenerate && supportingFilesToGenerate != null && !supportingFilesToGenerate.isEmpty()) {\n                        shouldGenerate = supportingFilesToGenerate.contains(openapiGeneratorIgnore);\n                    }\n                    File written = processTemplateToFile(bundle, openapiGeneratorIgnore, ignoreFileNameTarget, shouldGenerate, CodegenConstants.SUPPORTING_FILES);\n                    if (written != null) {","sourceCodeStart":1110,"sourceCodeEnd":1146,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java#L1110-L1146","documentation":"generateSupportingFiles iterates config.supportingFiles(); each SupportingFile is resolved to an output filename and rendered via processTemplateToFile. Any exception in that block - template file not found in the template engine, template rendering error, or IOException while writing - is wrapped with support.toString() (the supporting file's destination path). The chained cause tells you whether it is a missing template, a rendering failure on the bundle data, or a filesystem error.","triggerScenarios":"A SupportingFile whose templateFile is absent from a --template-dir override (classic partial-copy mistake); a custom template using a lambda or key that is missing from the bundle for the current run scope (e.g. --global-property apis only, so operations/models lists are empty); an output filename containing characters illegal on the OS; unwritable output directory; template engine classpath problems (missing handlebars adapter when engine id is set).","commonSituations":"Teams overriding a subset of templates and the generator release adds NEW supporting files whose templates the override lacks; custom generators shipping a supportingFiles() entry without the corresponding resource; CI running with a narrower scope (--global-property) than the templates were written for.","solutions":["Identify the failing supporting file from the message path, then look up which template name it maps to in the generator's supportingFiles() definition.","Check the chained cause: FileNotFoundException/<template>.mustache => copy that template from the generator's bundled resources into your --template-dir; IOException => fix output-directory permissions/space.","Keep --template-dir overrides complete: re-copy ALL templates from the matching generator version whenever you upgrade, then re-apply your edits.","If you do not need the file, add its destination path to .openapi-generator-ignore - processTemplateToFile skips ignored targets entirely, so generation proceeds without rendering it.","For scope-related failures, run full scope (no --global-property filter) or adjust the custom template to tolerate empty operation/model lists."],"exampleFix":"# before: template override missing pom.hbs -> 'pom.xml' supporting file fails\n# after: copy the missing template from the generator jar into the override\ncp ~/.m2/repository/org/openapi-generator/openapi-generator/6.x/y\n# (illustrative) unzip -p openapi-generator-6.x.jar Java/pom.mustache > my-tpl/pom.mustache","handlingStrategy":"validation","validationCode":"// Pre-flight: every supporting-file template must resolve in the template dir\nString overrideDir = config.getTemplateDir();\nfor (SupportingFile sf : config.supportingFiles()) {\n    if (overrideDir != null && !Files.exists(Path.of(overrideDir, sf.getTemplateFile()))) {\n        throw new IllegalStateException(\n            \"Missing template for supporting file: \" + sf.getTemplateFile());\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    generator.opts(input).generate();\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Could not generate supporting file\")) {\n        String target = e.getMessage().split(\"'\")[1];\n        if (e.getCause() instanceof java.io.FileNotFoundException\n                || e.getCause() instanceof java.io.IOException) {\n            // add target to .openapi-generator-ignore or restore template, then retry\n        }\n        throw new GenerationFailure(\"Supporting file failed: \" + target, e.getCause());\n    }\n    throw e;\n}","preventionTips":["Copy the complete bundled template set into any --template-dir override.","Add new supporting files introduced by generator upgrades to your override checklist (diff release notes).","Use .openapi-generator-ignore to skip supporting files you never consume instead of deleting them post-hoc."],"tags":["openapi-generator","supporting-files","template","io","code-generation"],"backgroundTag":"template-rendering-failure","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}