user3711357
user3711357

Reputation: 1625

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

Upvotes: 22

Views: 45968

Answers (4)

Synctrex
Synctrex

Reputation: 881

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.

Upvotes: 20

user10775215
user10775215

Reputation: 19

Their is no such tool or functionality to export swagger documentation into PDF or any other doc. You need to convert your swagger.json file to yaml file then u can get swagger as html doc form http://editor.swagger.io/.

Upvotes: -2

Gabriel Arellano
Gabriel Arellano

Reputation: 171

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.

Upvotes: 14

help-info.de
help-info.de

Reputation: 7288

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

Upvotes: 2

Related Questions