OpenAPITools/openapi-generator · error · RuntimeException
Empty method/operation name (operationId) not allowed
Error message
Empty method/operation name (operationId) not allowed
What it means
AbstractScalaCodegen.toOperationId throws RuntimeException when the operationId handed to it is empty. The default pipeline normally substitutes a synthesized id (derived from the operation summary, else from method + path) before this point, so an empty id reaching the guard means synthesis was skipped or itself produced nothing usable.
Source
Thrown at modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractScalaCodegen.java:591
return;
}
String scalaPostProcessFile = System.getenv("SCALA_POST_PROCESS_FILE");
if (StringUtils.isEmpty(scalaPostProcessFile)) {
return; // skip if SCALA_POST_PROCESS_FILE env variable is not defined
}
// only process files with scala extension
if ("scala".equals(FilenameUtils.getExtension(file.toString()))) {
this.executePostProcessor(new String[]{scalaPostProcessFile, file.toString()});
}
}
@Override
public String toOperationId(String operationId) {
// throw exception if method name is empty
if (StringUtils.isEmpty(operationId)) {
throw new RuntimeException("Empty method/operation name (operationId) not allowed");
}
operationId = camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
String newOperationId = camelize("call_" + operationId, LOWERCASE_FIRST_LETTER);
LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newOperationId);
return newOperationId;
}
// operationId starts with a number
if (operationId.matches("^\\d.*")) {
LOGGER.warn(operationId + " (starting with a number) cannot be used as method sname. Renamed to " + camelize("call_" + operationId), true);
operationId = camelize("call_" + operationId, LOWERCASE_FIRST_LETTER);
}
return operationId;View on GitHub (pinned to fcec517be3)
Solutions
- Set a unique non-empty operationId on every operation
- Delete empty operationId keys so summary/path-based fallback naming applies
- If relying on fallback naming, keep a summary with at least some word characters
Example fix
# before
get:
operationId: ''
responses: { '200': { description: ok } }
# after
get:
operationId: list_users
responses: { '200': { description: ok } } Defensive patterns
Strategy: validation
Validate before calling
// JS: no empty operationIds; usable summary when id absent
for (const [p, item] of Object.entries(spec.paths || {})) {
for (const [m, op] of Object.entries(item)) {
if (!op || !op.responses) continue;
if (op.operationId === '') fail(`${m} ${p}: empty operationId`);
}
} Try / catch
try { generator.generate(); } catch (RuntimeException e) { if ("Empty method/operation name (operationId) not allowed".equals(e.getMessage())) { /* set operationId or a word-bearing summary on the failing operation */ } throw e; } Prevention
- Always set explicit operationIds in authored specs
- Fail template pipelines on empty rendered ids
- Keep summaries that contain at least one word character
When it happens
Trigger: operationId: "" explicitly set with no summary, or a summary consisting solely of characters that sanitize away (pure symbols/emoji); also direct programmatic use of the generator API passing an empty operationId. Reserved-word or digit-leading ids do NOT throw — those are renamed via camelize('call_' + ...).
Common situations: Templated spec pipelines rendering operationId from data that can be empty; scraping/conversion tools that blank ids; specs whose only summary is decorative characters.
Related errors
- Empty method name (operationId) not allowed
- Empty method name (operationId) not allowed
- Empty method/operation name (operationId) not allowed
- Empty method/operation name (operationId) not allowed
- Empty method/operation name (operationId) not allowed
AI-assisted analysis of OpenAPITools/openapi-generator@fcec517be3 (2026-08-22).
Data as JSON: /api/errors/c623ada517815152.
Report an issue: GitHub.