OpenAPITools/openapi-generator · error · RuntimeException
Empty method name (operationId) not allowed
Error message
Empty method name (operationId) not allowed
What it means
The scala-lagom-server-deprecated generator overrides toOperationId() and rejects an empty or null operationId with RuntimeException. openapi-generator normally derives an operationId from method+path when the spec omits one, so this is hit when the spec supplies an explicitly empty operationId (or tooling passes one through as empty).
Source
Thrown at modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaLagomServerCodegen.java:174
public CodegenType getTag() {
return CodegenType.SERVER;
}
@Override
public String getName() {
return "scala-lagom-server-deprecated";
}
@Override
public String getHelp() {
return "Generates a Lagom API server (Beta) in scala. IMPORTANT: this generator has been deprecated";
}
@Override
public String toOperationId(String operationId) {
// throw exception if method name is empty
if (StringUtils.isEmpty(operationId)) {
throw new RuntimeException("Empty method name (operationId) not allowed");
}
// method name cannot use reserved keyword, e.g. return
if (isReservedWord(operationId)) {
throw new RuntimeException(operationId + " (reserved word) cannot be used as method name");
}
return camelize(operationId, LOWERCASE_FIRST_LETTER);
}
@Override
public ModelsMap postProcessModelsEnum(ModelsMap objs) {
objs = super.postProcessModelsEnum(objs);
for (ModelMap mo : objs.getModels()) {
CodegenModel cm = mo.getModel();
for (CodegenProperty var : cm.vars) {
if (var.isEnum) {View on GitHub (pinned to fcec517be3)
Solutions
- Give every operation a non-empty operationId in the spec
- Remove the empty operationId field entirely so the generator derives one from method+path
- Prefer a spec linter (e.g. Spectral rule operation-operationId) in CI to catch empty operationIds before generation
- Migrate off the deprecated Lagom generator if possible
Example fix
# before
paths:
/pets:
get:
operationId: ''
# after
paths:
/pets:
get:
operationId: listPets Defensive patterns
Strategy: validation
Validate before calling
# Lint every operation for a non-empty operationId (Python):
for path, item in spec['paths'].items():
for method, op in item.items():
if method in {'get','put','post','delete','options','head','patch','trace'}:
oid = op.get('operationId')
assert oid and oid.strip(), f'{method.upper()} {path} has an empty operationId' Try / catch
try {
new DefaultGenerator().opts(input).generate();
} catch (RuntimeException e) {
// 'Empty method name (operationId) not allowed' - fill in or delete the empty operationId key, then rerun
} Prevention
- Run a spec linter (Spectral operation-operationId) in CI before generation
- Prefer deleting an unused operationId over leaving it empty so the generator derives one
- Script-generated specs should omit the key, not serialize it as an empty string
When it happens
Trigger: -g scala-lagom-server-deprecated against a spec containing operationId: '' (or a template/null that serializes to empty) on an operation. The check runs per operation during model/operation processing, before files are written.
Common situations: Specs post-processed by scripts that blank out operationIds for dedup; YAML where operationId is present but empty; merging specs where the field was dropped. The generator itself is deprecated, so this mostly appears in legacy pipelines.
Related errors
- " + operationId + " (reserved word) cannot be used as method
- Empty method name (operationId) not allowed
- unsupported status " + resp.code
- " + operationId + " (reserved word) cannot be used as method
- DateLibrary " + dateLibrary + " is not supported. Please use
AI-assisted analysis of OpenAPITools/openapi-generator@fcec517be3 (2026-08-22).
Data as JSON: /api/errors/fe04de41fb0569bd.
Report an issue: GitHub.