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
Setter validating the 'modelPropertyNaming' additional property of the plain javascript generator. Accepts only original, camelCase, PascalCase and snake_case (case-sensitive equals chain); anything else throws IllegalArgumentException during processOpts and generation stops before files are written. Default is camelCase.
Source
Thrown at modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClientCodegen.java:639
} else if (ModelUtils.isIntegerSchema(p)) {
if (p.getDefault() != null) {
return p.getDefault().toString();
}
} else if (ModelUtils.isStringSchema(p)) {
if (p.getDefault() != null) {
return "'" + p.getDefault() + "'";
}
}
return null;
}
public void setModelPropertyNaming(String naming) {
if ("original".equals(naming) || "camelCase".equals(naming) ||
"PascalCase".equals(naming) || "snake_case".equals(naming)) {
this.modelPropertyNaming = naming;
} else {
throw new IllegalArgumentException("Invalid model property naming '" +
naming + "'. Must be 'original', 'camelCase', " +
"'PascalCase' or 'snake_case'");
}
}
@Override
public String toDefaultValueWithParam(String name, Schema p) {
String type = normalizeType(getTypeDeclaration(p));
if (!StringUtils.isEmpty(p.get$ref())) {
return " = " + type + ".constructFromObject(data['" + name + "']);";
} else {
return " = ApiClient.convertToType(data['" + name + "'], " + type + ");";
}
}
@Override
public void setParameterExampleValue(CodegenParameter p) {
String example;View on GitHub (pinned to fcec517be3)
Solutions
- Use exactly `original`, `camelCase`, `PascalCase`, or `snake_case`.
- Omit the option — default camelCase applies.
- Verify against `config-help -g javascript` output for your installed CLI version.
Example fix
# before openapi-generator-cli generate -g javascript -i api.yaml -p modelPropertyNaming=snake # after openapi-generator-cli generate -g javascript -i api.yaml -p modelPropertyNaming=snake_case
Defensive patterns
Strategy: validation
Validate before calling
# shell: exact-case allowlist for the plain javascript generator
mpn="${MODEL_PROPERTY_NAMING:-camelCase}"
case "$mpn" in
original|camelCase|PascalCase|snake_case) ;;
*) echo "modelPropertyNaming must be original|camelCase|PascalCase|snake_case, got: $mpn" >&2; exit 2 ;;
esac Type guard
type ModelPropertyNaming = 'original' | 'camelCase' | 'PascalCase' | 'snake_case';
const VALID = new Set(['original', 'camelCase', 'PascalCase', 'snake_case']);
function isModelPropertyNaming(v: string): v is ModelPropertyNaming {
return VALID.has(v);
} Try / catch
try {
new DefaultGenerator().opts(clientOptInput).generate();
} catch (IllegalArgumentException e) {
throw new IllegalStateException("Invalid modelPropertyNaming for javascript: " + e.getMessage(), e);
} Prevention
- Verify values against `config-help -g javascript` for the installed version.
- Keep casing exact: 'camelCase' and 'PascalCase', never 'camelcase'/'pascalcase'.
- Centralize generator options in one script per target language.
When it happens
Trigger: `-g javascript -p modelPropertyNaming=snake` (missing '_case'), `camelcase`, `pascalcase`, `kebab-case`; programmatic setModelPropertyNaming("CamelCase").
Common situations: Copy-pasting the option between generators with different vocabularies; casing typos in YAML pipelines; docs examples that shorten snake_case to snake.
Related errors
- Invalid model property naming '{name}'. Must be 'original',
- Invalid model property naming '{naming}'. Must be 'original'
- Invalid model property naming '{name}'. Must be 'original',
- Invalid model property naming '{name}'. Must be 'original',
- Invalid model property naming '{naming}'. Must be 'original'
AI-assisted analysis of OpenAPITools/openapi-generator@fcec517be3 (2026-08-22).
Data as JSON: /api/errors/c610ffebc9f3d595.
Report an issue: GitHub.