我想获取具有承载apitoken的标头。我已经在控制器的注释中定义了标头,但是当我在swagger中尝试时,swagger无法获取标头。
这是我的控制器:
/**
* @SWG\SecurityScheme(
* @SWG\Swagger(
* schemes={"https"},
* @SWG\SecurityDefinitions(
* bearer={
* type="apiKey",
* name="Authorization",
* in="header"
* }
* ),
* @OA\Get(
* path="/boards",
* tags={"Show ALL Board"},
* @OA\Parameter(
* name="Authorization",
* in="header",
* description="Header for API Token (with 'bearer ' first). ex : bearer api_token",
* required=true,
* @OA\Schema(type="string")
* ),
* @OA\Response(
* response="200",
* description="Returns all Boards",
* @OA\JsonContent()
* ),
* @OA\Response(
* response="400",
* description="Error: Bad request. When required parameters were not supplied.",
* ),
* @OA\Response(
* response="401",
* description="Error: Unauthorized User. Header with API token required",
* ),
* )
*/
public function index(Request $request)
{
return response()->json([
'status' => 'error',
'message' => $request->header('Authorization')
], 400);
}
任何帮助将不胜感激。谢谢!