How to open Swagger-ui from vert.x

走远了吗. 提交于 2019-12-05 22:12:05

问题


I want to implement Swagger-UI in Vert.X app. I have listed all routes and I want to see them in swagger-ui like in SpringBoot. I have also manually edited them in swagger-editor. So, how to open localhost:8080/swagger-ui.html from vert.x app and there to see all routers.

I read that i need to save the json from swagger-editor and to put it in src/resources. After that what?

Also i found a great stuff here: https://github.com/phiz71/vertx-swagger and http://vertx.io/blog/presentation-of-the-vert-x-swagger-project/

But how to implement it?


回答1:


Well, you started in the wrong direction a bit. Those examples demonstrate how to build VertX application out of Swagger files. What you want is to serve Swagger UI through VertX. I've put an example project for you: https://github.com/AlexeySoshin/VertxSwaggerUI

When you open http://localhost:8080/swagger/ you'll see all Swagger documentation, as usual.

If you want to do that by yourself:

  1. Copy https://github.com/swagger-api/swagger-ui/tree/master/dist contents under your resources/webroot
  2. Put swagger.json along with those files
  3. Create StaticHandler in VertX: router.route("/*").handler(StaticHandler.create());


来源:https://stackoverflow.com/questions/48518149/how-to-open-swagger-ui-from-vert-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!