{"record":{"id":"ba82b9d151e964a6","repo":"OpenAPITools/openapi-generator","slug":"empty-method-name-operationid-not-allowed-ba82b9","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/Swift6ClientCodegen.java","lineNumber":986,"sourceCode":"\n    @Override\n    public String toModelDocFilename(String name) {\n        return toModelName(name);\n    }\n\n    @Override\n    public String toApiDocFilename(String name) {\n        return toApiName(name);\n    }\n\n    @Override\n    public String toOperationId(String operationId) {\n        operationId = camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);\n\n        // Throw exception if method name is empty.\n        // This should not happen but keep the check just in case\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            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(\"{} (starting with a number) cannot be used as method name. Renamed to {}\", operationId, camelize(sanitizeName(\"call_\" + operationId), LOWERCASE_FIRST_LETTER));\n            operationId = camelize(sanitizeName(\"call_\" + operationId), LOWERCASE_FIRST_LETTER);\n        }\n\n        return operationId;\n    }\n","sourceCodeStart":968,"sourceCodeEnd":1004,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Swift6ClientCodegen.java#L968-L1004","documentation":"The Swift 6 generator derives the method name from operationId via sanitizeName plus camelization and rejects an empty result, since Swift methods need a valid identifier. This is the Swift 6 port of the same guard the Swift 5 generator applies.","triggerScenarios":"An operation has no operationId, or an operationId like '///', '-' or whitespace that sanitizes to an empty string after camelization.","commonSituations":"Migrating a project to the swift6 generator with a spec that previously squeaked by; specs with symbol-only operationIds; generated specs where operationId fields are conditionally emitted.","solutions":["Add an explicit, unique, alphanumeric operationId to every operation in the spec.","Replace symbol-only operationIds with real identifiers.","Enforce an operationId-required lint rule in the spec pipeline."],"exampleFix":"# before\npaths:\n  /pets/{id}:\n    delete:\n      operationId: '///'\n\n# after\npaths:\n  /pets/{id}:\n    delete:\n      operationId: deletePet","handlingStrategy":"validation","validationCode":"// node\nconst bad = Object.entries(spec.paths)\n  .flatMap(([p, item]) => Object.values(item).filter(op => op && op.responses)\n    .filter(op => !op.operationId || !/[a-zA-Z0-9]/.test(op.operationId)));\nif (bad.length) throw new Error('operations without usable operationId: ' + bad.length);","typeGuard":"const isValidOperationId = (id: unknown): id is string =>\n  typeof id === 'string' && /[a-zA-Z0-9]/.test(id);","tryCatchPattern":"// Java\ntry { new DefaultGenerator().opts(input).generate(); }\ncatch (RuntimeException e) {\n    // empty-name guard: fix the spec, never retry the same input\n}","preventionTips":["Lint operationId presence before any generator run.","When porting specs to the swift6 generator, diff for empty or symbol-only ids.","Automate id generation (method + path camelization) in the spec pipeline if hand-authoring is error-prone."],"tags":["swift","openapi","spec-validation","naming"],"backgroundTag":"missing-operation-id","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}