Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate static docs with swagger

Tags:

swagger

Is there a method for creating static documentation for swagger 2.0? Perhaps like the 'preview' on editor.swagger.io.

I need to get static html files so I can include them in some static documents.

So far I've not found a way to do this. I see there is swagger-codegens static-docs but this only works for swagger <= 1.2.

like image 473
romeovs Avatar asked Oct 28 '14 09:10

romeovs


1 Answers

Use swagger-codegen:

swagger-codegen generate -i <path to your swagger file> -l html2 -o <path to output location> 

If you decide to customize the HTML template:

  1. Clone the swagger-codegen project from github
  2. Copy modules/swagger-codegen/src/main/resources/htmlDocs2 folder to another place, for example: cp -R modules/swagger-codegen/src/main/resources/htmlDocs2 ~/templates
  3. Modify the .mustache templates in ~/templates to fit your requirements.
  4. Run: swagger-codegen generate -i <path to your swagger file> -l html2 -o <path to output location> -t <templates path> for <templates path> should be ~/templates in the example above.
like image 160
ZigZagT Avatar answered Sep 27 '22 21:09

ZigZagT