为什么自定义路由在Nelmio API Doc中出现两次?

时间:2016-12-14 07:35:46

标签: symfony fosrestbundle nelmioapidocbundle

我尝试为我的某个API定义自定义路由名称,从那时起,API Doc会显示该路由两次。有什么想法吗?

以下是我的API的定义:

/**
 * @ApiDoc(
 *   description = "Sends the support email to the HelpDesk address",
 *   statusCodes = {
 *     204 = "Returned when successful",
 *     400 = "Returned when the parameters are incorrect",
 *     401 = "Returned when the token is invalid",
 *     500 = "Returned when there's an internal server error"
 *   },
 *   input="AppBundle\Form\Type\SupportEmailType"
 * )
 * @Post("/support-requests")
 * @Rest\View ()
 */
public function postSupportAction(Request $request)

以及这条路线在我的文档中的显示方式: enter image description here

这是我的routing.yml文件:

# app/config/routing.yml
app:
    resource: "@AppBundle/Controller/"
    type:     annotation
NelmioApiDocBundle:
   resource: "@NelmioApiDocBundle/Resources/config/routing.yml"
   prefix:   /api/doc
user:
    type:     rest
    resource: AppBundle\Controller\UserController

1 个答案:

答案 0 :(得分:2)

从它的外观来看,唯一想到有可能做到这一点的是你的routing.yml的第一部分

尝试从routing.yml中删除它

app:
    resource: "@AppBundle/Controller/"
    type:     annotation

我认为这段代码和用户路线的分离定义使得nelmio两次看到路线。我前段时间遇到过类似的问题,我认为这就是原因。很抱歉我不得不提出一些问题,但我需要看到全貌。

希望这有帮助,

Alexandru Cosoi