【若依(ruoyi)】swagger 生成接口文档

前言

  • 若依(ruoyi): v4.3

若依自带了 swagger 的接口。
将若依启动后,访问 http://localhost/swagger-ui.html (或者使用菜单系统工具 -> 系统接口)可以查看接口。
在这里插入图片描述

将若依启动后,访问 http://localhost/v2/api-docs 可以查看 json 格式的接口文档。
在这里插入图片描述
一切都很不错,只是要有个 html 或 pdf 格式的接口文档就更好了。

更好的 html 或 pdf 格式的接口文档

要生成更好的 html 或 pdf 格式的接口文档需要用到 swagger2pdf 项目。

生成的步骤是这样的:

  1. http://localhost/v2/api-docs 的json格式接口文档,利用 Swagger2Markup Maven插件生成 asciidoc 格式的文档。
  2. 利用asciidoctor Maven插件生成 html 和 pdf 文件。

操作

  1. 克隆项目 https://gitee.com/sayyy/swagger2pdf
  2. http://localhost/v2/api-docs 另存为 swagger.json
  3. 替换 swagger2pdf/src/test/resources 目录下的 swagger.json
  4. swagger2pdf 目录下执行命令:
    mvn clean test
    
  5. swagger2pdf/target/asciidoc目录找到 html/pdf 格式的接口文档

结果展示

在这里插入图片描述

参考

https://github.com/Swagger2Markup/spring-swagger2markup-demo
https://leongfeng.github.io/2017/02/20/springboot-springfox-swagger2markup-spring-restdoc/

https://gitee.com/nitianziluli/swagger2pdf
https://github.com/nitianziluli/swagger2pdf
https://blog.csdn.net/u013719669/article/details/80998225

猜你喜欢

转载自blog.csdn.net/sayyy/article/details/108216712