View on GitHub

widdershins

OpenAPI / Swagger, AsyncAPI & Semoasa definitions to (re)Slate compatible markdown

Download this project as a .zip file Download this project as a tar.gz file

Converting an OpenAPI/Swagger file to Markdown with the Widdershins CLI

The simplest way to convert an OpenAPI or Swagger file to Markdown with Widdershins is to use the Widdershins command-line interface (CLI). For a more powerful way to use Widdershins, see Converting an OpenAPI/Swagger file to Markdown with the Widdershins JavaScript interface.

Prerequisites

Converting files on the command line

  1. Get an OpenAPI 3.0 or Swagger 2.0 file. To test the process, you can use the pet store sample here: https://petstore.swagger.io/v2/swagger.json The file must parse as a valid OpenAPI or Swagger file.
  2. Assemble the options that you want to use to convert the file. These options are listed in the README.md file.

Note that some of these options are useful only if you intend to take the Markdown output from Widdershins and convert it to HTML with Shins. Other options are not usable from the command line.

For example, the language_tabs option specifies a list of one or more languages to generate examples in, each with an ID and display name. You can generate examples in Ruby and Python with the command-line option --language_tabs 'ruby:Ruby' 'python:Python'.

  1. Optional: Put the options in an environment file for easier reuse. Environment files contain the options for the conversion in JSON format. For environment files, use the JavaScript parameter name from the README.md file, not the CLI parameter name. For example:
    {
    "language_tabs": [{ "python": "Python" }, { "ruby": "Ruby" }]
    }
    
  2. Convert the file with the widdershins command, specify the name of the OpenAPI or Swagger file, and specify the name of the output file with the -o option. Include the options in the command or specify the name of the environment file with the --environment option, as in this example:
    widdershins --environment env.json swagger.json -o myOutput.md
    

Now you can use the Markdown file in your documentation or use a tool such as Shins to convert it to HTML.