phantomk / moleculer-web-swagger

This is a swagger plugin for moleculer-web, just simple.
MIT License
15 stars 4 forks source link

moleculer-web-swagger

npm-veriosn npm-dt

This is a swagger plugin for moleculer-web for Moleculer microservices framework, just simple.

Install

npm install moleculer-web-swagger --save

Usage

Add a service swagger.service.js, here is all options.

const SwaggerService = require("moleculer-web-swagger");

module.exports = {
  mixins: [SwaggerService],
  settings: {
    middleware: false,
    port: 3002,
    ip: "0.0.0.0",
    expose: true,
    swagger: {
      info: {
        description: "moleculer apigateway swagger",
        version: "1.0.0",
        title: "moleculer-apigateway",
        termsOfService: "",
        contact: {
          name: "phantomk",
          url: "https://github.com/phantomk",
          email: "phantomk94@gmail.com"
        },
        license: {
          name: "Apache 2.0",
          url: "https://www.apache.org/licenses/LICENSE-2.0.html"
        }
      },
      host: "127.0.0.1:3002",
      basePath: "/v1",
      tags: [{
        name: "pet",
        description: "Everything about your Pets",
        externalDocs: {
          description: "Find out more",
          url: "http://swagger.io"
        }
      }],
      schemes: [
        "http",
        "https"
      ],
      consumes: [
        "application/json",
        "application/xml"
      ],
      produces: [
        "application/xml",
        "application/json"
      ],
    },

    routes: [
      // your moleculer-web routes
      // you can impoert from your moleculer-web service
    ]
  }
};

Not support middleware

Todo

License

The project is available under the MIT license.