作为迁移的一部分,我已经安装了Loopback 4,并将我的遗留Loopback 3应用程序安装到其中——到目前为止一切都很好。
然而,我的(招摇过市的ui形状(浏览器渲染默认情况下是扩展的,而且有很多端点和服务,所以很难找到我想要的东西。
我的直觉告诉我应该能够在application.ts
中添加配置,但我什么都找不到。
this.configure(RestExplorerBindings.COMPONENT).to({
path: '/explorer',
docExpansion:'none' <<<<< this is what I would expect/like
});
this.component(RestExplorerComponent);
有人能做到这一点吗?论坛上似乎有很多这样的请求。
你可以试试这个。
https://www.npmjs.com/package/@环回/休息浏览器
重写Swagger UI index.html为了获得更大的灵活性,可以使用indexTemplatePath
属性来完全自定义Swagger UI配置选项。
indexTemplatePath
应该是指向html.ejs模板的绝对路径。
要开始,请下载默认的index.html.ejs,将/explorer/index.html.ejs
添加到您的项目中,并更新配置:
this.configure(RestExplorerBindings.COMPONENT).to({
// For example, create a directory "explorer" at the same level
// as "src" and "node_modules" in your applciation structure
indexTemplatePath: path.resolve(__dirname, '../explorer/index.html.ejs'),
});
然后可以添加
docExpansion: 'none',
在index.html.ejs文件中。
const ui = SwaggerUIBundle({
url: '<%- openApiSpecUrl %>',
dom_id: '#swagger-ui',
deepLinking: true,
filter: true,
docExpansion: 'none',
defaultModelsExpandDepth: 0,
defaultModelExpandDepth: 0,
presets: [
SwaggerUIBundle.presets.apis,
// SwaggerUIStandalonePreset
SwaggerUIStandalonePreset.slice(1) // Disable the top bar
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: 'StandaloneLayout'
})