Swagger-Codegen already has a tool to generate html documents. However, it seems ugly and to be in lack of information.
This project produces a neat one:
Check the full html here.
mvn package
cd target
unzip target/swagger2html-some-version-jarset.zip -d /path/to/your/dir
# Go to the direction of extraction and you will see an executable file. Run it like,
./s2h.sh http://petstore.swagger.io/v2/swagger.json /path/to/your/html/doc/file
# or s2h.bat for windows
In your pom.xml, add the following:
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
...
</repositories>
<dependencies>
<dependency>
<groupId>com.github.chenjianjx</groupId>
<artifactId>swagger2html</artifactId>
<version>1.0.7</version>
</dependency>
...
</dependencies>
Swagger2Html s2h = new Swagger2Html();
s2h.toHtml("http://petstore.swagger.io/v2/swagger.json", out);
./s2h.sh http://petstore.swagger.io/v2/swagger.json /path/to/your/html/doc/file -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 , out);