如何让Nelmio ApiDoc注释通过我的表格请求方法?

时间:2015-04-24 11:55:32

标签: symfony-forms fosrestbundle api-doc

我使用动态表单(定义为services(!))来启用/禁用特定请求(POST / PUT / PATCH)的某些字段。我希望通过将选项传递给described in documentation来自动显示在ApiDoc中。但它不起作用。我用这个:

 * @ApiDoc(
 *  section = "...",
 *  description = "...",
 *  input = {
 *      "class" = "my_form_type_alias",
 *      "options" = {"method" = "PUT"},
 *      "name" = ""
 *  },
 *  statusCodes = {
 *      200 = "Updated (seems to be OK)",
 *      400 = "Bad request (see messages)",
 *      401 = "Unauthorized, you must login first",
 *      404 = "Not found",
 *  }
 * )

但是通过xdebug我可以看到$ options ['方法']总是等于' POST',就像我没有指定"选项&# 34; = {"方法" =" PUT"}。

2 个答案:

答案 0 :(得分:0)

目前这已在Nelmio ApiDoc中修复并且运行正常。

答案 1 :(得分:0)

您可以尝试在路由中包含请求方法。

通过正确配置ApiDoc,方法将显示在ApiDoc中。

在app / config / routing.yml中

# app/config/routing.yml
app:
    resource: "@AppBundle/Controller/"
    type:     annotation
    requirements:
        _method: POST