Skip to content

Commit 1b790b3

Browse files
committed
update 5.0.3
- Query/Param/Returned注解支持children子参数注解中直接使用ref。 - 支持接口调试响应参数的Hover提示。 - 修正ref引用文件/方法不存在时,异常提示不准确问题。 - 修正Laravel异常显示问题。
1 parent 9fa3f5f commit 1b790b3

File tree

8 files changed

+30
-19
lines changed

8 files changed

+30
-19
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
<div align="center" style="margin-top:10px;margin-bottom:50px;">
1414
<a href="https://packagist.org/packages/hg/apidoc"><img src="https://img.shields.io/packagist/v/hg/apidoc"></a>
1515
<a href="https://packagist.org/packages/hg/apidoc"><img src="https://img.shields.io/packagist/dt/hg/apidoc"></a>
16+
<a href="https://packagist.org/packages/hg/apidoc"><img src="https://img.shields.io/packagist/dm/hg/apidoc"></a>
17+
<a href="https://packagist.org/packages/hg/apidoc"><img src="https://img.shields.io/packagist/dd/hg/apidoc"></a>
1618
<a href="https://packagist.org/packages/hg/apidoc"><img src="https://img.shields.io/packagist/l/hg/apidoc"></a>
1719
<a href="https://github.com/HGthecode/apidoc-php"><img src="https://img.shields.io/github/issues/HGthecode/apidoc-php"></a>
1820
<a href="https://github.com/HGthecode/apidoc-php"><img src="https://img.shields.io/github/forks/HGthecode/apidoc-php"></a>
@@ -46,7 +48,7 @@ Apidoc是一个通过解析注解生成Api接口文档的PHP composer扩展,
4648
|框架|版本|说明|
4749
|-|-|-|
4850
|ThinkPHP|5.1、6.x||
49-
|Laravel|8.x、9.x||
51+
|Laravel|8.x、9.x、10.x||
5052
|Webman|1.x||
5153
|Hyperf|2.x、3.x||
5254

src/parses/ParseApiDetail.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,13 @@ protected function handleAnnotationsParamItem($param,$field){
429429
$childrenData = [];
430430
foreach ($data['children'] as $child) {
431431
$paramItem=$this->handleAnnotationsParamItem($child,$field);
432+
432433
if ($paramItem!==false){
433-
$childrenData[] = $paramItem;
434+
if (!empty($paramItem) && is_array($paramItem) && array_key_first($paramItem)===0){
435+
$childrenData = Helper::arrayMergeAndUnique("name",$childrenData,$paramItem);
436+
}else{
437+
$childrenData[] = $paramItem;
438+
}
434439
}
435440
}
436441
$data['children'] = $childrenData;
@@ -559,7 +564,7 @@ protected function renderRef($refPath,$field): array
559564
return [$field=>$modelParams];
560565

561566
} catch (\ReflectionException $e) {
562-
throw new ErrorException('Class '.$classPath.' '.$e->getMessage());
567+
throw new ErrorException($e->getMessage());
563568
}
564569

565570

@@ -587,6 +592,11 @@ protected function handleRefData($annotation,$refParams, string $field): array
587592
}
588593
return $annotation;
589594
}
595+
// else{
596+
// if (!empty($annotation[$field])) {
597+
// $annotation[$field] = Helper::arrayMergeAndUnique("name",$refParams,$annotation[$field]);
598+
// }
599+
// }
590600
return $refParams;
591601
}
592602

src/parses/ParseModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function parseModelTable($model,$classReflect,$methodName=""){
6060
}
6161
return $table;
6262
} catch (\ReflectionException $e) {
63-
throw new ErrorException('Class '.$path.' '.$e->getMessage());
63+
throw new ErrorException('Class '.get_class($model).' '.$e->getMessage());
6464
}
6565

6666
}

