Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
项目API结构:
其中:Wechat文件夹下面的两个类,Login.php和Register.php,同个分组,
请求接口分别是:
登录:/api/wechat/login/index
注册:/api/wechat/register/index
文件代码节选:
`/**
Class Register
@controller("Register")
@Package App\HttpController\Api\Wechat
@APIGroup(groupName="微信小程序")
@ApiGroupDescription("微信小程序相关")
*/
class Register extends Base
{
/**
{
"code": 200,
"result": {
1
},
"msg": "ok"
}
)
{
"code": 600,
"result": {
"error": "openid:openid不能为空!"
},
"msg": "openid:openid不能为空!"
}
)
*/
public function index(){
$params = $this->_params;
$Val = new Validator($this->_params);
$Val->rule('required', 'companyID')->message('物流公司ID不能为空!')
->rule('required', 'username')->message('用户昵称不能为空!')
->rule('required', 'sex')->message('用户性别不能为空!')
->rule('required', 'openid')->message('openid不能为空!');
}
}
/**
class Login
@controller("Login")
@Package App\HttpController\Api\Wechat
@APIGroup(groupName="微信小程序")
@ApiGroupDescription("微信小程序相关")
*/
class Login extends Base
{
/**
{
"code": 600,
"result": {
"error": "code:CODE不能为空!"
},
"msg": "code:CODE不能为空!"
}
)
{
"code": 600,
"result": {
"error": "缺少code参数"
},
"msg": "缺少code参数"
}
)
*/
public function index(){
}
}`
API在同个分组,里面请求的同个方法名,但是不同的类里面
最后导致,doc文档左侧菜单只显示一个函数。(easyswoole6群:524475224 有我发的消息截图,此处由于网络问题无法上传图片)
根据分析,我找到对应的方法只需要加上控制器名字进行区分方法,这样就可以避免。
获取控制器名字,且判断是否有配置@controller,如果没有则给他一个默认default
EasySwoole\HttpAnnotation\Utility\AnnotationDoc
line:128行
$controllerAnnotation = $objectAnnotation->getController(); if(!$controllerAnnotation){ $controllerName = 'default'; }else{ $controllerName = $controllerAnnotation->value; }
line:143行
$groupList[$currentGroupName][$controllerName.'-'.$method->getMethodName()] = $method;
line: 148行 标记ID锚点
$html .= "<h2 class='api-method {$currentGroupName}' id='{$currentGroupName}-{$controllerName}-{$methodName}'>{$apiTag->name}{$deprecated}</h2>{$this->CLRF}";