Skip to content

forestlake/express-api-doc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DEPRECATED

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',
});

About

auto generated express documentation

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •