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

Why does a custom route appears twice in Nelmio API Doc?

我已经尝试为我的 API 之一定义一个自定义路由名称,从那时起,API 文档显示该路由两次。有什么想法吗?

这是我的 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)

这是路线在我的文档中的显示方式:

这是我的 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

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

的第一部分

尝试从您的 routing.yml

中删除它
app:
    resource: "@AppBundle/Controller/"
    type:     annotation

我认为这段代码和用户路由的分离定义让 nelmio 看到了两次路由。前段时间我遇到了类似的问题,我认为这就是原因。很抱歉我不得不问很多问题,但我需要看到完整的图片。

希望这对您有所帮助,

亚历山德鲁·科索伊