{"record":{"id":"6072d0bb941018a8","repo":"OpenAPITools/openapi-generator","slug":"empty-method-operation-name-operationid-not-allo-6072d0","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/AbstractJavaCodegen.java","lineNumber":1929,"sourceCode":"    public String getSchemaType(Schema p) {\n        String openAPIType = super.getSchemaType(p);\n\n        // don't apply renaming on types from the typeMapping\n        if (typeMapping.containsKey(openAPIType)) {\n            return typeMapping.get(openAPIType);\n        }\n\n        if (null == openAPIType) {\n            LOGGER.error(\"No Type defined for Schema {}\", p);\n        }\n        return toModelName(openAPIType);\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            LOGGER.warn(operationId + \" (starting with a number) cannot be used as method name. Renamed to \" + camelize(\"call_\" + operationId), true);\n            operationId = camelize(\"call_\" + operationId, LOWERCASE_FIRST_LETTER);\n        }\n\n        return operationId;","sourceCodeStart":1911,"sourceCodeEnd":1947,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java#L1911-L1947","documentation":"AbstractJavaCodegen.toOperationId throws when the operation name reaching it is null or empty. Java interface/client method names are derived from operationId, and an empty one would generate invalid Java, so the run aborts. The framework normally supplies a path-derived default, so this fires when an explicitly empty value or a custom code path bypasses that.","triggerScenarios":"A spec operation with 'operationId: \"\"' processed through a code path that skips default derivation, or a custom Java generator subclass calling toOperationId with a blank id.","commonSituations":"Specs converted from other formats that emit blank operationIds; hand-edited specs; generator subclasses that sanitize/replace ids and can produce empty strings for exotic path names.","solutions":["Assign a unique non-empty operationId to every operation.","Remove the blank operationId key so the default path-based name is generated.","In custom subclasses, guard against passing empty strings into toOperationId."],"exampleFix":"# before:\npaths:\n  /orders:\n    delete:\n      operationId: ''\n# after:\npaths:\n  /orders:\n    delete:\n      operationId: deleteOrder","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":["Always author explicit operationIds in API specs.","Remove blank operationId keys instead of leaving empty strings.","In custom generator subclasses, keep the framework's default-id derivation intact."],"tags":["openapi","operationid","java","code-generation"],"backgroundTag":"missing-operation-id","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}