参数缺少Swagger / API文档

时间:2018-10-09 08:35:05

标签: symfony parameters swagger api-doc

在我的symfony项目4.1中将nelmio api doc从3.0更新到3.1 / 3.3时出现问题。我无法理解在请求中可以在API服务中发送的参数。无论使用$ request-> attributes-> all(),$ request-> query-> all()还是$ request-> request-> all(),我都没有参数,但是在3.0版中,它可以正常工作

我试图清除缓存,更改参数类型,但不起作用:(

我在symfony项目中具有nelmio api doc软件包的配置

<mat-spinner [diameter]="25" class="mat-spinner-color"></mat-spinner>

以及控制器中的示例注释:

nelmio_api_doc:
documentation:
    info:
        title: Project
        description: description
        version: 1.0.0
    securityDefinitions:
       api_key:
           type: apiKey
           description: Json Web Token
           name: Authorization
           in: header
    security:
        - api_key: []
models: { use_jms: true }

有人可以解决吗?谢谢!

2 个答案:

答案 0 :(得分:0)

您可以尝试使用此注释吗?

/**
 * @SWG\Post(
 *     path="/api/path",
 *     summary="Post to URL",
 *     @SWG\Parameter(
 *          name="body",
 *          in="body",
 *          required=true,
 *          @SWG\Schema(
 *              @SWG\Property(
 *                  property="email",
 *                  type="string"
 *              ),
 *              @SWG\Property(
 *                  property="password",
 *                  type="string"
 *              )
 *          )
 *     )
 *   )
 */

答案 1 :(得分:0)

 * @Operation(
 *     consumes={"multipart/form-data"},

尝试过此方法,它可以工作,但不能访问put方法