api-doc-generator-on-tests
v1.0.6
Published
Create markdown API documentation from Express while running your tests
Downloads
10
Readme
Document your API while running your tests
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
Created by
Nicolas SAILLY