{"record":{"id":"ffc2d7e235b3214f","repo":"OpenAPITools/openapi-generator","slug":"empty-method-name-operationid-not-allowed-ffc2d7","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/PowerShellClientCodegen.java","lineNumber":983,"sourceCode":"     */\n    @Override\n    public String getTypeDeclaration(Schema p) {\n        if (ModelUtils.isArraySchema(p)) {\n            Schema inner = ModelUtils.getSchemaItems(p);\n            return getTypeDeclaration(inner) + \"[]\";\n        } else if (ModelUtils.isMapSchema(p)) {\n            return \"System.Collections.Hashtable\";\n        } else if (!languageSpecificPrimitives.contains(getSchemaType(p))) {\n            return super.getTypeDeclaration(p);\n        }\n        return super.getTypeDeclaration(p);\n    }\n\n    @Override\n    public String toOperationId(String operationId) {\n        // throw exception if method name is empty (should not occur as an auto-generated method name will be used)\n        if (StringUtils.isEmpty(operationId)) {\n            throw new RuntimeException(\"Empty method name (operationId) not allowed\");\n        }\n\n        return sanitizeName(operationId);\n    }\n\n    @Override\n    public String toParamName(String name) {\n        // obtain the name from parameterNameMapping directly if provided\n        if (parameterNameMapping.containsKey(name)) {\n            return parameterNameMapping.get(name);\n        }\n\n        // sanitize and camelize parameter name\n        // pet_id => PetId\n        name = camelize(sanitizeName(name));\n\n        // for param name reserved word or word starting with number, append _\n        if (paramNameReservedWords.contains(name) || name.matches(\"^\\\\d.*\")) {","sourceCodeStart":965,"sourceCodeEnd":1001,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PowerShellClientCodegen.java#L965-L1001","documentation":"The PowerShell client's toOperationId() throws a RuntimeException when the operationId it receives is empty (PowerShellClientCodegen.java:983). The code comment notes this 'should not occur' because the core pipeline auto-generates a method name from path+method when operationId is absent — so an explicit empty-string operationId (or a direct programmatic call) is what trips it.","triggerScenarios":"Generating `-g powershell` from a spec with `operationId: \"\"` on an operation; or calling PowerShellClientCodegen.toOperationId(\"\") directly in embedded generation code.","commonSituations":"Templated specs where operationId is left blank for later filling; pipelines merging specs where a merge key overwrites operationId with an empty anchor; upstream API exports that emit empty operationIds for undocumented endpoints.","solutions":["Set a unique non-empty operationId on every operation.","Delete the empty `operationId:` key so the auto-generation fallback can name the method.","Lint specs for empty-string operationIds in CI before code generation."],"exampleFix":"# before (api.yaml)\npaths:\n  /users/{id}:\n    delete:\n      operationId: \"\"\n      responses: { '204': { description: deleted } }\n# after\npaths:\n  /users/{id}:\n    delete:\n      operationId: deleteUser\n      responses: { '204': { description: deleted } }","handlingStrategy":"validation","validationCode":"// powershell: empty-string operationIds break toOperationId; absent ones are synthesized\nopenAPI.getPaths().forEach((path, item) -> {\n  for (Operation op : item.readOperations().values()) {\n    if (op.getOperationId() != null && op.getOperationId().trim().isEmpty()) {\n      throw new IllegalArgumentException(\"Empty operationId on \" + path\n          + \" — set a value or remove the key\");\n    }\n  }\n});","typeGuard":null,"tryCatchPattern":"try {\n    new DefaultGenerator().opts(clientOptInput).generate();\n} catch (RuntimeException e) {\n    throw new BuildException(\"PowerShell generation failed: \" + e.getMessage(), e);\n}","preventionTips":["Blanket-set unique operationIds in every spec instead of relying on synthesized names.","Reject empty operationId strings in spec lint (different rule from missing operationId).","Inspect converter output for blank operationId fields before feeding it to the generator."],"tags":["powershell","operation-id","openapi-spec","openapi-generator","spec-validation"],"backgroundTag":"missing-operation-id","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}