2 changed files with 59 additions and 11 deletions
@ -0,0 +1,59 @@
|
||||
<?php |
||||
|
||||
namespace Plugins\ApiDoc\Controller; |
||||
|
||||
use App\Util\Response; |
||||
use Hyperf\HttpServer\Annotation\Controller; |
||||
use Hyperf\HttpServer\Annotation\GetMapping; |
||||
use Hyperf\HttpServer\Annotation\PostMapping; |
||||
use Plugins\ApiDoc\Attributes\Api; |
||||
use Plugins\ApiDoc\Attributes\ApiBody; |
||||
use Plugins\ApiDoc\Attributes\ApiQuery; |
||||
use Plugins\ApiDoc\Attributes\ApiReturn; |
||||
use Psr\Http\Message\ResponseInterface; |
||||
|
||||
/** |
||||
* API文档demo |
||||
* |
||||
* Class ApiDocDemo |
||||
*/ |
||||
#[Controller('api/plugins/demo')] |
||||
class DemoController |
||||
{ |
||||
/** |
||||
* 测试GET请求 |
||||
* |
||||
* @return ResponseInterface |
||||
*/ |
||||
#[Api] |
||||
#[ApiQuery('id', 'Integer', 'ID', true)] |
||||
#[ApiReturn('id', 'Integer', 'ID')] |
||||
#[ApiReturn('title', 'String', '标题')] |
||||
#[ApiReturn('describe', 'String', '描述')] |
||||
#[GetMapping(path: 'get')] |
||||
public function get(): ResponseInterface |
||||
{ |
||||
return Response::json()->success(); |
||||
} |
||||
|
||||
/** |
||||
* 测试POST请求 |
||||
* |
||||
* @return ResponseInterface |
||||
*/ |
||||
#[Api] |
||||
#[ApiBody('id', 'Integer', 'ID', true)] |
||||
#[ApiReturn('id', 'Integer', 'ID')] |
||||
#[ApiReturn('title', 'String', '标题')] |
||||
#[ApiReturn('describe', 'String', '描述')] |
||||
#[PostMapping(path: 'post')] |
||||
public function post(): ResponseInterface |
||||
{ |
||||
return Response::json()->success(); |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} |
Loading…
Reference in new issue