如何告诉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 文档注释.试试这个:
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屋!