gpt4 book ai didi

node.js - 为 NodeJS 自定义 Swagger UI 选项卡标题和图标

转载 作者:行者123 更新时间:2023-12-05 08:14:49 24 4
gpt4 key购买 nike

有没有办法用 NodeJS 自定义 Swagger UI? ,我一直在弄乱“node_modules/swagger-ui-dist”目录中包含的“swagger-ui.css”文件,我设法更改了标签栏背景颜色并替换了栏 Logo ,但我不能'不要精确定位 index.html 文件来更改选项卡标题和图标,请记住前面提到的目录中确实有一个“index.html”文件,但似乎 swagger 每次都动态生成一个新的索引文件路由被访问。

谢谢。

最佳答案

要自定义 swagger 页面的样式,您可以将自定义 CSS 作为选项的 Favicon 属性的 'customCss' 和 'customfavIcon' 传递给设置函数。

const express = require('express');
const app = express();
const swaggerUi = require('swagger-ui-express');
const swaggerDocument = require('./swagger.json');

var options = {
customCss: '.swagger-ui .topbar { display: none }',
customSiteTitle: "New Title",
customfavIcon: "/assets/favicon.ico"
};

app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument, options));

关于node.js - 为 NodeJS 自定义 Swagger UI 选项卡标题和图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61993255/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com