diff --git a/app/Controller/Admin/Login.php b/app/Controller/Admin/Login.php index c52c3ec..7ad50cb 100644 --- a/app/Controller/Admin/Login.php +++ b/app/Controller/Admin/Login.php @@ -21,12 +21,31 @@ use Hyperf\HttpServer\Annotation\PostMapping; use MathCaptcha\Captcha; use App\Request\Account as aRequest; use function Hyperf\Config\config; +use Hyperf\Swagger\Annotation as SA; #[Controller(prefix: "admin")] class Login extends Base { #[GetMapping(path: "captcha")] #[Auth(needLogin: false)] + #[SA\Post(path: '/captcha', summary: '登录接口', tags: ['登录接口'])] + #[SA\RequestBody( + description: '请求参数', + content: [ + new SA\MediaType( + mediaType: 'application/json', + schema: new SA\Schema( + required: ['username', 'age'], + properties: [ + new SA\Property(property: 'username', description: '用户名字段描述', type: 'string'), + new SA\Property(property: 'age', description: '年龄字段描述', type: 'string'), + new SA\Property(property: 'city', description: '城市字段描述', type: 'string'), + ] + ), + ), + ], + )] + #[SA\Response(response: 200, description: '返回值的描述')] public function captcha() { // 获取uuid diff --git a/composer.json b/composer.json index 8468f87..c60f776 100644 --- a/composer.json +++ b/composer.json @@ -31,6 +31,7 @@ "hyperf/process": "~3.1.0", "hyperf/rate-limit": "^3.1", "hyperf/redis": "~3.1.0", + "hyperf/swagger": "^3.1", "hyperf/validation": "^3.1", "hyperf/websocket-server": "^3.1", "phpoffice/phpspreadsheet": "^4.5", diff --git a/config/autoload/app.php b/config/autoload/app.php index 4610b37..6059798 100644 --- a/config/autoload/app.php +++ b/config/autoload/app.php @@ -1,8 +1,11 @@ */ return [ // 域名 - 'domain' => 'https://server.leapy.cn/' + 'domain' => env('DOMAIN') ]; \ No newline at end of file diff --git a/config/autoload/file.php b/config/autoload/file.php index 3d4a8d5..ae25563 100644 --- a/config/autoload/file.php +++ b/config/autoload/file.php @@ -11,7 +11,7 @@ return [ 'storage' => [ 'local' => [ 'driver' => LocalAdapterFactory::class, - 'root' => BASE_PATH . '/runtime', + 'root' => BASE_PATH . '/static', ], ], ]; diff --git a/config/autoload/server.php b/config/autoload/server.php index 743d758..cbc5958 100644 --- a/config/autoload/server.php +++ b/config/autoload/server.php @@ -59,7 +59,7 @@ return [ Constant::OPTION_BUFFER_OUTPUT_SIZE => 2 * 1024 * 1024, Constant::OPTION_PACKAGE_MAX_LENGTH => 50 * 1024 * 1024, - 'document_root' => BASE_PATH . '/runtime', + 'document_root' => BASE_PATH . '/static', 'enable_static_handler' => true, ], 'callbacks' => [ diff --git a/config/autoload/swagger.php b/config/autoload/swagger.php new file mode 100644 index 0000000..22a688b --- /dev/null +++ b/config/autoload/swagger.php @@ -0,0 +1,80 @@ + true, + 'port' => (int)env("SWAGGER_PORT", 9500), + 'json_dir' => BASE_PATH . '/static/swagger/json', + 'html' => <<<'HTML' + + + + + + + SwaggerUI + + + +
+ + + + + +HTML, + 'url' => '/swagger', + 'path' =>'/swagger', + 'auto_generate' => true, + 'scan' => [ + 'paths' => [ + BASE_PATH . '/app/Controller/Admin' + ], + ], + 'processors' => [ + // users can append their own processors here + ], + 'server' => [ + 'http' => [ + 'servers' => [ + [ + 'url' => env('DOMAIN') . '/admin', + 'description' => '后台接口', + ], + ], + 'info' => [ + 'title' => '里派基础接口', + 'description' => '管理端接口', + 'version' => '1.0.0', + ], + ], + ], +];