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 k6 generator, which converts property names per the configured convention. The switch covers exactly the four MODEL_PROPERTY_NAMING_TYPE constants (original, camelCase, PascalCase, snake_case), making the default arm unreachable in practice — invalid values fail earlier in setModelPropertyNaming (K6ClientCodegen.java:853) or at valueOf(). The message also reports the property name being converted rather than the bad convention value, which is misleading.
Source
Thrown at modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/K6ClientCodegen.java:768
return reference.toString();
}
private String getTemplateVariable(String input) {
return "${" + input + "}";
}
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) {
// sanitize name
name = sanitizeName(name); // FIXME parameter should not be assigned. Also declare it as "final"
if ("_".equals(name)) {
name = "_u";
}
// if it's all upper case, do nothing
if (name.matches("^[A-Z_]*$")) {
return name;
}View on GitHub (pinned to fcec517be3)
Solutions
- Check the `modelPropertyNaming` option value — the setter at K6ClientCodegen.java:853 is the realistic throw site.
- Use exactly original, camelCase, PascalCase, or snake_case.
- In subclasses, always use the setter rather than assigning the field.
Example fix
# before openapi-generator-cli generate -g k6 -i api.yaml -p modelPropertyNaming=camel_case # after openapi-generator-cli generate -g k6 -i api.yaml -p modelPropertyNaming=camelCase
Defensive patterns
Strategy: validation
Validate before calling
# validate the option; this branch is defensive, the setter at K6ClientCodegen:853 is the gate
mpn="${MODEL_PROPERTY_NAMING:-}"
[ -z "$mpn" ] || 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
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("k6 naming config rejected: " + e.getMessage());
} Prevention
- Validate modelPropertyNaming against the four constants before generation.
- Suspect the setter throw site when this wording appears.
- Use the setter in subclasses; never assign the field.
When it happens
Trigger: Not reachable through supported inputs: `-p modelPropertyNaming=<bad>` is rejected by the setter first. Only direct field assignment in a subclass or a future enum constant without a case could trigger it.
Common situations: Essentially never fires; the same wording thrown from K6ClientCodegen.java:853 is what developers actually encounter.
Related errors
- Invalid model property naming '{naming}'. Must be 'original'
- 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 '{naming}'. Must be 'original'
AI-assisted analysis of OpenAPITools/openapi-generator@fcec517be3 (2026-08-22).
Data as JSON: /api/errors/e7666035f13b3063.
Report an issue: GitHub.