Giter Site home page Giter Site logo

happyliuyi / swagger2pdf Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nitianziluli/swagger2pdf

0.0 1.0 0.0 102.08 MB

使用springBoot+springFox+swagger2markup+asciidoctorj-pdf,生成HTML和PDF格式的接口文档,也解决了PDF文档中文显示为空白的问题

Java 100.00%

swagger2pdf's Introduction

swagger2pdf

使用springBoot + springFox + swagger2markup + asciidoctorj-pdf,生成HTML和PDF格式的接口文档,也解决了PDF文档中文显示为空白的问题。

关于本项目的一些其他信息,可以看我的这篇博客

实现原理:

  1. 先利用SpringFox库生成RESTful API
  2. 再利用Swagger2Markup Maven插件生成asciidoc文档
  3. 最后利用asciidoctor Maven插件生成 html 或 pdf 文件

如何使用本项目

先下载本项目到本地,导入eclipse,等待maven下载完依赖的jar包,即可使用。运行时只需要在项目上右击-->Run As-->Maven clean-->在项目上右击-->Run As-->Maven test,只要控制台显示成功,在当前项目的target\asciidoc\htmltarget\asciidoc\pdf分别存放着HTML文档PDF文档

注意:其他IDE工具没有试过,如需使用,请自行研究。

其他说明

为了本项目使用方便,不建议将要生成文档的项目源码整合到本项目,这样做比较麻烦,需要每个项目都加。

比较好的做法是:

  • 首先你的项目要确保是spring boot的,并且集成了swagger,接口层和入参出参实体类加了swagger的相关注解,且能正确跑起来;
  • 然后将本项目的src/test/javacom.example.swagger2pdf中的Swagger2PdfTest类中的注释放开,将生成当前项目的swagger.json的代码注释掉,将url中的ipport换成自己要生成文档的项目的ipport,这里要确保这个url直接访问有数据返回,不然是无法生成文档的;
  • 最后按上面说的运行项目即可生成文档。

运行报错的看这里

有部分人说运行报错,我也没遇到过这些错误,不过我猜测可能是有些插件没下下来或者没下完整,所以我上传了我这个项目用到的所有 jar 包到 repository 目录,报错的兄弟可以把这些文件放到 .m2/repository 目录里,应该能让你的项目运行起来。如果还有问题,那就问谷歌度娘吧。

swagger2pdf's People

Contributors

nitianziluli avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.