Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Export Swagger documentation in PDF and XML files

I have generated swagger document for web api using below link: http://wmpratt.com/swagger-and-asp-net-web-api-part-1/

Need to export document in PDF or XML file to send across handy.

Its .NET WEB API.

How to export swagger documentation ?

Thanks

like image 778
user3711357 Avatar asked Nov 08 '17 14:11

user3711357


3 Answers

Here's what I did today, since many of these other projects require laborious workarounds or extra libraries or some completely separate language.

  • Go to https://editor.swagger.io/ (Make sure it's the HTTPS version)
  • At the top, click File => Import File.
  • Select your Swagger JSON file.
  • At the top, click Generate Client => HTML2 and download the ZIP file.

This yields a static HTML page that you can then print (via the browser) to PDF using the built-in Microsoft Print to PDF printer, or Adobe Acrobat, or whatever else you might want to use.

like image 160
Synctrex Avatar answered Oct 20 '22 07:10

Synctrex


You can use Swagger2Markup and AsciiDoc docker images:

docker run --rm -v $(pwd):/opt swagger2markup/swagger2markup convert -i "https://api.example.org/api/doc/swagger.json" -f /opt/swagger-doc

Creates asciidoc file named 'swagger-doc.adoc' in current folder.

docker run -it -v $(pwd):/documents/ asciidoctor/docker-asciidoctor asciidoctor-pdf swagger-doc.adoc

Creates a PDF file named 'swagger-doc.pdf' in current folder.

like image 11
Gabriel Arellano Avatar answered Oct 20 '22 08:10

Gabriel Arellano


The Swagger2Markup project is on GitHub and some more information you'll find by using Google too.

Swagger2Markup converts a Swagger JSON or YAML file into several AsciiDoc or GitHub Flavored Markdown documents which can be combined with hand-written documentation.

AsciiDoc is preferable to Markdown as it has more features. AsciiDoc is a text document format for writing documentation, articles, books, ebooks, slideshows, web pages and blogs. AsciiDoc files can be converted to HTML, PDF and EPUB. AsciiDoc is much better suited for describing public APIs than JavaDoc or Annotations.

You can generate your HTML5, PDF and EPUB documentation via asciidoctorj or even better via the asciidoctor-gradle-plugin or asciidoctor-maven-plugin.

The project requires at least JDK 8.

See also RESTful API Documentation with Swagger and AsciiDoc

like image 2
help-info.de Avatar answered Oct 20 '22 09:10

help-info.de