如何告诉 Symfony 3 忽略某些注释? [英] How to tell Symfony 3 to ignore certain annotations?
问题描述
我正在使用 Symfony 3 开发 API,我想使用 apidoc 来创建文档.Apidoc 使用注释:
I'm developing an API with Symfony 3 and I want to use apidoc to create a documentation. Apidoc works with annotations:
/**
* @api {get} /user/:id Request User information
* @apiName GetUser
* @apiGroup User
*
* @apiParam {Number} id Users unique ID.
*
* @apiSuccess {String} firstname Firstname of the User.
* @apiSuccess {String} lastname Lastname of the User.
*/
但是 Symfony 抛出一个注解异常:
But Symfony throws an annotation exception:
[语义错误] 方法中的注解@apiName"AppBundle\Controller\API\ApiLoginController::loginAction() 从来没有进口的.您是否忘记为此添加使用"语句注释?
[Semantical Error] The annotation "@apiName" in method AppBundle\Controller\API\ApiLoginController::loginAction() was never imported. Did you maybe forget to add a "use" statement for this annotation?
500 内部服务器错误 - AnnotationException
500 Internal Server Error - AnnotationException
有没有办法告诉 symfony 忽略这些注释?提前致谢.
Is there any way to tell symfony to ignore those annotations? Thanks in advance.
推荐答案
有一个@IgnoreAnnotation Doctrine 注释.试试这个:
There's an @IgnoreAnnotation Doctrine annotation you can use. Try this:
/**
* @IgnoreAnnotation("api")
* @IgnoreAnnotation("apiName")
* @IgnoreAnnotation("apiGroup")
* @IgnoreAnnotation("apiParam")
* @IgnoreAnnotation("apiSuccess")
*/
class SomeController extends Controller{
...
/**
* @api {get} /user/:id Request User information
* @apiName GetUser
* @apiGroup User
*
* @apiParam {Number} id Users unique ID.
*
* @apiSuccess {String} firstname Firstname of the User.
* @apiSuccess {String} lastname Lastname of the User.
*/
文档位于该链接的下方.
The documentation is further down in that link.
这篇关于如何告诉 Symfony 3 忽略某些注释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!