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 ...
随机推荐
- PHP 标量类型与返回值类型声明
标量类型声明 默认情况下,所有的PHP文件都处于弱类型校验模式. PHP 7 增加了标量类型声明的特性,标量类型声明有两种模式: 强制模式 (默认) 严格模式 标量类型声明语法格式: declare( ...
- Python os.tmpfile() 方法
概述 os.tmpfile() 方法用于返回一个打开的模式为(w+b)的临时文件对象,这文件对象没有文件夹入口,没有文件描述符,将会自动删除.高佣联盟 www.cgewang.com 语法 tmpfi ...
- PHP debug_print_backtrace() 函数
定义和用法 debug_print_backtrace() 函数打印 backtrace. 该函数显示由 debug_print_backtrace() 函数代码生成的数据. 语法 debug_pri ...
- PHP fwrite() 函数
定义和用法 fwrite() 函数将内容写入一个打开的文件中. 函数会在到达指定长度或读到文件末尾(EOF)时(以先到者为准),停止运行. 如果函数成功执行,则返回写入的字节数.如果失败,则返回 FA ...
- Dynmaics 365 scale group
关于scale Groups的概念,在看Dynamics crm online的时候,一直不理解缩放组scale group的概念,后来查到GP也在用这个概念,想想不就是动态扩展嘛,马上顿悟了,原来如 ...
- 唯一约束 UNIQUE KEY
目录 什么是唯一约束 与主键的区别 创建唯一约束 唯一性验证 什么是唯一约束 Unique Key:它是 MySQL 中的唯一约束,是指在所有记录中字段的值不能重复出现.例如,为 id 字段加上唯一性 ...
- PV与UV你的网站也可以
个人博客网站分析 阅读前面的文章,有助于理解本文. 1.是时候来一个个人博客网站了 2.什么?你还没有自己的域名? 3.你的个人博客网站该上线了! 为什么需要流量分析? 各位小伙伴,请看下图,你们发现 ...
- Java动态代理(AOP)
目录 一.代理 1. 什么是代理? 2. 使用代理模式的作用 3. 实现代理的方式 二.静态代理 1. 模拟用户购买u盘 2. 静态代理的缺点 三.动态代理 四. JDK 动态代理 1. Invoca ...
- MyFirstJavaWeb
源代码: Register.jsp <%@ page language="java" contentType="text/html; charset=utf-8&q ...
- git使用-远程仓库(github为例)
1.登录github(没有先注册账号) 2.settings>SSH and GPG keys>New SSH key Title(自己填写即可) key需要git命令生成 ssh-key ...