Swagger basePath无法正常运行主机正确,但api仍无法正常运行。为什么?

时间:2020-09-15 07:50:38

标签: javascript node.js swagger-ui

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无法正常工作。

0 个答案:

没有答案