OpenAPITools/openapi-generator · error · IllegalArgumentException
Invalid model property naming '{name}'. Must be 'original',
Error message
Invalid model property naming '{name}'. Must be 'original', 'camelCase', 'PascalCase' or 'snake_case' What it means
Defensive default arm inside getNameUsingModelPropertyNaming of the plain javascript generator: it rewrites property names according to the configured convention. The switch covers exactly the MODEL_PROPERTY_NAMING_TYPE constants (original, camelCase, PascalCase, snake_case), so the default arm is effectively unreachable — invalid values are rejected earlier by setModelPropertyNaming (JavascriptClientCodegen.java:639) or by valueOf(). The message prints the property name being converted instead of the bad convention, which is misleading.
Source
Thrown at modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClientCodegen.java:487
}
@Override
public String toModelTestFilename(String name) {
return toModelName(name) + ".spec";
}
private String getNameUsingModelPropertyNaming(String name) {
switch (CodegenConstants.MODEL_PROPERTY_NAMING_TYPE.valueOf(getModelPropertyNaming())) {
case original:
return name;
case camelCase:
return camelize(name, LOWERCASE_FIRST_LETTER);
case PascalCase:
return camelize(name);
case snake_case:
return underscore(name);
default:
throw new IllegalArgumentException("Invalid model property naming '" +
name + "'. 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);
}
// sanitize name
name = sanitizeName(name); // FIXME parameter should not be assigned. Also declare it as "final"
if ("_".equals(name)) {
name = "_u";
}View on GitHub (pinned to fcec517be3)
Solutions
- Check your `modelPropertyNaming` value — the setter at JavascriptClientCodegen.java:639 is the realistic source of this message.
- Use exactly original, camelCase, PascalCase, or snake_case.
- Set the convention only through the setter / additionalProperties, never by field access in subclasses.
Example fix
# before openapi-generator-cli generate -g javascript -i api.yaml -p modelPropertyNaming=Pascal_Case # after openapi-generator-cli generate -g javascript -i api.yaml -p modelPropertyNaming=PascalCase
Defensive patterns
Strategy: validation
Validate before calling
# validate the option — the default branch here is defensive; the setter is the real gate
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
openapi-generator-cli generate -g javascript -i api.yaml -p modelPropertyNaming="$mpn" Type guard
private static final java.util.Set<String> NAMING_CONVENTIONS =
java.util.Set.of("original", "camelCase", "PascalCase", "snake_case");
boolean isValidNamingConvention(String v) {
return v != null && NAMING_CONVENTIONS.contains(v);
} Try / catch
try {
new DefaultGenerator().opts(clientOptInput).generate();
} catch (RuntimeException e) {
failBuild("javascript generator naming config rejected: " + e.getMessage());
} Prevention
- Check the modelPropertyNaming value first when this wording appears; the setter throw site is the realistic source.
- Use the four-constant allowlist in your build script.
- Never assign the convention by field access in subclasses.
When it happens
Trigger: Not reachable via supported inputs: `-p modelPropertyNaming=<bad>` fails first in the setter. Only subclasses assigning the modelPropertyNaming field directly, or a future enum constant without a matching case, could land here.
Common situations: Almost never fires; developers hitting this text usually did so via the identically-worded setter error caused by a misspelled modelPropertyNaming value.
Related errors
- Invalid model property naming '{name}'. Must be 'original',
- Invalid model property naming '{naming}'. Must be 'original'
- Invalid model property naming '{naming}'. 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/26acfe6792ad2c94.
Report an issue: GitHub.