OpenAPITools/openapi-generator · error · RuntimeException
Empty method name (operationId) not allowed
Error message
Empty method name (operationId) not allowed
What it means
For the Objective-C client, toOperationId() refuses empty method names: if the operationId it receives is null or empty (StringUtils.isEmpty), it throws a RuntimeException (ObjcClientCodegen.java:619). In the normal pipeline DefaultCodegen synthesizes an operationId from the path and HTTP method when the spec omits it, so this throw indicates an explicitly empty/blank operationId (or a direct programmatic call) rather than a merely absent one.
Source
Thrown at modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ObjcClientCodegen.java:619
*/
@Override
public String escapeReservedWord(String name) {
if (this.reservedWordsMappings().containsKey(name)) {
return this.reservedWordsMappings().get(name);
}
return "_" + name;
}
@SuppressWarnings("static-method")
public String escapeSpecialWord(String name) {
return "var_" + name;
}
@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)) {
final String newName = "call_" + operationId;
LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, newName);
operationId = newName;
}
return camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);
}
@Override
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
OperationMap operations = objs.getOperations();
if (operations != null) {
List<CodegenOperation> ops = operations.getOperation();View on GitHub (pinned to fcec517be3)
Solutions
- Give every operation a unique, non-empty operationId in the spec.
- Remove the empty `operationId:` key entirely so the generator's path+method fallback can synthesize one.
- Add a spec lint rule rejecting empty-string operationIds (distinct from absent operationIds).
Example fix
# before (api.yaml)
paths:
/pets:
get:
operationId: ""
responses: { '200': { description: ok } }
# after
paths:
/pets:
get:
operationId: listPets
responses: { '200': { description: ok } } Defensive patterns
Strategy: validation
Validate before calling
// reject explicitly empty operationIds (absent is fine; the generator synthesizes one)
openAPI.getPaths().forEach((path, item) -> {
for (Operation op : item.readOperations().values()) {
if (op.getOperationId() != null && op.getOperationId().trim().isEmpty()) {
throw new IllegalArgumentException("Empty operationId on " + path
+ " — set a real value or delete the key");
}
}
}); Try / catch
try {
new DefaultGenerator().opts(clientOptInput).generate();
} catch (RuntimeException e) {
throw new BuildException("Objective-C generation failed: " + e.getMessage(), e);
} Prevention
- Treat `operationId: ""` as a lint error, distinct from a missing operationId.
- Prefer always setting explicit, unique operationIds for stable generated API names.
- Check specs produced by converters for blank operationId fields before generation.
When it happens
Trigger: Generating `-g objc` from a spec containing `operationId: ""` (or a whitespace-only value) on some operation; or calling ObjcClientCodegen.toOperationId("") directly in embedded usage.
Common situations: Hand-edited or templated specs where the operationId field was left as an empty string; code-gen pipelines that copy operationIds from an upstream source that sometimes emits empty values; YAML merge keys overriding operationId with an empty anchor.
Related errors
- Empty method name (operationId) not allowed
- Empty method name (operationId) not allowed
- The BLOB and JSON data types cannot be assigned a default va
- Empty database/table/column name for property '{name}' not a
- The BLOB, TEXT, GEOMETRY, and JSON data types cannot be assi
AI-assisted analysis of OpenAPITools/openapi-generator@fcec517be3 (2026-08-22).
Data as JSON: /api/errors/1e227dd1d14a505d.
Report an issue: GitHub.