const swaggerOptions = {
swaggerDefinition: {
info: {
version: "1.0.0",
title: "Attendance System API",
description: "Attendance System API Information",
contact: {
name: "Kellton Developer"
},
host: ["http://localhost:3000"],
basePath: "/api/v1"
}
},
schemes: ["https", "http"],
tags: [{
name: "login",
description: "user can login here",
}],
// ['.routes/*.js']
apis: ['./routes/index.js']
};
const swaggerDocs = swaggerJsDoc(swaggerOptions);
app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerDocs));
app.use('/api/v1/', indexRouter);
它总是命中 http:// localhost:3000 / login 但应该是这样的 http:// localhost:3000 / login / api / v1 / login
我猜Swagger basePath
无法正常工作。