Skip to content

Commit

Permalink
参数验证规则说明
Browse files Browse the repository at this point in the history
  • Loading branch information
kiss291323003 committed Feb 22, 2021
1 parent f8e9673 commit 1a14daf
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/Utility/AnnotationDoc.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use EasySwoole\HttpAnnotation\AnnotationTag\ApiDescription;
use EasySwoole\HttpAnnotation\AnnotationTag\Param;
use EasySwoole\HttpAnnotation\Exception\Exception;
use EasySwoole\Validate\Error;

class AnnotationDoc
{
Expand Down Expand Up @@ -246,9 +247,22 @@ private function buildParamMarkdown($params)
}else{
$description = '-';
}
$rule = implode(',',array_keys($param->validateRuleList));
if(empty($rule)){
if(empty($param->validateRuleList)){
$rule = '-';
}else{
$rule = '';
foreach ($param->validateRuleList as $ruleName => $conf){
$arrayCheckFunc = ['inArray', 'notInArray', 'allowFile', 'allowFileType'];
if (in_array($ruleName, $arrayCheckFunc)) {
if(!is_array($conf[0])){
$conf = [$conf];
}
}
$err = new Error($param->name,null,null,$ruleName,null,$conf);
$temp = $err->__toString();
$temp = "{$ruleName}: ".substr($temp,strlen($param->name));
$rule .= $temp." </br>";
}
}
$ingoreAction = implode(',',$param->ignoreAction);
if(empty($ingoreAction)){
Expand Down

0 comments on commit 1a14daf

Please sign in to comment.