0.1.5 • Published 3 years ago

@synx-ai/openapi2md v0.1.5

Weekly downloads
183
License
MIT
Repository
github
Last release
3 years ago

OpenAPI3 to Markdown converter

Travis Build Status GitHub Workflow Status npm npm Coveralls

Convert OpenAPI v3 spec into a directory of markdown files based on your spec paths. The purpose of this tool is to boost documentation generation and seamlessly integrate them into static site generators.

Handlebars is used to provide fully configurable templating support.

Installation

yarn

yarn add @synx-ai/openapi2md

npm

npm install @synx-ai/openapi2md

Basic usage

Options

OptionCLI argumentJavaScript parameterDefault
OpenAPI spec--specspecFileNone
Target build dir--targetoutPath./build
Templates dir--templatestemplatePath./templates

The tool will try to load the --templates relative to current working path first, then will fallback to library path.

CLI

Usage: openapi2md --specs [file] --target [target path] --templates [template path]

Options:
      --version   Show version number                         [boolean]
  -s, --spec      OpenAPI specification                      [required]
  -o, --target    target build path                [default: "./build"]
  -t, --template  templates paths              [default: "./templates"]
      --help      Show help

JavaScript

const convert = require('openapi2md').default;

convert('./example/petstore.json', './build');

Templates

For every operation in paths, object with all references resolved will be passed to templates/path.hdb, please refer to default template for an example in how to use it.

Please note that before saving, prettify will be executed to format the output, you can disable it using the <!-- prettier-ignore-start --> tag, exmaple:

<!-- prettier-ignore-start -->

<Tabs defaultValue="{{someVar}}" values={[
{{#each content}}
  { label: "{{@key}}", value: "{{@key}}" },
{{/each}}
]}>

<!-- prettier-ignore-end -->

Roadmap

  • Create a cli.js file to execute commands using yarn or npm
  • Add more configurations (ie: custom templates)
  • ~MDX templating support for platform that supports React components.~ Removed as it can be customized from current templates.
  • Add schemas and general info rendering.

Contribute

PR's are more than welcome and highly appreciated.