[FAQ] swagger-php 支持 Authorization Bearer token 校验的用法

@OASecurityScheme 可以是 Controller 层面也可以是 Action 层面。

类型 type="apiKey"。

in="header" 表示在 header 头中。

name 定义请求头的 key 名为 Authorization。

securityScheme="xx",Authorization 的值会带上 swagger ui 上设置的值。

@OAPost 对应到具体的方法,在 security 中指定 securityScheme 的值。

     * @OASecurityScheme(
     *     type="apiKey",
     *     in="header",
     *     securityScheme="Bearer",
     *     name="Authorization"
     * )
     *
     * @OAPost(
     *     path="/api/v1/create",
     *     security={
     *       {"Bearer":{}}
     *     },
     *     @OAResponse(
     *         response="default",
     *         description="successful operation"
     *     )
     * )

Link:https://www.cnblogs.com/farwish/p/14016676.html

原文地址:https://www.cnblogs.com/farwish/p/14016676.html