Skip to content

Latest commit

 

History

History
57 lines (41 loc) · 1.76 KB

README.md

File metadata and controls

57 lines (41 loc) · 1.76 KB

remark-openapi

NPM Travis CI MIT License

A remark plugin that converts a link to a local or remote open api spec into a table with summary of all paths.

This project is inspired by remark-swagger. It borrows some code in table generation from remark-swagger.

Installation

$ npm install remark-openapi

Usage

This plugin is to be used with remark, e.g.

var vfile = require('to-vfile');
var remark = require('remark');
var openapi = require('remark-openapi');

var example = vfile.readSync('example.md');

remark()
  .use(openapi)
  .process(example, function (err, file) {
    if (err) throw err;

    console.log(String(file));
  });

This plugin does a conversion when the markdown file contains a link to a local open api spec file

[API Reference](../assets/petstore-open-api.json "openapi:")

or a remote open api spec file

[API Reference](https://temando.github.io/open-api-renderer/petstore-open-api-v3.0.0-RC2.json "openapi:")

The above will be converted to the following table:

# swagger link
| Path  | Method | Summary                    |
| ----- | ------ | -------------------------- |
| /pet  | POST   | Add a new pet to the store |
| /pet  | PUT    | Update an existing pet     |
| /user | POST   | Create user                |