1.0.6 • Published 4 years ago

api-doc-generator-on-tests v1.0.6

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

Document your API while running your tests

MIT License Build Status: Linux

Installation

yarn add api-doc-generator-on-tests

Create API documentation based on Express.js

Simple express example

var express = require('express');
var Markdown = require('api-doc-generator-on-tests');

var app = express();

Markdown({
      express: app,
      path: '/api.md', // path to API API documentation
      storeResponses: true, // store first response as example
      guessAll: true, // make description quite pretty
      title: 'docTitle',
    });

// regular app express workflow ( app.get, app.post, app.listen... etc )

Add doc generation on each route test

before(async () => {
    server = await createServer({ docTitle: 'Best API Ever' });
  });

  after(async () => {
    const documentation = await apiRequest.get('api.md');
    await fs.writeFile(`${__dirname}/../../../documentation/best-api-ever.md`, documentation.text);
    await closeServer(server);
  });

// run your tests  

Result example

Options parameters

var md = new Markdown(options);
  • express - an Express application
  • path - path to get API API documentation ( default: /api.md )
  • storeResponses - store first response as example ( default: false )
  • guessAll - make description quite pretty ( default: false )
  • title - title of API in document

Tests

yarn test

Change Log

all changes

Created by

Nicolas SAILLY

1.0.6

4 years ago

1.0.5

4 years ago