OpenAPITools/openapi-generator · error · IllegalArgumentException

Invalid ngVersion: " + ngVersion + ". Only Angular v9+ is su

Error message

Invalid ngVersion: " + ngVersion + ". Only Angular v9+ is supported.

What it means

The typescript-angular generator builds templates against Angular APIs that exist only since Angular 9 (Ivy renderer). During supporting-file setup it parses the ngVersion option and throws when the parsed version is below 9.0.0. The default is 22.0.0, so the error only fires when an explicit older version is passed.

Source

Thrown at modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java:221

        supportingFiles.add(new SupportingFile("configuration.mustache", getIndexDirectory(), "configuration.ts"));
        supportingFiles.add(new SupportingFile("api.base.service.mustache", getIndexDirectory(), "api.base.service.ts"));
        supportingFiles.add(new SupportingFile("variables.mustache", getIndexDirectory(), "variables.ts"));
        supportingFiles.add(new SupportingFile("encoder.mustache", getIndexDirectory(), "encoder.ts"));
        supportingFiles.add(new SupportingFile("param.mustache", getIndexDirectory(), "param.ts"));
        supportingFiles.add(new SupportingFile("gitignore", "", ".gitignore"));
        supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
        supportingFiles.add(new SupportingFile("queryParams.mustache", getIndexDirectory(), "query.params.ts"));

        if(ngVersionAtLeast_17) {
            supportingFiles.add(new SupportingFile("README.mustache", getIndexDirectory(), "README.md"));
        }
        else {
            supportingFiles.add(new SupportingFile("README_beforeV17.mustache", getIndexDirectory(), "README.md"));
        }


        if (!ngVersion.atLeast("9.0.0")) {
            throw new IllegalArgumentException("Invalid ngVersion: " + ngVersion + ". Only Angular v9+ is supported.");
        }

        if (additionalProperties.containsKey(NPM_NAME)) {
            addNpmPackageGeneration(ngVersion);
        }

        if (additionalProperties.containsKey(STRING_ENUMS)) {
            setStringEnums(Boolean.parseBoolean(additionalProperties.get(STRING_ENUMS).toString()));
            additionalProperties.put("stringEnums", getStringEnums());
            if (getStringEnums()) {
                classEnumSeparator = "";
            }
        }

        if (additionalProperties.containsKey(WITH_INTERFACES)) {
            boolean withInterfaces = Boolean.parseBoolean(additionalProperties.get(WITH_INTERFACES).toString());
            if (withInterfaces) {
                apiTemplateFiles.put("apiInterface.mustache", "Interface.ts");

View on GitHub (pinned to fcec517be3)

Solutions

  1. Set ngVersion to 9.0.0 or higher, e.g. -DngVersion=17.0.0.
  2. If the app is genuinely Angular 8, pin an old openapi-generator release that still supported it, or migrate the app to a supported Angular version.

Example fix

# before
openapi-generator generate -g typescript-angular -i api.yaml -DngVersion=8.2.14

# after
openapi-generator generate -g typescript-angular -i api.yaml -DngVersion=17.0.0
Defensive patterns

Strategy: validation

Validate before calling

# bash
python3 -c "import sys; from packaging.version import Version; sys.exit(0 if Version('$NG_VERSION') >= Version('9.0.0') else 1)" \
  || { echo "ngVersion must be >= 9.0.0"; exit 1; }

Type guard

const isSupportedNgVersion = (v: string): boolean => {
  const [maj] = v.split('.').map(Number);
  return Number.isFinite(maj) && maj >= 9;
};

Try / catch

// Java
try { new DefaultGenerator().opts(input).generate(); }
catch (IllegalArgumentException e) {
    // ngVersion too old: bump the option to match the project's real Angular major
}

Prevention

When it happens

Trigger: -g typescript-angular with -DngVersion=8.2.14 (any value below 9.0.0).

Common situations: Legacy Angular 8 apps trying to regenerate clients; typos such as ngVersion=4 instead of 14; CI configs pinned to generator options written years ago; MAJOR-only values like ngVersion=8.

Related errors


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