phptokenl5-swagger

Swagger is not returning authorization token


Swagger is not returning authorization token! but it's working fine in Postman. Even if I am printing verify token it returns empty string.

My Function Code.

$verified_token = str_replace('Bearer ', '', $request->header('Authorization'));
        return $verified_token;

Swagger Response is empty due to which I cannot do further validations.

Thanks

I have tried reading documentation for swagger but couldn't found any help.


Solution

  • Make sure your are defining security field in swagger code. For example if you are using sanctum as middleware define like this.

    /**
         * @OA\Get(
         ...
         *  security={ {"sanctum": {} }},
         ...