Dan*_*yCC 6 annotations symfony
我正在使用Symfony 3开发API,我想使用apidoc来创建文档.Apidoc使用注释:
/**
* @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.
*/
Run Code Online (Sandbox Code Playgroud)
但Symfony会抛出一个注释异常:
[语义错误]从未导入方法AppBundle\Controller\API\ApiLoginController :: loginAction()中的注释"@apiName".您是否忘记为此注释添加"使用"语句?
500内部服务器错误 - AnnotationException
有没有办法告诉symfony忽略那些注释?提前致谢.
win*_*ace 10
还有一种方法可以忽略全局注释.我们不想注释每个类,所以我们将它添加到我们的bootstrap文件中web/app.php.
Doctrine\Common\Annotations\AnnotationReader::addGlobalIgnoredName('your-custom-annotation');
Run Code Online (Sandbox Code Playgroud)
你可以使用@IgnoreAnnotation Doctrine注释.试试这个:
/**
* @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.
*/
Run Code Online (Sandbox Code Playgroud)
该文档在该链接中进一步说明.
| 归档时间: |
|
| 查看次数: |
1596 次 |
| 最近记录: |