{"record":{"id":"0ac0cba23b805f22","repo":"OpenAPITools/openapi-generator","slug":"empty-method-operation-name-operationid-not-allo-0ac0cb","errorCode":null,"errorMessage":"Empty method/operation name (operationId) not allowed","messagePattern":"Empty method/operation name \\(operationId\\) not allowed","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClientCodegen.java","lineNumber":843,"sourceCode":"        if (typeMapping.containsKey(openAPIType)) {\n            type = typeMapping.get(openAPIType);\n            if (!needToImport(type)) {\n                return type;\n            }\n        } else {\n            type = openAPIType;\n        }\n        if (null == type) {\n            LOGGER.error(\"No Type defined for Schema {}\", p);\n        }\n        return toModelName(type);\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/operation name (operationId) not allowed\");\n        }\n\n        operationId = camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);\n\n        // method name cannot use reserved keyword, e.g. return\n        if (isReservedWord(operationId)) {\n            String newOperationId = camelize(\"call_\" + operationId, LOWERCASE_FIRST_LETTER);\n            LOGGER.warn(\"{} (reserved word) cannot be used as method name. Renamed to {}\", operationId, newOperationId);\n            return newOperationId;\n        }\n\n        // operationId starts with a number\n        if (operationId.matches(\"^\\\\d.*\")) {\n            String newOperationId = camelize(\"call_\" + operationId, LOWERCASE_FIRST_LETTER);\n            LOGGER.warn(\"{} (starting with a number) cannot be used as method name. Renamed to {}\", operationId, newOperationId);\n            return newOperationId;\n        }\n","sourceCodeStart":825,"sourceCodeEnd":861,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClientCodegen.java#L825-L861","documentation":"toOperationId of the plain javascript generator throws when an operation's operationId is null or empty rather than auto-generating a method name. It runs for every operation, so a single id-less operation aborts the whole generation run with a RuntimeException.","triggerScenarios":"`-g javascript` against a spec where any operation lacks operationId (or has operationId: \"\"); specs converted from Swagger 2.0 or Postman that drop ids; specs assembled from multiple files where one fragment omits ids.","commonSituations":"Large hand-maintained specs where a new endpoint was added without an id; API-first pipelines that never enforced operationId presence.","solutions":["Add unique non-empty operationIds to all operations in the spec.","Pre-fill ids programmatically from method+path before generation (see validationCode).","Add a CI spec-lint step (Spectral operation-operationId-unique plus a presence check) so bad specs fail before the generator runs."],"exampleFix":"# before (api.yaml)\n  /users/{id}:\n    delete:\n      summary: remove user\n# after\n  /users/{id}:\n    delete:\n      operationId: deleteUser\n      summary: remove user","handlingStrategy":"validation","validationCode":"// Java: pre-check every operation for an id before running the javascript generator\nOpenAPI api = new OpenAPIParser().readLocation(\"api.yaml\", null, new ParseOptions()).getOpenAPI();\nList<String> missing = new ArrayList<>();\napi.getPaths().forEach((path, item) -> item.readOperationsMap().forEach((m, op) -> {\n    if (op.getOperationId() == null || op.getOperationId().isBlank()) missing.add(m.name() + \" \" + path);\n}));\nif (!missing.isEmpty()) throw new IllegalStateException(\"Operations missing operationId: \" + missing);","typeGuard":null,"tryCatchPattern":"try {\n    new DefaultGenerator().opts(clientOptInput).generate();\n} catch (RuntimeException e) {\n    failBuild(\"Spec rejected (likely missing operationId): \" + e.getMessage());\n}","preventionTips":["Enforce operationId presence in CI with a Spectral/custom lint step before generation.","Treat 'Empty method/operation name' as a spec defect, not a CLI problem.","When merging spec fragments, run the pre-check to catch id-less additions early."],"tags":["openapi-generator","javascript","openapi-spec","operationid"],"backgroundTag":"missing-operationid","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}