merest-swagger
The extension of merest
that provides SWAGGER documentation support.
Installation
npm up merest
npm i --save merest-swagger
merest-swagger doesn't install the merest, so you should do it by yourself.
Recommended Installation
npm i --save merest merest-swagger mongoose express body-parser method-override
Documentation
http://dscheglov.github.io/merest/
Example
'use strict';
const merest = require('merest-swagger');
const express = require('express');
const bodyParser = require('body-parser');
const methodOverride = require('method-override');
const mongoose = require('mongoose');
const Contact = mongoose.model('Contact', new mongoose.Schema({
name: { type: String, required: true },
email: { type: String, required: true },
phone: String,
tags: [String]
}));
mongoose.connect('mongodb://localhost/merest-sample');
const app = express();
const api = new merest.ModelAPIExpress({
title: 'Contact List API',
host: 'localhost:8000',
path: '/api/v1',
options: false
});
app.use(bodyParser.json());
app.use(methodOverride());
api.expose(Contact);
api.exposeSwaggerUi();
app.use('/api/v1', api);
app.listen(8000, () => {
console.log('Express server listening on port 8000');
});
Going to swagger-ui in browser: http://localhost:8000/swagger-ui