How to generate static html file from swagger documentation?

I created the documentation with a yamlfile yamlunder:

 api/swagger/swagger.yaml

Now I want to share a static html document with its definition, but the swagger project stated that they did not plan to support html generation at all.

How can I create a static HTML file from a Swagger project?

+7
source share
3 answers

The easiest way I can come up with is to use the Swagger Editor :

  1. Go to: https://editor.swagger.io
  2. Click "File" in the top menu bar and select "Import File"
  3. " " , "HTML" "HTML2" HTML.

editor.swagger.io generator.swagger.io API-, , generator.swagger.io Swagger Codegen.

+6

swagger2markup-cli, adoc.

, ​​ Java. ( Java (TM) SE Runtime ( 1.8.0_111-b14)).

:

 wget https://jcenter.bintray.com/io/github/swagger2markup/swagger2markup-cli/1.1.0/swagger2markup-cli-1.1.0.jar

adoc :

java -jar ~/your/path/swagger2markup-cli-1.1.0.jar  help convert  -i api/swagger/swagger.yaml --outputFile static-swagger

adoc html asciidoctor:

asciidoctor *.adoc

, Ubuntu, :

sudo apt-get -qq install asciidoctor
+3
  1. Download https://github.com/swagger-api/swagger-ui - the " dist " folder of interest
  2. Copy your Swagger JSON to the dist folder
  3. Open index.html and change the URL value inside the tag at the bottom of the file to ./swagger.json(or whatever your swagger json is called there) (see here )
  4. The host is online! (or start a local server to view the results).
0
source

Source: https://habr.com/ru/post/1659750/


All Articles