swagger的导出
swagger-export是一个提供swagger文档导出功能的服务,不依赖于具体的API接口服务实现,你可以很方便地导出html和pdf两种格式的静态文档。源码来自swagger导出静态API文档工具,做了一些修改,以符合实际的项目需要。
一.在src下配置asciidoc

二.pom.xml
也就是maven插件
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.</modelVersion> <groupId>com.jeesun</groupId>
<artifactId>swagger-export</artifactId>
<version>1.0.</version> <properties>
<swaggerInputPath>http://127.0.0.1:8080/api/v2/api-docs</swaggerInputPath>
</properties> <build>
<finalName>com-jeesun-${project.artifactId}-${project.version}</finalName> <plugins>
<!--此插件生成ASCIIDOC-->
<plugin>
<groupId>io.github.swagger2markup</groupId>
<artifactId>swagger2markup-maven-plugin</artifactId>
<version>1.3.</version>
<dependencies>
<dependency>
<groupId>io.github.swagger2markup</groupId>
<artifactId>swagger2markup</artifactId>
<version>1.3.</version>
</dependency>
</dependencies>
<configuration>
<!--此处端口一定要是当前项目启动所用的端口-->
<swaggerInput>${swaggerInputPath}</swaggerInput>
<outputDir>${project.build.directory}/docs/asciidoc/generated</outputDir>
<config>
<!-- 除了ASCIIDOC之外,还有MARKDOWN和CONFLUENCE_MARKUP可选 -->
<swagger2markup.markupLanguage>ASCIIDOC</swagger2markup.markupLanguage>
<swagger2markup.pathsGroupedBy>TAGS</swagger2markup.pathsGroupedBy>
<swagger2markup.outputLanguage>ZH</swagger2markup.outputLanguage>
</config>
</configuration>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>convertSwagger2markup</goal>
</goals>
</execution>
</executions> </plugin>
<!--此插件生成HTML和PDF-->
<plugin>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>
<version>1.5.</version>
<!-- Include Asciidoctor PDF for pdf generation -->
<dependencies>
<dependency>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctorj-pdf</artifactId>
<version>1.5.-alpha.</version>
</dependency>
<!--<dependency>-->
<!--<groupId>org.jruby</groupId>-->
<!--<artifactId>jruby-complete</artifactId>-->
<!--<version>1.7.</version>-->
<!--</dependency>-->
<!-- Comment this section to use the default jruby artifact provided by the plugin -->
<dependency>
<groupId>org.jruby</groupId>
<artifactId>jruby-complete</artifactId>
<version>9.1.8.0</version>
</dependency>
<!-- Comment this section to use the default AsciidoctorJ artifact provided by the plugin -->
<dependency>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctorj</artifactId>
<version>1.5.</version>
</dependency> </dependencies>
<!-- Configure generic document generation settings -->
<configuration>
<sourceDirectory>src/docs/asciidoc</sourceDirectory>
<sourceDocumentName>index.adoc</sourceDocumentName>
<sourceHighlighter>coderay</sourceHighlighter>
<attributes>
<doctype>book</doctype>
<toc>left</toc>
<toclevels></toclevels>
<numbered></numbered>
<hardbreaks></hardbreaks>
<sectlinks></sectlinks>
<sectanchors></sectanchors>
<generated>${project.build.directory}/docs/asciidoc/generated</generated>
</attributes>
</configuration>
<!-- Since each execution can only handle one backend, run
separate executions for each desired output type -->
<executions>
<execution>
<id>output-html</id>
<phase>generate-resources</phase>
<goals>
<goal>process-asciidoc</goal>
</goals>
<configuration>
<backend>html5</backend>
<outputDirectory>${project.build.directory}/docs/asciidoc/html</outputDirectory>
</configuration>
</execution> <execution>
<id>output-pdf</id>
<phase>generate-resources</phase>
<goals>
<goal>process-asciidoc</goal>
</goals>
<configuration>
<backend>pdf</backend>
<outputDirectory>${project.build.directory}/docs/asciidoc/pdf</outputDirectory>
</configuration>
</execution> </executions>
</plugin>
<!-- end::plugin[] -->
</plugins>
</build>
<!--<repositories>
<repository>
<id>jcenter-releases</id>
<name>jcenter</name>
<url>http://jcenter.bintray.com</url>
</repository>
</repositories>-->
<pluginRepositories>
<pluginRepository>
<id>jcenter-releases</id>
<name>jcenter</name>
<url>http://jcenter.bintray.com</url>
</pluginRepository>
</pluginRepositories>
</project>
导出步骤
启动待导出的API接口服务;
修改pom文件中
properties配置的swaggerInputPath值为目标服务的IP端口信息;在当前目录执行
mvn clean compile命令;生成的文档有html和pdf两种格式,目录分别为
target\docs\asciidoc\html\index.html
target\docs\asciidoc\pdf\index.pdf
导出的pdf格式文件,中文存在显示问题。可用Word2016打开,然后另存为word格式文件。
注意:
导出时,如果有数据权限,得放出 /v2/api-docs 接口。
swagger的导出的更多相关文章
- 怎么将swagger API导出为HTML或者PDF
文章目录 将swagger API导出为HTML或者PDF 什么是Asciidoc swagger2markup-maven-plugin asciidoctor-maven-plugin 使用命令行 ...
- 通过Swagger接口导出模板文件时报错:URL.createObjectURL: Argument 1 is not valid for any of the 1-argument overloads.
问题描述:通过Swagger接口导出Excel模板文件时,报错:URL.createObjectURL: Argument 1 is not valid for any of the 1-argume ...
- 在.Net Core WebAPI下给Swagger增加导出离线文档功能
一丶前言 最近刚接触到Swagger,在github上下载了它的源码和demo学习了一遍,发现这个组件非常好用,不过不足的是它没有导出离线文档的功能,于是乎我就想给它加一个导出功能 Swagger G ...
- swagger json导出word,Typora软件推荐!!!
场景: 前几天项目验收,赶了一整天补API接口设计文档,给爷整吐了.周末的时候就想能不能直接把swagger的json文件导出成word? 顺便学习一下NPOI的使用. 实现思路: 1.先把swaag ...
- swagger环境搭建
下面所用工具下载 http://editor.swagger.io/#/ demo 一.安装 swagger editor 说明:安装swagger前需要安装node工具 工具安装 ...
- 浅谈API网关(API Gateway)如何承载API经济生态链
序言 API经济生态链已经在全球范围覆盖, 绝大多数企业都已经走在数字化转型的道路上,API成为企业连接业务的核心载体, 并产生巨大的盈利空间.快速增长的API规模以及调用量,使得企业IT在架构上.模 ...
- 阿里云高磊:API网关加速能力聚合与生态集成
导读:本文中,阿里云高级技术专家高磊(花名:埃兰)将聚焦API网关加速能力聚合与生态集成,讲述API如何实现系统间的衔接和API网关的产品升级进程,重点展示了一些新功能.新体验和新变化. 大家下午好, ...
- Swagger 导出API
Swagger 导出API 这算是在博客园的第一篇博客吧,之后发的应该也会同步到博客园上. 此前的博客地址: https://blog.mytyiluo.cn Swagger简介 Swagger是一个 ...
- C#中缓存的使用 ajax请求基于restFul的WebApi(post、get、delete、put) 让 .NET 更方便的导入导出 Excel .net core api +swagger(一个简单的入门demo 使用codefirst+mysql) C# 位运算详解 c# 交错数组 c# 数组协变 C# 添加Excel表单控件(Form Controls) C#串口通信程序
C#中缓存的使用 缓存的概念及优缺点在这里就不多做介绍,主要介绍一下使用的方法. 1.在ASP.NET中页面缓存的使用方法简单,只需要在aspx页的顶部加上一句声明即可: <%@ Outp ...
随机推荐
- Python os.stat_float_times() 方法
概述 os.stat_float_times() 方法用于决定stat_result是否以float对象显示时间戳.高佣联盟 www.cgewang.com 语法 stat_float_times() ...
- PHP link() 函数
定义和用法 link() 函数创建一个从指定名称连接的现存目标文件开始的硬连接. 如果成功,该函数返回 TRUE.如果失败,则返回 FALSE. 语法 link(target,link) 参数 描述 ...
- Spring异常总结
1. Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean o ...
- 分布式任务调度平台 → XXL-JOB 实战
开心一刻 老师:谁知道鞭炮用英语怎么说? 甲:老师!老师!我知道,鞭炮的英文是pilipala. 老师:那闪电呢? 乙:kucha kucha 老师:那舞狮呢? 丙:dong dong qiang 老 ...
- 一文打尽Java抽象类和接口的相关问题
相关文章: <面向对象再探究>:介绍了面向对象的基本概念 <详解Java的对象创建>:介绍了对象的创建.构造器的使用 <一文打尽Java继承的相关问题>:介绍了继承 ...
- 用Python绘制一套“会跳舞”的动态图形给你看看
在读技术博客的过程中,我们会发现那些能够把知识.成果讲透的博主很多都会做动态图表.他们的图是怎么做的?难度大吗?这篇文章就介绍了 Python 中一种简单的动态图表制作方法. 看这优美的舞姿 很多人学 ...
- Java集合最全解析,学集合,看这篇就够用了!!!
在看集合类之前, 我们要先明白一下概念: 1.数据结构 (1):线性表 [1]:顺序存储结构(也叫顺序表) 一个线性表是n个具有相同特性的数据元素的有限序列.数据元素是一个抽象的符号,其具体含义在不同 ...
- 手写IOC实现过程
一.手写ioc前基础知识 1.什么是IOC(Inversion of Control 控制反转)? IoC不是一种技术,只是一种思想,一个重要的面向对象编程的法则,它能指导我们如何设计出松耦合.更优良 ...
- RabbitMQ 基础概念进阶
上一篇 RabbitMQ 入门之基础概念 介绍了 RabbitMQ 的一些基础概念,本文再来介绍其中的一些细节和其它的进阶的概念. 一.消息生产者发送的消息不可达时如何处理 RabbitMQ 提供了消 ...
- C#开发笔记之02-什么时候使用OnXXX方法,这种命名是什么意思?
C#开发笔记概述 该文章的最新版本已迁移至个人博客[比特飞],单击链接 https://www.byteflying.com/archives/958 访问. 你也许经常会看到别人写的代码里有OnXX ...