Laravel8扩展swagger

安装和配置

  • composer require "darkaonline/l5-swagger" //目前是最新的
  • php artisan vendor:publish --provider "L5Swagger\L5SwaggerServiceProvider"
  • php artisan l5-swagger:generate

访问

在控制器中创建文件

/**
 * @OA\Info(
 *     title="Auth api",
 *     version="0.0.1"
 * )
 */
class LoginController extends Controller{
/**
     * @OA\Get(
     *     path="/projects",
     *     @OA\Response(response="200", description="Display a listing of projects.")
     * )
     */
    public function test()
    {
        return 'test -> user 33333';
    }

}

执行 php artisan l5-swagger:generate

参考1:https://blog.csdn.net/u012375924/article/details/79334537
参考2:https://stackoom.com/question/3ts8q/%E6%97%A0%E6%B3%95%E5%9C%A8l-swagger%E4%B8%AD%E7%94%9F%E6%88%90API%E6%96%87%E6%A1%A3
参考3:https://packagist.org/packages/darkaonline/l5-swagger

推荐阅读更多精彩内容