【发布时间】:2019-11-25 10:15:28
【问题描述】:
目前我们的项目已经安装了 Symfony 4.3。自2.7 以来,我们已经发展壮大,因此可能会有一些遗留垃圾,但总体而言,我们的应用运行良好。我们有一个为每条路线添加前缀的调味系统(如果这是一个好主意,我不知道,但当我们开始支持它时就是这样)。所以链接看起来像这样:
test.me/{flavor}/project/{UUID}
我们正在为路由使用注释,因此有一个annotations.yaml:
controllers:
resource: ../../src/App/Controller/
type: annotation
prefix: /{flavor}/
现在,由于我们要引入 API 文档,因此我们想使用这个 php 包:https://github.com/zircote/swagger-php,它让我们可以像使用路由一样为 API 编写注释,并生成一个可以分发给我们连接的 swagger.json项目。问题是在编写注释时会弹出此错误:
$:bin/console cache:clear -e dev
// Clearing the cache for the dev environment with debug true
In FileLoader.php line 166:
[Semantical Error] The annotation "@OA\Schema" in class App\Controller\Api\Model\APIMessage
was never imported. Did you maybe forget to add a "use" statement for this annotation? in /config/routes/../../src/Catrobat/Controller/ (which is being imported from "/config/routes/annotations.yaml"). Make sure annotations are installed
and enabled.
知道如何告诉框架忽略文件加载器中的这个注释吗? swagger-php 会自行解析文件,因此它并不关心文件是否被导入。我也尝试导入 Openapi Annotations,但这也不起作用。非常感谢任何帮助!
【问题讨论】:
标签: php symfony swagger symfony4 openapi