How to generate offline Swagger API docs?

code picture code · Jan 25, 2016 · Viewed 34.2k times · Source

I have a spring boot MVC java Web app. I've been able to integrate Springfox for API documentation. I can visually see all of the APIs when server is up and running.

How can I generate OFFLINE swagger API documentation? Note: I would not like to use asciidoc or markdown documentation, but I'd like the same swagger API user interface in html files. I'd like so that the links are relative to local directory instead of local host server links. Thanks

Answer

g00glen00b picture g00glen00b · Jan 25, 2016

Springfox allows you to easily create a Swagger tester/API docs based on your Spring annotations.

Swagger itself has some tools to allow you to generate offline/static documentation:

  • The Swagger Editor has several ways of generating documentation listed in the Generate Client menu
  • The Swagger Codegen module allows you to generate a static and dynamic HTML document

Both of them require a Swagger YAML or JSON file. In case you don't have a Swagger definition in YAML/JSON because you're using Springfox, you can use the generated file used for Swagger UI (/v2/api-docs?group=<group name>).