feat: 添加/api/swagger/swagger.json
This commit is contained in:
@@ -8,5 +8,12 @@ export function RegisterTsoaRoutes(app: any) {
|
|||||||
|
|
||||||
// Serve swagger documentation (dynamic import)
|
// Serve swagger documentation (dynamic import)
|
||||||
const swaggerDocument = require(path.join(__dirname, '../swagger.json'));
|
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));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user