farhatmo / express-swaggerize

Amazing package for swagger-ui + express

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Express-Swaggerize

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.

Supported Swagger Versions

Quick Start

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);

Contributing

We welcome pull requests from the community! Feel free to propose new features as PR in order to improve this package.

About

Amazing package for swagger-ui + express

License:MIT License


Languages

Language:HTML 75.6%Language:JavaScript 24.4%