feat: 添加/api/swagger/swagger.json

This commit is contained in:
dayjoy
2025-10-11 10:50:28 +08:00
parent c6464fe1d1
commit 339dccdaa5

View File

@@ -8,5 +8,12 @@ export function RegisterTsoaRoutes(app: any) {
// Serve swagger documentation (dynamic import)
const swaggerDocument = require(path.join(__dirname, '../swagger.json'));
app.use('/v3/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument));
const options = {
swaggerOptions: {
url: "/api/swagger/swagger.json",
},
}
app.get("/api/swagger/swagger.json", (req: any, res: any) => res.json(swaggerDocument));
// @ts-ignore
app.use('/api/swagger', swaggerUi.serveFiles(null, options), swaggerUi.setup(null, options));
}