symfony - 为什么 swagger 看不到 public/bundles/hbswaggerui 中的文件?
问题描述
我使用 OpenServer(Apache 2.4 + PHP 7.2)。
Symfony 4 工作正常,路由工作正常。在 /public 文件夹中,我放置了 .htaccess 文件。
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
有用。
我在这里安装了招摇: https ://github.com/harmbandstra/swagger-ui-bundle
我还在 hb_swagger_ui.yaml 中使用了assetUrlPath 参数
hb_swagger_ui:
directory: "%kernel.root_dir%/../docs/"
assetUrlPath: '/public/bundles/hbswaggerui/'
files:
- "swagger.json"
url mysite/docs/?url=/docs/file/swagger.json 显示白页
控制台显示:
Refused to apply style from 'http://mysite/docs/swagger-ui.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
?url=/docs/file/swagger.json:36 GET http://mysite/docs/swagger-ui-bundle.js net::ERR_ABORTED 404 (Not Found)
?url=/docs/file/swagger.json:37 GET http://mysite/docs/swagger-ui-standalone-preset.js net::ERR_ABORTED 404 (Not Found)
?url=/docs/file/swagger.json:41 Uncaught ReferenceError: SwaggerUIBundle is not defined
at window.onload (?url=/docs/file/swagger.json:41)
如果我创建文件夹 /public/doc/ 并将文件从 /public/bundles/hbswaggerui/ 移到那里 - 它可以工作。
但它应该在文件夹 /public/bundles/hbswaggerui 中工作。
为什么不呢?
我应该做一些额外的 Apache 设置来将 /public/docs 重写为 /public/bundles/hbswaggerui 吗?
手册中没有关于它的信息...
解决方案
你不应该设置assetUrlPath
,从你的配置中删除它。
推荐阅读
- reactjs - 如何使用离子反应创建输入自动建议或选择选项搜索?
- r - 无法更改向量中的名称值
- latex - Texmaker “!额外的 \endgroup。” 编译错误
- swift - 客户端特征配置描述符 0x81 配置不正确
- javascript - 异步函数返回 Observer 对象和 Promise
- javascript - 为阵列输出创建 Google 应用脚本 GUI
- vue.js - Vue.js 2:如何绑定到组件方法?
- python - 使用映射字典替换多个字符
- azure - 如何从 azure 发布管道查询当前部署到应用服务的 docker 映像?
- typescript - Jest:有没有办法从 Jest 的期望中返回通过或失败的值?