Giter Site home page Giter Site logo

swagger-export's Introduction

swagger-export

该项目的作用是根据swagger在线api生成离线api文档。

说明

  • 只适用于集成swagger框架的项目
  • 确保项目的/v2/api-docs接口可访问
  • 目前离线文档只支持html5格式,如果需要转化为docpdf格式,可以将生成的html5文件选择用world文档打开,然后选择'另存为'其他格式。(建议采用html格式,效果最好

大致思路

  • 1.通过http请求访问swagger相关接口:/v2/api-docs,将获取到的json数据保存至项目的target/asciidoc目录下,文件名为swagger.json
  • 2.读取上步中保存的swagger.json文件,转换为html形式的接口文档。

注意

该项目不需要运行任何程序,只需要修改SwaggerExportTest.java文件,然后执行相关mvn命令即可。

使用

该项目主要类只有一个,包括配置也是在该类中配置,即: src\test\java\com\beauxie\swagger\export下的SwaggerExportTest.java测试类

  • 配置URL 修改服务器地址,比如api接口访问地址为http://127.0.0.1:8080/v2/api-docs,则如下配置:
  /**
     * 服务器地址
     */
    private static String SERVICE_URL = "http://127.0.0.1:8080";
  • 生成文档

修改url地址以后,在项目根目录下打开cmd命令窗口,执行以下mvn命令:

mvn test

  • 文件位置 执行成功以后,会在项目的target/asciidoc/html目录下,生成一个名为index.html文件,这个文件就是swagger离线api文档,用浏览器打开即可查看。

相关博客:使用springfox-staticdocs生成swagger离线api

swagger-export's People

Contributors

beauxie avatar

Watchers

tangly1024 avatar  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.