【问题标题】:swagger-tools on node: how to serve swagger-ui from basePath节点上的 swagger-tools:如何从 basePath 提供 swagger-ui
【发布时间】:2015-07-27 16:03:14
【问题描述】:

使用 nodejs 和 swagger-tools v0.8.7 来路由端点。

"basePath": "/api/myapi" 在 api/myapi.json 中效果很好,即:http://localhost:3000/api/myapi 处的 GET、POST 等...有效。

但我仍然需要访问 http://localhost:3000/docs/ 才能使用 UI 工具。我如何从http://localhost:3000/api/myapi/docs/ 提供这个服务?

在 /api/myapy/api-docs 而不是 /api-docs 上提供 yaml 的问题相同。

谢谢。

【问题讨论】:

    标签: swagger swagger-ui swagger-2.0


    【解决方案1】:

    得到了我想要的东西:

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

    【讨论】:

      猜你喜欢
      • 2016-07-18
      • 2016-11-18
      • 2016-11-09
      • 2021-12-18
      • 2016-07-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多