{"record":{"id":"639af4f079fca95d","repo":"OpenAPITools/openapi-generator","slug":"empty-method-operation-name-operationid-not-allo","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/AbstractApexCodegen.java","lineNumber":413,"sourceCode":"\n        schemaType = getAlias(schemaType);\n\n        // don't apply renaming on types from the typeMapping\n        if (typeMapping.containsKey(schemaType)) {\n            return typeMapping.get(schemaType);\n        }\n\n        if (null == schemaType) {\n            LOGGER.error(\"No Type defined for Property {}\", p);\n        }\n        return toModelName(schemaType);\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        return operationId;\n    }\n\n    @Override\n    public CodegenModel fromModel(String name, Schema model) {\n        CodegenModel cm = super.fromModel(name, model);\n","sourceCodeStart":395,"sourceCodeEnd":431,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractApexCodegen.java#L395-L431","documentation":"AbstractApexCodegen.toOperationId throws when the operation name reaching it is null or empty. Apex generated classes derive method names from operationId, and an empty name would emit invalid Apex, so generation aborts. The framework normally derives a default operationId from path+method, so an explicitly empty value or a custom code path is what reaches this guard.","triggerScenarios":"An OpenAPI operation whose operationId is an empty string and default derivation was bypassed — e.g. a custom generator overriding fromOperation, or programmatic use calling toOperationId directly with a blank id.","commonSituations":"Hand-written specs with 'operationId: \"\"'; specs converted from Postman or API descriptions that drop operationIds; custom Apex generator subclasses that manipulate operationIds before delegation.","solutions":["Give every operation a unique non-empty operationId in the spec.","Remove the empty operationId key entirely (instead of leaving it blank) so path-based default naming can kick in.","If you subclass the Apex generator, ensure overrides never pass an empty string into toOperationId."],"exampleFix":"# before:\npaths:\n  /pets:\n    get:\n      operationId: ''\n# after:\npaths:\n  /pets:\n    get:\n      operationId: listPets","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":["Prefer explicit operationIds in specs over relying on derived defaults.","Remove blank 'operationId: \"\"' keys entirely rather than leaving empty values.","Run a spec lint (e.g. spectral rule on operationId) before invoking the Apex generator."],"tags":["openapi","operationid","apex","code-generation"],"backgroundTag":"missing-operation-id","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}