{"record":{"id":"c7862169061c1160","repo":"OpenAPITools/openapi-generator","slug":"empty-method-name-operationid-not-allowed","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/AbstractCSharpCodegen.java","lineNumber":1537,"sourceCode":"        return outputFolder + File.separator + sourceFolder + File.separator + packageName + File.separator + apiPackage();\n    }\n\n    @Override\n    public String modelFileFolder() {\n        return outputFolder + File.separator + sourceFolder + File.separator + packageName + File.separator + modelPackage();\n    }\n\n    @Override\n    public String toModelFilename(String name) {\n        // should be the same as the model name\n        return toModelName(name);\n    }\n\n    @Override\n    public String toOperationId(String operationId) {\n        // throw exception if method name is empty (should not occur as an auto-generated method name will be used)\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            LOGGER.warn(\"{} (reserved word) cannot be used as method name. Renamed to {}\", operationId, camelize(sanitizeName(\"call_\" + operationId)));\n            operationId = \"call_\" + operationId;\n        }\n\n        // operationId starts with a number\n        if (operationId.matches(\"^\\\\d.*\")) {\n            LOGGER.warn(\"{} (starting with a number) cannot be used as method name. Renamed to {}\", operationId, camelize(sanitizeName(\"call_\" + operationId)));\n            operationId = \"call_\" + operationId;\n        }\n\n        return camelize(sanitizeName(operationId));\n    }\n\n    @Override","sourceCodeStart":1519,"sourceCodeEnd":1555,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java#L1519-L1555","documentation":"AbstractCSharpCodegen.toOperationId throws when the operation name reaching it is null or empty. C# client/interface method names come from operationId; an empty one would produce uncompilable C#, so generation aborts. The comment in code notes this should not occur under normal flow because an auto-generated name is used, so it signals an empty explicit value or a custom code path.","triggerScenarios":"A spec operation carrying 'operationId: \"\"' combined with a code path that bypasses default operationId derivation, or a custom C# generator override that calls toOperationId with a blank string.","commonSituations":"Specs exported from tools that emit empty operationIds; copy-paste spec surgery that strips the id; custom generators built on AbstractCSharpCodegen manipulating ids first.","solutions":["Set a unique non-empty operationId on every operation.","Delete the empty operationId key rather than leaving a blank value so the default generator can derive a name from the path.","Audit custom generator subclasses to ensure they never forward empty ids to toOperationId."],"exampleFix":"# before:\npaths:\n  /users/{id}:\n    get:\n      operationId: \"\"\n# after:\npaths:\n  /users/{id}:\n    get:\n      operationId: getUserById","handlingStrategy":"validation","validationCode":"// Pre-flight: every operation must have a non-empty operationId\nOpenAPI api = new OpenAPIV3Parser().read(\"spec.yaml\");\napi.getPaths().forEach((path, item) -> item.readOperationsMap().forEach((method, op) -> {\n    String id = op.getOperationId();\n    if (id == null || id.trim().isEmpty())\n        throw new IllegalStateException(method + \" \" + path + \" has an empty operationId\");\n}));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure converter/export tools that produce specs never emit empty operationId strings.","Never leave 'operationId: \"\"' — omit the key so a path-derived default is used.","Validate specs in CI before C# generation runs."],"tags":["openapi","operationid","csharp","code-generation"],"backgroundTag":"missing-operation-id","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}