OpenAPITools/openapi-generator · error · IllegalArgumentException
Invalid model property naming '{naming}'. Must be 'original'
Error message
Invalid model property naming '{naming}'. Must be 'original', 'camelCase', 'PascalCase' or 'snake_case' What it means
AbstractScalaCodegen.setModelPropertyNaming calls CodegenConstants.ENUM_PROPERTY_NAMING_TYPE.valueOf(naming). An unrecognized string makes valueOf throw IllegalArgumentException, rethrown with the allowed list 'original', 'camelCase', 'PascalCase', 'snake_case' — matched case-sensitively against the enum constant names.
Source
Thrown at modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractScalaCodegen.java:270
public void setDateLibrary(String dateLibrary, boolean withLegacy) {
if (withLegacy && dateLibrary.equals(DateLibraries.legacy.name())) {
this.dateLibrary = dateLibrary;
return;
}
for (DateLibraries dateLib : DateLibraries.values()) {
if (dateLib.name().equals(dateLibrary)) {
this.dateLibrary = dateLibrary;
return;
}
}
throw new IllegalArgumentException("Invalid dateLibrary. Must be 'java8' or 'joda'");
}
public void setModelPropertyNaming(String naming) {
try {
this.modelPropertyNaming = CodegenConstants.ENUM_PROPERTY_NAMING_TYPE.valueOf(naming).name();
} catch (IllegalArgumentException ex) {
throw new IllegalArgumentException("Invalid model property naming '" +
naming + "'. Must be 'original', 'camelCase', " +
"'PascalCase' or 'snake_case'");
}
}
@Override
public String toVarName(String name) {
// obtain the name from nameMapping directly if provided
if (nameMapping.containsKey(name)) {
return nameMapping.get(name);
}
String varName = sanitizeName(name);
if ("_".equals(varName)) {
varName = "_u";
}View on GitHub (pinned to fcec517be3)
Solutions
- Pass one of the exact values: original, camelCase, PascalCase, snake_case
- For underscore naming write it fully: -p modelPropertyNaming=snake_case
- Omit the option to keep the generator default while you check the README table
Example fix
# before -p modelPropertyNaming=snake # after -p modelPropertyNaming=snake_case
Defensive patterns
Strategy: validation
Validate before calling
// Java: validate against the enum before applying
try {
CodegenConstants.ENUM_PROPERTY_NAMING_TYPE.valueOf(naming);
} catch (IllegalArgumentException ex) {
throw new IllegalArgumentException("modelPropertyNaming must be original, camelCase, PascalCase or snake_case");
} Try / catch
try { generator.generate(); } catch (IllegalArgumentException e) { if (e.getMessage().contains("Invalid model property naming")) { /* fix the casing option value */ } throw e; } Prevention
- Copy option values from the generator's README table, exactly as printed
- Treat naming values as case-sensitive enum names
- Centralize generator options in a reviewed config file
When it happens
Trigger: -p modelPropertyNaming=<bad> on Scala generators: 'snake' (missing _case), 'Pascalcase' or 'pascalcase' (wrong case), 'kebab-case', 'hyphen', 'camel_case'.
Common situations: Muscle memory from other tools' naming options; assuming case-insensitive matching; copy-pasting values between generators whose option vocabularies differ.
Related errors
- Invalid dateLibrary. Must be 'java8' or 'joda'
- %s is an invalid enum property naming option. Please choose
- Invalid model property naming '%s'. Must be 'original', 'cam
- %s is an invalid enum property naming option. Please choose
- %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/b961d78636234ec1.
Report an issue: GitHub.