Swagger to Html

A java tool to convert swagger json to readable doc

License

License

Categories

Categories

Swagger Program Interface REST Frameworks
GroupId

GroupId

com.github.chenjianjx
ArtifactId

ArtifactId

swagger2html
Last Version

Last Version

2.0.3
Release Date

Release Date

Type

Type

jar
Description

Description

Swagger to Html
A java tool to convert swagger json to readable doc
Project URL

Project URL

https://github.com/chenjianjx/swagger2html
Source Code Management

Source Code Management

https://github.com/chenjianjx/swagger2html

Download swagger2html

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.chenjianjx/swagger2html/ -->
<dependency>
    <groupId>com.github.chenjianjx</groupId>
    <artifactId>swagger2html</artifactId>
    <version>2.0.3</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.chenjianjx/swagger2html/
implementation 'com.github.chenjianjx:swagger2html:2.0.3'
// https://jarcasting.com/artifacts/com.github.chenjianjx/swagger2html/
implementation ("com.github.chenjianjx:swagger2html:2.0.3")
'com.github.chenjianjx:swagger2html:jar:2.0.3'
<dependency org="com.github.chenjianjx" name="swagger2html" rev="2.0.3">
  <artifact name="swagger2html" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.chenjianjx', module='swagger2html', version='2.0.3')
)
libraryDependencies += "com.github.chenjianjx" % "swagger2html" % "2.0.3"
[com.github.chenjianjx/swagger2html "2.0.3"]

Dependencies

compile (6)

Group / Artifact Type Version
commons-lang : commons-lang jar 2.6
commons-beanutils : commons-beanutils jar 1.9.2
commons-io : commons-io jar 2.4
org.freemarker : freemarker jar 2.3.20
io.swagger : swagger-parser jar 1.0.13
org.pegdown : pegdown jar 1.6.0

test (1)

Group / Artifact Type Version
junit : junit jar 4.9

Project Modules

There are no modules declared in this project.

swagger2html

Converts swagger jsons to html documents which are readable by everybody.

Swagger-Codegen already has a tool to generate html documents. However, it seems ugly and in lack of information.

petstore-by-swagger-cg


swagger2html produces a neat one:

petstore-by-s2h

Check the full html here.

How to run

Run as a command line tool

mvn clean package 
unzip target/swagger2html*jarset.zip -d /path/to/your/dir
cd /path/to/your/dir/swagger2html*
./s2h.sh http://petstore.swagger.io/v2/swagger.json /path/to/your/result/doc/file.html
# or s2h.bat for windows

Run it inside your application

In your pom.xml, add the following:

	<dependencies>
		...	
		<dependency>
			<groupId>com.github.chenjianjx</groupId>
			<artifactId>swagger2html</artifactId>
			<version>2.0.3</version>
		</dependency>
		...
	</dependencies>	
	Swagger2Html s2h = new Swagger2Html();
	Writer writer = new FileWriter("someFile.html");
	s2h.toHtml("http://petstore.swagger.io/v2/swagger.json", writer);

Customization of CSS

./s2h.sh http://petstore.swagger.io/v2/swagger.json \ 
    /path/to/your/html/doc/file.html -css /path/to/your/css/with/html/tag.html");  

A css template can be found at here. It's not a css file but css snippets and/or external css links in an html file.

In java program, you can

	String cssToInclude = FileUtils.toString("/path/to/your/css/with/html/tag.html");  
	Swagger2Html s2h = new Swagger2Html();
	s2h.toHtml("http://petstore.swagger.io/v2/swagger.json", cssToInclude , writer);

Versions

Version
2.0.3
2.0.2
2.0.1
2.0.0