绕过注释 Symfony2

Bypass Annotation Symfony2

我目前正在使用 Symfony2 构建 RESTful API。

为了创建一个简单干净的文档,我希望使用apidoc.js(我真的更愿意使用这个,但是如果你有什么其他的可以自动生成api文档的感觉免费分享)。

此生成器使用由 Symfony 内核解析的注释(显然,据我了解)

这是我的控制器代码

/**
 * @api {get} /contact/list Request Contacts List
 * @apiName List Contacts
 * @apiGroup Contacts
 *
 * @apiSuccess {Integer} Status
 * @apiSuccess {String} Custom Message to be displayed
 */
public function clientListAction(){}

遗憾的是,Symfony 对此进行了解析,并向我抛出一个错误:

[Semantical Error] The annotation "@apiName" in method AppBundle\Controller\ClientApiController::clientListAction() was never imported.

您是否有解决方案来阻止 Symfony 解析注释(我一直使用 YAML,所以 Symfony 注释实际上对我没有用),或者只是导入那些?

我在这方面还很陌生,我仍在努力创建一个可靠且干净的 Symfony 应用程序。

使用@ignoreAnnotation.

When using another library or program (e.g. Doxygen) that uses annotations, you should place the @IgnoreAnnotation annotation on the class to indicate which annotations Symfony should ignore.

看看Nelmio Api Doc Bundle。它允许以类似的方式(通过注释)生成文档。