0.0.12 • Published 7 years ago

express-api-doc v0.0.12

Weekly downloads
1,136
License
MIT
Repository
github
Last release
7 years ago

Auto generated express documentation

To create documentation:

create file docs.js:

const Docs = require('express-api-doc');
const app = require('./app'); // your app.js
const docs = new Docs(app);
docs.generate({
  path:     './public/template.html',
});

run:

node ./docs.js

template.html will be generated in ./public/

Track requests and responses:

If You have coverage tests, you can track responses and requests, and add them to the documentation. in app.js, before routes declaration, add track function, so app.js will look like this:

const Docs = require('express-api-doc');
...
const app = express();
...
const dock = new Docs(app);
dock.track({
	path: './public/examples.txt', // responses and requests will save here
});
app.use('/', index);
...

in docs.js file pass examples option to generate function:

docs.generate({
  path:     './public/template.html',
  examples: './public/examples.txt,
});

now you can run tests with documentation generating:

node ./node_modules/.bin/mocha -r should && node ./docs.js

in generated html present list of available routes with search and sendbox, where you can try to send json to your server. Under sendbox present list of examples, where you can see request and response json which has been tracked (for instance during tests).

List of available routes:

list

Sendbox with example:

sendbox

you can change and generate your own template using express-api-doc-template project.

to use your template, pass template option to generate function in docs.js:

docs.generate({
  path:     './public/template.html',
  examples: './public/examples.txt,
  template: './path/to/your/template.html',
});
0.0.12

7 years ago

0.0.11

7 years ago

0.0.10

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago