navicore
navicore

Reputation: 2119

swagger-tools on node: how to serve swagger-ui from basePath

using nodejs and swagger-tools v0.8.7 to route endpoints.

"basePath": "/api/myapi" in the api/myapi.json works great, ie: GET, POST, etc... at http://localhost:3000/api/myapi works.

But I still have to access http://localhost:3000/docs/ to get at the UI tool. How can I serve this from http://localhost:3000/api/myapi/docs/ ?

Same question for serving the yaml at /api/myapy/api-docs instead of /api-docs.

Thx.

Upvotes: 0

Views: 875

Answers (1)

navicore
navicore

Reputation: 2119

got what i wanted via:

app.use(middleware.swaggerRouter(
  {
    swaggerUi: '/myapi.json',
    controllers: './lib'
  }));

app.use(middleware.swaggerUi(
  {
    "apiDocs": "/myapi/api",
    "swaggerUi": "/myapi.json"
  }
));

Upvotes: 0

Related Questions