【发布时间】:2021-06-26 08:47:01
【问题描述】:
我在 Symfony 5 应用程序上全新安装 Swagger 和 FosRestBundle 时遇到问题。 我有这个错误:
[Semantical Error] The annotation "@Swagger\Annotations\Response" in method ... was never imported. Did you maybe forget to add a "use" statement for this annotation? Make sure annotations are installed and enabled.
这是我的代码:
/**
* @Route("/", name="api_ia", methods="GET")
* @SWG\Response(
* response=200,
* description="Returns all informations based on image"
* @SWG\Schema(
* type="array"
* )
* )
* @SWG\Parameter(
* name="image"
* type="string"
* description="Photo of boiler label"
* )
* @SWG\Tag(name="IA")
* @Security(name="Bearer")
*/
有人遇到过问题吗?我没有修改我的注释文件,我已将 Swagger\Annotations 导入为 SWG。
【问题讨论】:
-
你能分享更多细节吗?删除该注释是否也会删除该错误?
-
错误出现在每个 @SWG* 标签上。如果我全部删除,错误就会消失
-
那么请分享更多详细信息,例如该类中的
use语句 -
use Symfony\Component\Routing\Annotation\Route;use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;use Swagger\Annotations as SWG;
标签: symfony swagger fosrestbundle