How to generate a PDF or markup from OpenAPI 3.0?

Niranjan picture Niranjan · Jan 18, 2019 · Viewed 11.4k times · Source

I have an OpenAPI 3.0 spec and I want to generate a PDF out of it so that it can be given to the end users.

Currently, tools like swagger-spec-to-pdf or swagger2markup only support Swagger 2.0 but not OpenAPI 3.0. Is it possible to generate a PDF from an OpenAPI 3.0 spec without converting it to Swagger 2.0?

Answer

Helen picture Helen · Feb 4, 2019

A possible solution is to convert your OpenAPI 3.0 definition to an HTML doc, then use a browser's "Save to PDF" feature to convert HTML to PDF.

Follow these steps:

  1. Go to https://editor.swagger.io.
  2. Paste your OpenAPI 3.0 YAML/JSON definition.
  3. Select Generate Client > html.
  4. Download & unzip the file.
  5. Open the index.html page in a browser, e.g. Chrome.
  6. Select File > Print, change the Destination to Save as PDF, and save the page.