OpenAPITools/openapi-generator · error · ResponseStatusException

A target generation was attempted, but no files were created

Error message

A target generation was attempted, but no files were created!

What it means

Thrown when DefaultGenerator().opts(...).generate() completed without exception but returned an empty file list (Generator.java:150-161), so there is nothing to zip into the -bundle.zip. The spec parsed and the generator ran; the run simply produced zero output files. Typical specs that trigger this have no paths and no components (a structurally valid but empty document), so every generator skips all write steps.

Source

Thrown at modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/service/Generator.java:159

                }
                codegenConfig.openapiNormalizer().put(ruleOperands[0], ruleOperands[1]);
            }
        }

        codegenConfig.setOutputDir(outputFolder);

        clientOptInput.config(codegenConfig);

        try {
            List<File> files = new DefaultGenerator().opts(clientOptInput).generate();
            if (files.size() > 0) {
                List<File> filesToAdd = new ArrayList<>();
                LOGGER.debug("adding to {}", outputFolder);
                filesToAdd.add(new File(outputFolder));
                ZipUtil zip = new ZipUtil();
                zip.compressFiles(filesToAdd, outputFilename);
            } else {
                throw new ResponseStatusException(HttpStatus.BAD_REQUEST,
                        "A target generation was attempted, but no files were created!");
            }
            for (File file : files) {
                try {
                    file.delete();
                } catch (Exception e) {
                    LOGGER.error("unable to delete file " + file.getAbsolutePath(), e);
                }
            }
            try {
                new File(outputFolder).delete();
            } catch (Exception e) {
                LOGGER.error("unable to delete output folder " + outputFolder, e);
            }
        } catch (Exception e) {
            throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "Unable to build target: " + e.getMessage(), e);
        }
        return outputFilename;

View on GitHub (pinned to fcec517be3)

Solutions

  1. Add at least one path with one operation (get/post/...) to the spec and regenerate
  2. Verify locally that the document has a non-empty paths (or meaningful components for the target generator)
  3. If the spec intentionally has no operations, the online generator cannot produce a bundle — use the CLI with a generator that supports it or skip generation

Example fix

# before
{"openapi":"3.0.0","info":{"title":"t","version":"1"}}          # no paths -> 400 no files were created

# after
{"openapi":"3.0.0","info":{"title":"t","version":"1"},"paths":{"/ping":{"get":{"responses":{"200":{"description":"ok"}}}}}}
Defensive patterns

Strategy: try-catch

Validate before calling

// a spec with no paths and no components generates nothing
OpenAPI o = new OpenAPIParser().readContents(specJson, null, new ParseOptions()).getOpenAPI();
boolean generatable = o != null
    && ((o.getPaths() != null && !o.getPaths().isEmpty())
        || (o.getComponents() != null && o.getComponents().getSchemas() != null && !o.getComponents().getSchemas().isEmpty()));
if (!generatable) throw new IllegalArgumentException("spec has no paths/components; generation would be empty");

Type guard

boolean hasGeneratableContent(OpenAPI o) {
    return o.getPaths() != null && !o.getPaths().isEmpty();
}

Try / catch

catch (HttpClientErrorException.BadRequest e) {
    if (e.getResponseBodyAsString().contains("no files were created")) {
        // spec parsed but produced nothing: add operations, then regenerate
        throw new IllegalStateException("spec skeleton has no operations — nothing to generate", e);
    }
}

Prevention

When it happens

Trigger: Posting {"openapi":"3.0.0","info":{...}} with no "paths" (or paths:{}); specs whose only content lives in extensions the generator ignores; exotic combinations where the selected generator emits only files it later filters out.

Common situations: Starting a spec skeleton and testing the generator before writing any operations; tooling that strips empty paths objects; specs assembled from templates where the paths section failed to merge.

Related errors


AI-assisted analysis of OpenAPITools/openapi-generator@fcec517be3 (2026-08-22). Data as JSON: /api/errors/637d50a8867caa16. Report an issue: GitHub.