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
- Set fileNaming to one of 'PascalCase', 'camelCase' or 'kebab-case'.
- 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
- Keep per-generator option sets; do not copy fileNaming between generators.
- Maintain an allowlist per generator in the pipeline config.
- Run generation in CI so invalid values fail the build, not a local run.
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
- %s file suffix only allows '.', '-' and alphanumeric charact
- %s class prefix only allows alphanumeric characters.
- %s class suffix only allows alphanumeric characters.
- Invalid file naming '{}'. Must be 'camelCase' or 'kebab-case
- %s is an invalid enum property naming option. Please choose
AI-assisted analysis of OpenAPITools/openapi-generator@fcec517be3 (2026-08-22).
Data as JSON: /api/errors/4594af14bd4f0434.
Report an issue: GitHub.