OpenAPITools/openapi-generator · error · IllegalArgumentException

Invalid file naming '{}'. Must be 'PascalCase', 'camelCase'

Error message

Invalid file naming '{}'. Must be 'PascalCase', 'camelCase' or 'kebab-case'

What it means

The typescript-fetch generator's fileNaming option accepts 'PascalCase', 'camelCase' or 'kebab-case' and throws on anything else during option processing. Its accepted set differs from the Angular generator (which has no PascalCase), so copying options between TypeScript generators is a common trigger.

Source

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

    public Boolean getStringEnums() {
        return this.stringEnums;
    }

    public void setStringEnums(Boolean stringEnums) {
        this.stringEnums = stringEnums;
    }

    /**
     * Set the file naming type.
     *
     * @param fileNaming the file naming to use
     */
    public void setFileNaming(String fileNaming) {
        if (PASCAL_CASE.equals(fileNaming) || CAMEL_CASE.equals(fileNaming) || KEBAB_CASE.equals(fileNaming)) {
            this.fileNaming = fileNaming;
        } else {
            throw new IllegalArgumentException("Invalid file naming '" +
                    fileNaming + "'. Must be 'PascalCase', 'camelCase' or 'kebab-case'");
        }
    }

    public Boolean getSagasAndRecords() {
        return sagasAndRecords;
    }

    public void setSagasAndRecords(Boolean sagasAndRecords) {
        this.sagasAndRecords = sagasAndRecords;
    }

    public String getPassthroughSuffix() {
        return detectPassthroughModelsWithSuffixAndField != null ? detectPassthroughModelsWithSuffixAndField.split("\\.")[0] : null;
    }

    public String getPassthroughField() {
        return detectPassthroughModelsWithSuffixAndField != null ? detectPassthroughModelsWithSuffixAndField.split("\\.")[1] : null;

View on GitHub (pinned to fcec517be3)

Solutions

  1. Set fileNaming to one of 'PascalCase', 'camelCase' or 'kebab-case'.
  2. Keep per-generator option sets instead of one shared blob to avoid cross-generator mismatches.

Example fix

# before
openapi-generator generate -g typescript-fetch -i api.yaml -DfileNaming=snake_case

# after
openapi-generator generate -g typescript-fetch -i api.yaml -DfileNaming=camelCase
Defensive patterns

Strategy: validation

Validate before calling

// node: fetch generator naming allowlist
const NAMING = ['PascalCase', 'camelCase', 'kebab-case'];
if (opts.fileNaming && !NAMING.includes(opts.fileNaming))
  throw new Error(`fileNaming must be one of ${NAMING.join('|')}`);

Type guard

const isFetchFileNaming = (v: string): v is 'PascalCase' | 'camelCase' | 'kebab-case' =>
  ['PascalCase', 'camelCase', 'kebab-case'].includes(v);

Try / catch

// Java
try { new DefaultGenerator().opts(input).generate(); }
catch (IllegalArgumentException e) {
    // pick a supported naming value and rerun; note PascalCase is valid here but not in Angular
}

Prevention

When it happens

Trigger: -DfileNaming=snake_case, 'UPPER', or any value other than PascalCase/camelCase/kebab-case when using -g typescript-fetch.

Common situations: Reusing an options block across generators with different accepted sets; assuming snake_case support because other tools in the pipeline use it; typos like 'Kebab-Case'.

Related errors


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