OpenAPITools/openapi-generator · error · RuntimeException

Empty method/operation name (operationId) not allowed

Error message

Empty method/operation name (operationId) not allowed

What it means

toOperationId of the javascript-closure-angular generator rejects empty/missing operationIds instead of synthesizing one. Like the other JavaScript generators, every operation in the OpenAPI document must carry a non-empty operationId or generation aborts with a RuntimeException at the first offender.

Source

Thrown at modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClosureAngularClientCodegen.java:304

                }
            }
        }
        return objs;
    }

    @Override
    public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
        List<Map<String, String>> imports = objs.getImports();
        imports.sort(Comparator.comparing(o -> o.get("import")));
        objs.put("imports", imports);
        return objs;
    }

    @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;
        }

        return operationId;
    }

    @Override
    public String escapeQuotationMark(String input) {
        // remove ', " to avoid code injection
        return input.replace("\"", "").replace("'", "");

View on GitHub (pinned to fcec517be3)

Solutions

  1. Add unique non-empty operationIds to every operation in the spec.
  2. Pre-validate the spec for operationId presence (see validationCode) before invoking the generator.
  3. If the spec is third-party, request/derive ids upstream rather than patching generated code.

Example fix

# before (api.yaml)
  /orders:
    post:
      summary: create order
# after
  /orders:
    post:
      operationId: createOrder
      summary: create order
Defensive patterns

Strategy: validation

Validate before calling

// Java: same pre-check, aimed at javascript-closure-angular
OpenAPI api = new OpenAPIParser().readLocation("api.yaml", null, new ParseOptions()).getOpenAPI();
api.getPaths().forEach((path, item) -> item.readOperations().forEach((method, op) -> {
    if (op == null || op.getOperationId() == null || op.getOperationId().trim().isEmpty())
        throw new IllegalStateException("closure-angular requires operationId on " + method.toUpperCase() + " " + path);
}));

Try / catch

try {
    new DefaultGenerator().opts(clientOptInput).generate();
} catch (RuntimeException e) {
    failBuild("Spec missing operationId (javascript-closure-angular): " + e.getMessage());
}

Prevention

When it happens

Trigger: `-g javascript-closure-angular` run against a spec containing an operation without operationId (or an empty string one); typically converted or hand-merged specs.

Common situations: Legacy Google Closure Angular projects regenerating from specs that evolved and lost ids; batch conversion scripts that assume all generators tolerate missing ids.

Related errors


AI-assisted analysis of OpenAPITools/openapi-generator@fcec517be3 (2026-08-22). Data as JSON: /api/errors/3e93c3f08f89ce9d. Report an issue: GitHub.