{"record":{"id":"affa45c068660d5f","repo":"OpenAPITools/openapi-generator","slug":"empty-method-name-operationid-not-allowed-affa45","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/AbstractPhpCodegen.java","lineNumber":666,"sourceCode":"    public String toAbstractName(final String name) {\n        return camelize(abstractNamePrefix + name + abstractNameSuffix);\n    }\n\n    /**\n     * Output the proper trait name (capitalized).\n     *\n     * @param name the name of the trait\n     * @return capitalized trait name\n     */\n    public String toTraitName(final String name) {\n        return camelize(traitNamePrefix + name + traitNameSuffix);\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            LOGGER.warn(\"{} (reserved word) cannot be used as method name. Renamed to {}\", operationId, camelize(sanitizeName(\"call_\" + operationId), LOWERCASE_FIRST_LETTER));\n            operationId = \"call_\" + operationId;\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 = \"call_\" + operationId;\n        }\n\n        return camelize(sanitizeName(operationId), LOWERCASE_FIRST_LETTER);\n    }\n\n    /**","sourceCodeStart":648,"sourceCodeEnd":684,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPhpCodegen.java#L648-L684","documentation":"AbstractPhpCodegen.toOperationId throws when the operation name reaching it is null or empty. PHP method names in the generated API classes derive from operationId; an empty one would generate invalid PHP, so the run aborts. Default operationId derivation from path+method normally prevents blank ids from reaching this code.","triggerScenarios":"A spec operation carrying 'operationId: \"\"' where default derivation is bypassed, or a custom PHP generator calling toOperationId with a blank string.","commonSituations":"Machine-converted specs that drop operationIds; manually pruned specs; generator subclasses on AbstractPhpCodegen that rewrite ids first.","solutions":["Set a unique non-empty operationId on every operation.","Delete the blank operationId key so the generator derives a name from the path.","Check custom generator overrides for empty-id forwarding."],"exampleFix":"# before:\npaths:\n  /items:\n    put:\n      operationId: ''\n# after:\npaths:\n  /items:\n    put:\n      operationId: updateItem","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":["Give each operation a meaningful explicit operationId.","Strip blank operationId values in a pre-generation cleanup pass.","Check specs produced by converters for dropped ids."],"tags":["openapi","operationid","php","code-generation"],"backgroundTag":"missing-operation-id","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}