The project provides a middleware to integrate swagger-ui based on comments in the javascript code. The idea is to solve the common issues with connecting many package in order to get an automatic process for generating documentation from the comments in the source code. It's used with the middleware express. Please visit the issue tracker to see what issues we are aware of and what features/enhancements we are working on.
express-swaggerize used with express and parse the sources files (for the specification ) in order de define a swagger api.
var swaggerize = require('express-swaggerize');
var app = express();
var options = {
// Import swaggerDefinitions
swaggerDefinition: {
info: { // API informations (required)
title: 'Swagger', // Title (required)
version: '1.0.0', // Version (required)
description: 'A sample API made with <3' // Description (optional)
},
host: 'localhost:3000', // Host (optional)
basePath: '/api', // Base path (optional)
securityDefinitions: { // security definition (optional)
token: {
type: 'apiKey',
name: 'Authorization',
in: 'header'
}
}
},
// Path to the API docs
apiPaths: [path.resolve('./routes/*.routes.js'), path.resolve('./models/*.model.js')]
};
// Initialize express swagger object
var swagger = swaggerize(options);
// Affect the swagger express routes to '/v2/api'
app.use('/v2/api', swagger);
We welcome pull requests from the community! Feel free to propose new features as PR in order to improve this package.