From 1a14daf530c134be3377a5d44496dab23f4e77d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=82=E6=9E=9C=E7=9A=84=E5=A6=82=E6=9E=9C?= Date: Mon, 22 Feb 2021 15:57:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=82=E6=95=B0=E9=AA=8C=E8=AF=81=E8=A7=84?= =?UTF-8?q?=E5=88=99=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Utility/AnnotationDoc.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Utility/AnnotationDoc.php b/src/Utility/AnnotationDoc.php index f1e9e27..e62bf89 100644 --- a/src/Utility/AnnotationDoc.php +++ b/src/Utility/AnnotationDoc.php @@ -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 { @@ -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."
"; + } } $ingoreAction = implode(',',$param->ignoreAction); if(empty($ingoreAction)){