OpenAPITools/openapi-generator · error · RuntimeException
Empty method name (operationId) not allowed
Error message
Empty method name (operationId) not allowed
What it means
The Swift Combine generator applies the same guard as the other Swift generators: the method name is computed from operationId by sanitization and camelization, and an empty result throws because a valid Swift identifier is required for the generated API method.
Source
Thrown at modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SwiftCombineClientCodegen.java:460
@Override
public String toModelDocFilename(String name) {
return toModelName(name);
}
@Override
public String toApiDocFilename(String name) {
return toApiName(name);
}
@Override
public String toOperationId(String operationId) {
operationId = camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);
// Throw exception if method name is empty.
// This should not happen but keep the check just in case
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)) {
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("{} (starting with a number) cannot be used as method name. Renamed to {}", operationId, camelize(sanitizeName("call_" + operationId), LOWERCASE_FIRST_LETTER));
operationId = camelize(sanitizeName("call_" + operationId), LOWERCASE_FIRST_LETTER);
}
return operationId;
}View on GitHub (pinned to fcec517be3)
Solutions
- Give the failing operation an explicit alphanumeric operationId.
- Fix or remove placeholder operationIds made of symbols.
- Run a spec linter that requires operationId before invoking the generator.
Example fix
# before
paths:
/feed:
get:
operationId: ''
# after
paths:
/feed:
get:
operationId: getFeed Defensive patterns
Strategy: validation
Validate before calling
// node
const requiresId = (op) => Boolean(op && op.responses);
Object.values(spec.paths).forEach(item =>
Object.values(item).forEach(op => {
if (requiresId(op) && !/[a-zA-Z0-9]/.test(String(op.operationId ?? '')))
throw new Error('operation missing usable operationId');
})); Type guard
const isValidOperationId = (id: unknown): id is string => typeof id === 'string' && /[a-zA-Z0-9]/.test(id);
Try / catch
// Java
try { new DefaultGenerator().opts(input).generate(); }
catch (RuntimeException e) {
// empty operationId after sanitize: patch spec and regenerate once
} Prevention
- Run the same operationId lint for every Swift generator variant (5, 6, Combine).
- Reject placeholder ids (symbols only) in spec review.
- Generate clients from the same linted spec artifact for all target languages.
When it happens
Trigger: An operation with a missing, blank, or symbol-only operationId whose sanitized and camelized form is the empty string.
Common situations: Switching the Combine generator on for an old spec that lacks operationIds; specs edited by hand where an operationId was accidentally emptied; API-portal exports that omit operationId for auto-generated routes.
Related errors
- Empty method name (operationId) not allowed
- Empty method name (operationId) not allowed
- %s is an invalid enum property naming option. Please choose
- Invalid model property naming '%s'. Must be 'original', 'cam
- %s is an invalid enum property naming option. Please choose
AI-assisted analysis of OpenAPITools/openapi-generator@fcec517be3 (2026-08-22).
Data as JSON: /api/errors/af35e8b44e1f4b52.
Report an issue: GitHub.