registerRoute([ 'route_prefix' => '/article/openapi', 'register_route' => true, 'openapi_doc' => [ 'scan_path' => [ base_path('plugin/article/app/api'), ], 'modify' => function (OA\OpenApi $openapi) { $openapi->info->title = '文章管理 API'; $openapi->info->version = '1.0.0'; $openapi->servers = [ new OA\Server( [ 'url' => '/api', 'description' => request()->host(), ] ), ]; /** @phpstan-ignore-next-line */ if (!$openapi->components instanceof OA\Components) { $openapi->components = new OA\Components([]); } $openapi->components->securitySchemes = [ new OA\SecurityScheme([ 'securityScheme' => 'api_key', 'type' => 'apiKey', 'name' => config('core.jwt.app.token_name', 'Authorization'), 'in' => 'header', ]), ]; }, ], ]); }); /** * 注册 AdminAPI 路由 */ Route::group('/adminapi', function () { Swagger::create()->registerRoute([ 'route_prefix' => '/article/openapi', 'register_route' => true, 'openapi_doc' => [ 'scan_path' => [ base_path('plugin/article/app/adminapi'), ], 'modify' => function (OA\OpenApi $openapi) { $openapi->info->title = '文章管理 API'; $openapi->info->version = '1.0.0'; $openapi->servers = [ new OA\Server( [ 'url' => '/adminapi', 'description' => request()->host(), ] ), ]; /** @phpstan-ignore-next-line */ if (!$openapi->components instanceof OA\Components) { $openapi->components = new OA\Components([]); } $openapi->components->securitySchemes = [ new OA\SecurityScheme([ 'securityScheme' => 'api_key', 'type' => 'apiKey', 'name' => config('core.jwt.app.token_name', 'Authorization'), 'in' => 'header', ]), ]; }, ], ]); });