How to generate offline Swagger API docs?

37,138

Solution 1

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>).

Solution 2

Swagger has tool for generating offline docs.

The tool is "Swagger2Markup" which is located @ Github.

The output of "Swagger2Markup" can be used as an alternative to swagger-ui and can be served as static content.

Here is an Example

Good luck! :)

Solution 3

You can try "HTML" or "Dynamic HTML" under the "Generate Client" menu in https://editor.swagger.io. For any issue/feedback with the static doc, please report in the Swagger Codegen Github repo.

editor.swagger.io leverages https://generator.swagger.io to generate code and generator.swagger.io (Swagger Generator) is part of the Swagger Codegen project.

Solution 4

Open the live swagger HTML. click on expanding all the operations. Then save the HTML as PDF.

This should give you a decent PDF API documentation with all the details in it.

Solution 5

Pretty-swag is a UI for Swagger Specification V2 capable of generating static HTML an other formats. It is inspired by Swagger Editor.

checkout https://github.com/twskj/pretty-swag

Share:
37,138
code
Author by

code

Updated on January 22, 2020

Comments

  • code
    code over 4 years

    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

  • Pavlonator
    Pavlonator about 3 years
    neither of those two options help with original case when contracts are defined and need to generate swagger yml or swagger.html