使用Swagger - UI3XX
我只想知道这是否可能,如果可以,如何:
当前,我们需要显示hide的定义URL路径Swagger - UI。
我知道无法删除此URL,我也不想这样做,我只想对查看此页面的客户端隐藏/屏蔽文本框。
在这里查看新的Swagger文档,您可以添加一些很棒的技巧和其他功能-与查询有关的任何内容我都看不到。
我很确定,我可以查询HTML,找到有问题的元素的ID,然后在index.html中手动更改它的显示,我更喜欢使用内置方法,如果有的话在进入之前那可能的解决方案。
即像这样的事情是可行的,并且可以工作:
<style> .download-url-input { display: none !important; } </style>
Run Code Online (Sandbox Code Playgroud)
这有可能吗?
在Swagger UI 3.x中,您可以通过以下方式之一隐藏顶部栏。
编辑dist\index.html并找到以下代码:
const ui = SwaggerUIBundle({
url: "http://petstore.swagger.io/v2/swagger.json",
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout"
})
Run Code Online (Sandbox Code Playgroud)
删除layout,SwaggerUIStandalonePreset并SwaggerUIBundle.plugins.DownloadUrl,使构造函数如下所示:
const ui = SwaggerUIBundle({
url: "http://petstore.swagger.io/v2/swagger.json",
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis
]
})
Run Code Online (Sandbox Code Playgroud)
(来源)
您也可以不使用顶部栏插件重新编译Swagger UI,如此处所述,并对其进行重建。您将需要Node.js 6.x和npm3.x。
编辑src/standalone/index.js并从预设中删除TopbarPlugin:
const ui = SwaggerUIBundle({
url: "http://petstore.swagger.io/v2/swagger.json",
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout"
})
Run Code Online (Sandbox Code Playgroud)重建Swagger UI –在项目的根目录中运行
npm install
Run Code Online (Sandbox Code Playgroud)
然后
npm run build
Run Code Online (Sandbox Code Playgroud)现在您dist\index.html没有顶部栏。
| 归档时间: |
|
| 查看次数: |
6076 次 |
| 最近记录: |