Страница 1 из 1

Swagger + bearer

Добавлено: 2019.10.26, 07:30
Ghost_nsk
Товарищи, подскажите кто сталкивался. Работаю с документацией в swagger, не могу понять как подключить поле для ввода токена.

Код: Выделить всё

/**
 * Class ClientController
 *
 * @package api\controllers
 *
 * @OA\SecurityScheme(
 *   securityScheme="bearerAuth",
 *   in="header",
 *   name="bearerAuth",
 *   type="http",
 *   scheme="bearer",
 *   bearerFormat="JWT",
 * ),
 * @OA\Tag(
 *   name="client",
 *   description="Client crud methods"
 * ),
 * @OA\Post(
 *   path="/client/create",
 *   summary="Create a new client record",
 *   tags={"client"},
 *   security={"bearerAuth"},
 *   @OA\RequestBody(
 *     required=true,
 *     @OA\JsonContent(ref="#/components/schemas/Client"),
 *   ),
 *   @OA\Response(
 *     response=200,
 *     description="Success"
 *   ),
 *   @OA\Response(
 *     response=402,
 *     description="Validation error"
 *   ),
 * ),
 */

Re: Swagger + bearer

Добавлено: 2019.10.26, 10:41
yiiliveext
Оно само выводится в swagger-ui по нажатию на кнопку Authorize
https://petstore.swagger.io/

Re: Swagger + bearer

Добавлено: 2019.10.26, 16:52
Ghost_nsk
Правильный ответ, если кому понадобится:

Код: Выделить всё

/**
 * Class ClientController
 *
 * @package api\controllers
 *
 * @OA\SecurityScheme(
 *   securityScheme="bearerAuth",
 *   in="header",
 *   name="Authorization",
 *   type="http",
 *   scheme="bearer",
 *   bearerFormat="JWT",
 * ),
 * @OA\Tag(
 *   name="client",
 *   description="Client crud methods"
 * ),
 * @OA\Post(
 *   path="/client/create",
 *   summary="Create a new client record",
 *   tags={"client"},
 *   security={
 *     {"bearerAuth": {}}
 *   },
 *   @OA\RequestBody(
 *     required=true,
 *     @OA\JsonContent(ref="#/components/schemas/Client"),
 *   ),
 *   @OA\Response(
 *     response=200,
 *     description="Success"
 *   ),
 *   @OA\Response(
 *     response=402,
 *     description="Validation error"
 *   ),
 * ),
 */