Swagger 学说/zircote Bearer 授权码

Ric*_*ven 2 php doctrine jwt swagger bearer-token

我正在尝试使用 swagger zircote 创建 swagger ui json。对于我的应用程序,我使用 JWT,我的 json 中需要以下 swagger 代码:

"securityDefinitions": {
    "Bearer": {
      "in": "header",
      "type": "accessToken",
      "name": "Authorization"
    }
},
Run Code Online (Sandbox Code Playgroud)

但我不知道如何使用 swaggers zircote 创建该代码。我试过以下代码:

 * @SWG\Swagger(
 *     schemes={"https"},
 *     @SWG\SecurityDefinitions(
 *         bearer={
 *             type="apiKey",
 *             name="Authorization",
 *             in="header"
 *         }
 *     ),
Run Code Online (Sandbox Code Playgroud)

但这会导致以下错误:

第 2 行 .\index.php 中的注释“@Swagger\Annotations\SecurityDefinitions”不存在,或者无法自动加载。

有人可以帮助我,我找不到任何关于此的好的文档,也许是特定的,但我希望有人可以帮助我。

谢谢!

也在 github 上发布了这个... https://github.com/zircote/swagger-php/issues/366

Bob*_*ger 5

使用@SWG\SecurityScheme代替@SWG\SecurityDefinitions

 * @SWG\Swagger(
 *     schemes={"https"},
 *     @SWG\SecurityScheme(
 *         securityDefinition="Bearer",
 *         type="apiKey",
 *         name="Authorization",
 *         in="header"
 *     ),
Run Code Online (Sandbox Code Playgroud)

可以在vendor/zircote/swagger-php/src/Annotations 中找到可用注释的列表