API documentation generator based on jsdoc comments for express
npm install express-autodoc --save-dev
/**
* @description Get songs
* @queryParam (title) The song title
* @pathParam (:albumId) album UUID
* @produces application/json, application/xml
*/
app.get('/api/albums/:albumId/songs', (req, res) => (
res.json({
title: req.title,
})
));
node -e 'require("express-autodoc").generateSwagger(".")'
Tag | Format | Example |
---|---|---|
@queryParam | (<name>) {type: string, required: true, default: <defaultValue> } <description> | /** @queryParam (name) A name param */ |
@pathParam | (<:name>) <description> | /** @pathParam (:id) song Id */ |
@produces | <contentType1>,<contentTypeN> | /** @produces application/json */ |
@description | <description> | /** @description A description */ |
@body, @request | <body> [{"example": "object"} | ] |
@response | <response> [{"example": "object"} | ] |