{"record":{"id":"1e227dd1d14a505d","repo":"OpenAPITools/openapi-generator","slug":"empty-method-name-operationid-not-allowed-1e227d","errorCode":null,"errorMessage":"Empty method name (operationId) not allowed","messagePattern":"Empty method name \\(operationId\\) not allowed","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ObjcClientCodegen.java","lineNumber":619,"sourceCode":"     */\n    @Override\n    public String escapeReservedWord(String name) {\n        if (this.reservedWordsMappings().containsKey(name)) {\n            return this.reservedWordsMappings().get(name);\n        }\n        return \"_\" + name;\n    }\n\n    @SuppressWarnings(\"static-method\")\n    public String escapeSpecialWord(String name) {\n        return \"var_\" + name;\n    }\n\n    @Override\n    public String toOperationId(String operationId) {\n        // throw exception if method name is empty\n        if (StringUtils.isEmpty(operationId)) {\n            throw new RuntimeException(\"Empty method name (operationId) not allowed\");\n        }\n\n        // method name cannot use reserved keyword, e.g. return\n        if (isReservedWord(operationId)) {\n            final String newName = \"call_\" + operationId;\n            LOGGER.warn(\"{} (reserved word) cannot be used as method name. Renamed to {}\", operationId, newName);\n            operationId = newName;\n        }\n\n        return camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);\n    }\n\n    @Override\n    public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {\n        OperationMap operations = objs.getOperations();\n\n        if (operations != null) {\n            List<CodegenOperation> ops = operations.getOperation();","sourceCodeStart":601,"sourceCodeEnd":637,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ObjcClientCodegen.java#L601-L637","documentation":"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.","triggerScenarios":"Generating `-g objc` from a spec containing `operationId: \"\"` (or a whitespace-only value) on some operation; or calling ObjcClientCodegen.toOperationId(\"\") directly in embedded usage.","commonSituations":"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.","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)."],"exampleFix":"# before (api.yaml)\npaths:\n  /pets:\n    get:\n      operationId: \"\"\n      responses: { '200': { description: ok } }\n# after\npaths:\n  /pets:\n    get:\n      operationId: listPets\n      responses: { '200': { description: ok } }","handlingStrategy":"validation","validationCode":"// reject explicitly empty operationIds (absent is fine; the generator synthesizes one)\nopenAPI.getPaths().forEach((path, item) -> {\n  for (Operation op : item.readOperations().values()) {\n    if (op.getOperationId() != null && op.getOperationId().trim().isEmpty()) {\n      throw new IllegalArgumentException(\"Empty operationId on \" + path\n          + \" — set a real value or delete the key\");\n    }\n  }\n});","typeGuard":null,"tryCatchPattern":"try {\n    new DefaultGenerator().opts(clientOptInput).generate();\n} catch (RuntimeException e) {\n    throw new BuildException(\"Objective-C generation failed: \" + e.getMessage(), e);\n}","preventionTips":["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."],"tags":["objective-c","operation-id","openapi-spec","openapi-generator","spec-validation"],"backgroundTag":"missing-operation-id","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}