作为迁移的一部分,我已经安装了Loopback4,并将遗留的Loopback3应用程序挂载到其中-到目前为止一切正常。
然而,我的(swagger-ui形状)浏览器的渲染默认是展开的--而且有很多端点和服务--这使得我很难找到我想要的东西。
我的直觉告诉我,我应该能够在我的application.ts中添加配置-但我找不到任何东西。
this.configure(RestExplorerBindings.COMPONENT).to({
path: '/explorer',
docExpansion:'none' <<<<< this is what I would expect/like
});
this.component(RestExplorerComponent);有没有人能够做到这一点?从论坛上看,似乎有很多这样的请求。
发布于 2021-06-01 18:27:34
你可以试试这个。
https://www.npmjs.com/package/@loopback/rest-explorer
覆盖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'
}) https://stackoverflow.com/questions/67228756
复制相似问题