{"record":{"id":"1c26e5572b9989a8","repo":"OpenAPITools/openapi-generator","slug":"operationid-reserved-word-cannot-be-used","errorCode":null,"errorMessage":"\" + operationId + \" (reserved word) cannot be used as method name","messagePattern":"\" \\+ operationId \\+ \" \\(reserved word\\) cannot be used as method name","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaLagomServerCodegen.java","lineNumber":179,"sourceCode":"    public String getName() {\n        return \"scala-lagom-server-deprecated\";\n    }\n\n    @Override\n    public String getHelp() {\n        return \"Generates a Lagom API server (Beta) in scala. IMPORTANT: this generator has been deprecated\";\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            throw new RuntimeException(operationId + \" (reserved word) cannot be used as method name\");\n        }\n\n        return camelize(operationId, LOWERCASE_FIRST_LETTER);\n    }\n\n    @Override\n    public ModelsMap postProcessModelsEnum(ModelsMap objs) {\n        objs = super.postProcessModelsEnum(objs);\n        for (ModelMap mo : objs.getModels()) {\n            CodegenModel cm = mo.getModel();\n\n            for (CodegenProperty var : cm.vars) {\n                if (var.isEnum) {\n                    List<Object> enumValues = getEnumValues(var.allowableValues);\n\n                    for (final ListIterator<Object> i = enumValues.listIterator(); i.hasNext(); ) {\n                        final String element = String.valueOf(i.next());\n                        i.set(element.replaceAll(\"^\\\"|\\\"$\", \"\"));","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaLagomServerCodegen.java#L161-L197","documentation":"The scala-lagom-server-deprecated generator's toOperationId() checks the (non-empty) operationId against the Scala reserved word list; a reserved word cannot be used as a Scala method name, so generation throws RuntimeException naming the word.","triggerScenarios":"A spec operation with operationId: return / match / type / object / package / val / def / new / class etc., generated with -g scala-lagom-server-deprecated. camelize() does not save you: single-word identifiers pass through unchanged.","commonSituations":"REST operations named after language concepts ('get return policy', 'check type', 'create object') that camelCase to reserved words; specs authored by backend teams unfamiliar with Scala keywords; shared specs that generate fine for Python but fail for Scala.","solutions":["Rename the operationId in the spec to something non-reserved, e.g. returnType -> getReturnType","Use a multi-word operationId; camelization changes single reserved words but 'returnPolicy' is already safe","Add a spec lint rule rejecting the target language's reserved words for operationIds","If the wire operation name must stay, remember operationId only affects the generated method name, not the HTTP path"],"exampleFix":"# before\npaths:\n  /returns/{id}:\n    get:\n      operationId: return\n# after\npaths:\n  /returns/{id}:\n    get:\n      operationId: getReturn","handlingStrategy":"validation","validationCode":"# Reject Scala reserved words as operationIds (Python):\nSCALA_RESERVED = {'abstract','case','catch','class','def','do','else','extends','false','final',\n                  'finally','for','forSome','if','implicit','import','lazy','match','new','null',\n                  'object','override','package','private','protected','return','sealed','super',\n                  'this','throw','trait','true','try','type','val','var','while','with','yield'}\nfor oid in all_operation_ids(spec):\n    assert oid not in SCALA_RESERVED, f'operationId {oid!r} is a Scala reserved word'","typeGuard":null,"tryCatchPattern":"try {\n    new DefaultGenerator().opts(input).generate();\n} catch (RuntimeException e) {\n    // '<word> (reserved word) cannot be used as method name' - rename that operationId in the spec and rerun\n}","preventionTips":["Use verb+noun operationIds (getUser, buildType) instead of bare keywords","Keep a per-target-language reserved word list in your spec authoring guide","Remember the HTTP path is unaffected by operationId, so renaming is API-safe"],"tags":["scala","lagom","codegen","reserved-word","operationid","openapi-generator"],"backgroundTag":"reserved-word-identifier","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}