OpenAPITools/openapi-generator · error · IllegalArgumentException
Invalid file naming '{}'. Must be 'camelCase' or 'kebab-case
Error message
Invalid file naming '{}'. Must be 'camelCase' or 'kebab-case' What it means
The typescript-nestjs client generator supports exactly two file naming strategies, 'camelCase' and 'kebab-case', enforced by setFileNaming (TypeScriptNestjsClientCodegen.java:533). The 'fileNaming' additional property selects how model file names are derived in convertUsingFileNamingConvention; any other value throws this IllegalArgumentException during processOpts.
Source
Thrown at modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNestjsClientCodegen.java:537
*/
private void validateClassSuffixArgument(String argument, String value) {
if (!value.matches(CLASS_NAME_SUFFIX_PATTERN)) {
throw new IllegalArgumentException(
String.format(Locale.ROOT, "%s class suffix only allows alphanumeric characters.", argument)
);
}
}
/**
* Set the file naming type.
*
* @param fileNaming the file naming to use
*/
private void setFileNaming(String fileNaming) {
if ("camelCase".equals(fileNaming) || "kebab-case".equals(fileNaming)) {
this.fileNaming = fileNaming;
} else {
throw new IllegalArgumentException("Invalid file naming '" +
fileNaming + "'. Must be 'camelCase' or 'kebab-case'");
}
}
/**
* Converts the original name according to the current <code>fileNaming</code> strategy.
*
* @param originalName the original name to transform
* @return the transformed name
*/
private String convertUsingFileNamingConvention(String originalName) {
String name = this.removeModelPrefixSuffix(originalName);
if ("kebab-case".equals(fileNaming)) {
name = dashize(underscore(name));
} else {
name = camelize(name, LOWERCASE_FIRST_LETTER);
}
return name;View on GitHub (pinned to fcec517be3)
Solutions
- Set fileNaming to exactly 'camelCase' or 'kebab-case' (case-sensitive, kebab needs the dash).
- If you omitted the option but still see the error, search your spec's vendor extensions or config file for a 'fileNaming' key with a stray value.
Example fix
# before openapi-generator-cli generate -g typescript-nestjs -DfileNaming=snake_case # after openapi-generator-cli generate -g typescript-nestjs -DfileNaming=kebab-case
Defensive patterns
Strategy: validation
Validate before calling
case "$FILE_NAMING" in camelCase|kebab-case|"") ;; *) echo "ERROR: fileNaming must be 'camelCase' or 'kebab-case'" >&2; exit 1;; esac
Type guard
const FILE_NAMING_VALUES = ['camelCase', 'kebab-case'] as const; type FileNaming = typeof FILE_NAMING_VALUES[number]; const isFileNaming = (v: string): v is FileNaming => (FILE_NAMING_VALUES as readonly string[]).includes(v);
Prevention
- Treat fileNaming as an enum, not free text; validate against the two literals in your build tooling.
- Copy option values from the generator's own docs (`openapi-generator-cli config-help -g typescript-nestjs`), not from other generators.
When it happens
Trigger: Running with -DfileNaming=snake_case, -DfileNaming=PascalCase, or a typo like -DfileNaming=kebabcase. The check is an exact string comparison, so casing matters.
Common situations: Porting specs/build scripts from other generators (e.g. typescript-fetch, java) whose file naming options accept different vocabularies like 'snake_case' or 'PascalCase'; assuming kebabcase without the dash works.
Related errors
- %s file suffix only allows '.', '-' and alphanumeric charact
- %s file suffix only allows '.', '-' and alphanumeric charact
- Invalid file naming '{}'. Must be 'camelCase' or 'kebab-case
- %s class suffix only allows alphanumeric characters.
- %s class suffix only allows alphanumeric characters.
AI-assisted analysis of OpenAPITools/openapi-generator@fcec517be3 (2026-08-22).
Data as JSON: /api/errors/d026998c4ce34039.
Report an issue: GitHub.