OpenAPITools/openapi-generator · error · IllegalArgumentException
Invalid operationIdNaming: " + operationIdNaming + ". Must b
Error message
Invalid operationIdNaming: " + operationIdNaming + ". Must be PascalCase, camelCase or snake_case
What it means
The R generator's setOperationIdNaming() only accepts the literal strings 'PascalCase', 'camelCase', or 'snake_case' (exact casing); anything else throws IllegalArgumentException. The chosen value also drives the WithHttpInfo suffix used in generated function names ('_with_http_info' for snake_case).
Source
Thrown at modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RClientCodegen.java:666
}
public void setExceptionPackageToUse(String exceptionPackage) {
if (DEFAULT.equals(exceptionPackage))
this.useDefaultExceptionHandling = true;
if (RLANG.equals(exceptionPackage)) {
supportingFiles.add(new SupportingFile("api_exception.mustache", File.separator + "R", "api_exception.R"));
this.useRlangExceptionHandling = true;
}
}
public boolean getUseOneOfDiscriminatorLookup() {
return this.useOneOfDiscriminatorLookup;
}
public void setOperationIdNaming(final String operationIdNaming) {
if (!("PascalCase".equals(operationIdNaming) || "camelCase".equals(operationIdNaming) ||
"snake_case".equals(operationIdNaming))) {
throw new IllegalArgumentException("Invalid operationIdNaming: " + operationIdNaming +
". Must be PascalCase, camelCase or snake_case");
}
if ("snake_case".equals(operationIdNaming)) {
additionalProperties.put("WithHttpInfo", "_with_http_info");
} else {
additionalProperties.put("WithHttpInfo", "WithHttpInfo");
}
this.operationIdNaming = operationIdNaming;
}
@Override
public String escapeQuotationMark(String input) {
// remove " to avoid code injection
return input.replace("\"", "");
}
View on GitHub (pinned to fcec517be3)
Solutions
- Use one of the exact tokens: operationIdNaming=PascalCase, operationIdNaming=camelCase, or operationIdNaming=snake_case
- Check for stray whitespace/quotes in the config file around the value
- If unset, omit the option to keep the default naming
Example fix
# before openapi-generator-cli generate -i api.yaml -g r -c operationIdNaming=snake-case # after openapi-generator-cli generate -i api.yaml -g r -c operationIdNaming=snake_case
Defensive patterns
Strategy: validation
Validate before calling
# bash: exact-token whitelist
OP_NAMING="${OP_NAMING:-}"
[[ -z "${OP_NAMING}" || "${OP_NAMING}" == PascalCase || "${OP_NAMING}" == camelCase || "${OP_NAMING}" == snake_case ]] \
|| { echo 'operationIdNaming must be PascalCase, camelCase or snake_case (exact)'; exit 1; } Try / catch
try {
RClientCodegen codegen = new RClientCodegen();
codegen.setOperationIdNaming("snake_case"); // one of the three exact tokens
new DefaultGenerator().opts(input).generate();
} catch (IllegalArgumentException e) {
// 'Invalid operationIdNaming' - use the exact token and rerun
} Prevention
- Treat the three naming tokens as an enum, not free text
- Beware casing: snake_case is lowercase, PascalCase and camelCase are exact
- Document the allowed tokens next to your generation scripts
When it happens
Trigger: openapi-generator-cli generate -i api.yaml -g r -c operationIdNaming=Pascalcase / snake-case / snake / kebab-case. The comparison is String.equals, so any casing or spelling deviation fails.
Common situations: Users typing the style descriptively ('SnakeCase', 'SCREAMING_SNAKE') instead of the exact token; configs migrated from other generators whose naming options accept different vocabularies (e.g. --operation-id-name vs operationIdNaming).
Related errors
- Invalid HTTP library " + getLibrary() + ". Only httr, httr2
- 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/cd3c1b1cfd27612d.
Report an issue: GitHub.