如何从 vert.x 打开 Swagger-ui

How to open Swagger-ui from vert.x

我想在 Vert.X 应用程序中实施 Swagger-UI。我已经列出了所有路线,我想在 swagger-ui 中看到它们,就像在 SpringBoot 中一样。我还在 swagger-editor 中手动编辑了它们。那么,如何从 vert.x 应用程序打开 localhost:8080/swagger-ui.html 并在那里查看所有路由器。

我读到我需要从 swagger-editor 中保存 json 并将其放入 src/resources。那之后呢?

我还在这里发现了一个很棒的东西:https://github.com/phiz71/vertx-swaggerhttp://vertx.io/blog/presentation-of-the-vert-x-swagger-project/

但是如何实现呢?

嗯,你开始的方向有点不对。 这些示例演示了如何使用 Swagger 文件构建 VertX 应用程序。 您想要的是通过 VertX 为 Swagger UI 提供服务。 我为您提供了一个示例项目: https://github.com/AlexeySoshin/VertxSwaggerUI

当您打开 http://localhost:8080/swagger/ 时,您会像往常一样看到所有 Swagger 文档。

如果你想自己做:

  1. 复制https://github.com/swagger-api/swagger-ui/tree/master/dist你的resources/webroot下的内容
  2. 将 swagger.json 与这些文件放在一起
  3. 在 VertX 中创建 StaticHandler:router.route("/*").handler(StaticHandler.create());