src/providers/BaseService.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ trait BaseService
1111
{
1212

1313
static $routes = [
14-
['rule'=>'config','route'=>'getConfig','method'=>'GET'],
15-
['rule'=>'apiMenus','route'=>'getApiMenus','method'=>'POST'],
16-
['rule'=>'apiDetail','route'=>'getApiDetail','method'=>'POST'],
17-
['rule'=>'docMenus','route'=>'getMdMenus','method'=>'POST'],
18-
['rule'=>'docDetail','route'=>'getMdDetail','method'=>'POST'],
19-
['rule'=>'verifyAuth','route'=>'verifyAuth','method'=>'POST'],
20-
['rule'=>'generator','route'=>'createGenerator','method'=>'POST'],
21-
['rule'=>'cancelAllCache','route'=>'cancelAllCache','method'=>'POST'],
22-
['rule'=>'createAllCache','route'=>'createAllCache','method'=>'POST'],
23-
['rule'=>'renderCodeTemplate','route'=>'renderCodeTemplate','method'=>'POST'],
14+
['rule'=>'config','route'=>'getConfig'],
15+
['rule'=>'apiMenus','route'=>'getApiMenus'],
16+
['rule'=>'apiDetail','route'=>'getApiDetail'],
17+
['rule'=>'docMenus','route'=>'getMdMenus'],
18+
['rule'=>'docDetail','route'=>'getMdDetail'],
19+
['rule'=>'verifyAuth','route'=>'verifyAuth'],
20+
['rule'=>'generator','route'=>'createGenerator'],
21+
['rule'=>'cancelAllCache','route'=>'cancelAllCache'],
22+
['rule'=>'createAllCache','route'=>'createAllCache'],
23+
['rule'=>'renderCodeTemplate','route'=>'renderCodeTemplate'],
2424
];
2525

2626

@@ -148,7 +148,6 @@ static public function registerApidocRoutes($routeFun=null){
148148
'uri'=>$route_prefix.$item['rule'],
149149
'callback'=>$controller_namespace.$item['route'],
150150
'route'=>$item['route'],
151-
'method'=>$item['method']
152151
];
153152
if (!empty($routeFun)){
154153
$routeFun($route);

src/providers/HyperfService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ static function register(){
2222
! defined('APIDOC_STORAGE_PATH') && define('APIDOC_STORAGE_PATH', HyperfMiddleware::getRuntimePath());
2323

2424
CommonService::registerApidocRoutes(function ($item){
25-
Router::addRoute($item['method'],$item['uri'],$item['callback'],['middleware' => [HyperfMiddleware::class]]);
25+
Router::addRoute(['GET','POST'],$item['uri'],$item['callback'],['middleware' => [HyperfMiddleware::class]]);
2626
});
2727

2828
// 自动注册路由

src/providers/LaravelService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static function getApidocConfig()
6767

6868
static function registerRoute($route){
6969
$config = self::getApidocConfig();
70-
$registerRoute = Route::match([$route['method']],$route['uri'], $route['callback']);
70+
$registerRoute = Route::any($route['uri'], $route['callback']);
7171
$registerRoute->middleware([LaravelMiddleware::class]);
7272
if (!empty($config['allowCrossDomain'])) {
7373
$registerRoute->middleware([ApiCrossDomain::class]);

src/providers/ThinkPHP5Service.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static function getApidocConfig()
5252

5353
static function registerRoute($route){
5454
$config = self::getApidocConfig();
55-
$registerRoute = Route::rule($route['uri'], $route['callback'],$route['method']);
55+
$registerRoute = Route::rule($route['uri'], $route['callback'],"*");
5656
if (!empty($config['allowCrossDomain'])) {
5757
$registerRoute->allowCrossDomain();
5858
}

src/providers/ThinkPHPService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function register()
6767
}
6868

6969
static function registerRoute($route){
70-
$registerRoute = Route::rule($route['uri'], $route['callback'],$route['method']);
70+
$registerRoute = Route::any($route['uri'], $route['callback']);
7171
}
7272

7373
static function databaseQuery($sql){

0 commit comments

Comments
 (0)