3

我想将 swagger 与 laravel 护照联系起来。我的招摇配置文件设置

'passport' => [ // Unique name of security
            'type' => 'oauth2', // The type of the security scheme. Valid values are "basic", "apiKey" or "oauth2".
            'description' => 'Laravel passport oauth2 security.',
            'in' => 'header',
            'scheme' => 'https',
            'flows' => [
                "password" => [
                    "authorizationUrl" => config('app.url') . '/oauth/authorize',
                    "tokenUrl" => config('app.url') . '/oauth/token',
                    "refreshUrl" => config('app.url') . '/token/refresh',
                    "scopes" => []
                ],
            ],
        ],

在我使用注释的 laravel 控制器中

/**
     * @OA\Post(
     *     path="/beauty/list-customer-service-bookings",
     *     tags={"beauty_customer_bookings"},
     *     summary="List Customer Bookings.",
     *     operationId="Beauty_Customer_Bookings",
     *     security={{"passport": {}}},
     * @OA\SecurityScheme(
     *    securityScheme="https",
     *    type="oauth2",
     *    in="header",
     *    name="api_key"
     * ),
     *
     *     @OA\Parameter(
     *         name="customer_id",
     *         in="query",
     *         description="customer id",
     *         required=true,
     *         @OA\Schema(
     *             type="integer",
     *             default="482"
     *         )
     *     ),
     *     @OA\Response(
     *         response=422,
     *         description="validation errors."
     *     ),
     *     @OA\Response(
     *          response="200",
     *          description="Customer Bookings."
     *     ),
     *     @OA\Response(
     *          response="401",
     *          description="auth failed."
     *     ),
     *     @OA\Response(
     *          response="404",
     *          description="Page not found."
     *     ),
     * )
     */

它没有发送它应该发送的标题。我做错了什么还是缺少了什么?我需要这个解决方案,在 Laravel 中使用 OA 3

4

1 回答 1

0
  • 你好朋友,你只需要添加像
    示例这样的魔法参数:
    security={ 
       {"passport": {}}, 
     },
  • 在您的招摇评论中,这样当您输入有效的身份验证凭据和护照密钥时,curl 就会使用护照令牌生成。

谢谢你。

于 2020-11-02T07:04:01.180 回答