OpenAPITools/openapi-generator · critical · MojoExecutionException
The generator requires 'generatorName'. Refer to documentati
Error message
The generator requires 'generatorName'. Refer to documentation for a list of options.
What it means
Thrown by CodeGenMojo when the generate goal has no <generatorName> configured (isNotEmpty check fails). The generator name selects the language/framework (java, python, typescript-fetch, ...), and unlike the CLI the Maven plugin does not prompt for it, so a missing value aborts with this MojoExecutionException pointing at the documentation.
Source
Thrown at modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java:817
}
if (enablePostProcessFile != null) {
configurator.setEnablePostProcessFile(enablePostProcessFile);
}
if (generateAliasAsModel != null) {
configurator.setGenerateAliasAsModel(generateAliasAsModel);
}
if (minimalUpdate != null) {
configurator.setEnableMinimalUpdate(minimalUpdate);
}
if (isNotEmpty(generatorName)) {
configurator.setGeneratorName(generatorName);
} else {
LOGGER.error("A generator name (generatorName) is required.");
throw new MojoExecutionException("The generator requires 'generatorName'. Refer to documentation for a list of options.");
}
configurator.setOutputDir(output.getAbsolutePath());
if (isNotEmpty(auth)) {
configurator.setAuth(auth);
}
if (isNotEmpty(apiPackage)) {
configurator.setApiPackage(apiPackage);
}
if (isNotEmpty(modelPackage)) {
configurator.setModelPackage(modelPackage);
}
if (isNotEmpty(invokerPackage)) {
configurator.setInvokerPackage(invokerPackage);View on GitHub (pinned to fcec517be3)
Solutions
- Add <generatorName>java</generatorName> (or your target generator) to the plugin configuration.
- List installed generators with mvn org.openapitools:openapi-generator-maven-plugin:help or openapi-generator-cli list to confirm the exact name.
- If invoking the goal from the CLI, pass -DgeneratorName=java instead of relying on POM defaults.
- In multi-module builds, put common config in pluginManagement and the generatorName in each module.
Example fix
<!-- before -->
<configuration>
<inputSpec>${project.basedir}/api.yaml</inputSpec>
<output>${project.build.directory}/generated-sources</output>
</configuration>
<!-- after -->
<configuration>
<inputSpec>${project.basedir}/api.yaml</inputSpec>
<generatorName>java</generatorName>
<output>${project.build.directory}/generated-sources</output>
</configuration> Defensive patterns
Strategy: validation
Validate before calling
# CI: assert every openapi-generator generate execution declares a generatorName
for pom in $(git ls-files '*/pom.xml' pom.xml); do
grep -q 'openapi-generator-maven-plugin' "$pom" || continue
grep -q '<generatorName>' "$pom" || { echo "$pom: missing generatorName"; exit 1; }
done Prevention
- Always set <generatorName> explicitly; never assume a default exists in the Maven plugin.
- Confirm exact generator names via openapi-generator-cli list (or the help goal) before writing them into the POM.
- In multi-module builds, keep generatorName per module and shared options in pluginManagement.
- When invoking the goal directly on the CLI, pass -DgeneratorName=... to mirror the POM.
When it happens
Trigger: Generate goal configuration with inputSpec set but no <generatorName> element and no -DgeneratorName=... on the command line. Also when the element is typo'd (<generateName>, <generator>) or when the configuration is inherited from a parent POM's pluginManagement that never defined it.
Common situations: First-time adoption from a minimal example; renaming the property by hand; multi-module builds where one module lacks the inherited configuration; CI invoking the goal directly (mvn openapi-generator:generate) so the POM-bound execution config is bypassed.
Related errors
- inputSpec, inputSpecRootDirectory, or inputSpecFiles must be
- mergedFileOutputDir must be set when inputSpecFiles is used
- inputSpec, inputSpecRootDirectory, or inputSpecFiles must be
- mergedFileOutputDir must be set when inputSpecFiles is used
- Invalid mergeMode value '${mergeMode}'. Valid values are: RE
AI-assisted analysis of OpenAPITools/openapi-generator@fcec517be3 (2026-08-22).
Data as JSON: /api/errors/6be90020319173ce.
Report an issue: GitHub.