项目作者: thanhson1085

项目描述 :
Combines all swagger documents in microservices
高级语言: JavaScript
项目地址: git://github.com/thanhson1085/swagger-combined.git
创建时间: 2015-08-10T10:39:00Z
项目社区:https://github.com/thanhson1085/swagger-combined

开源协议:MIT License

下载


Build Status

NPM

If you are building a microservice system and using Swagger.

This packet is able to help you combine all swagger documents to only one document.

For example, you have the swagger documents at http://service1/docs, http://service2/docs

This will help you combine all links above to only one link http://service/docs

NOTE: If you need Gulp, ES6 and somethings more, please see branch added_gulp

Installation & Run from Docker

  1. docker run -d -p 3000:3000 thanhson1085/swagger-combined

Configuration file

See config/default.json as below:

  1. {
  2. "list_url": [
  3. {
  4. "docs": "http://petstore.swagger.io/v2/swagger.json",
  5. "base_path": "http://petstore.swagger.io/v2",
  6. "route_match": ["/user*", "/pet*", "/store*"]
  7. }
  8. ],
  9. "info": { "title": "Example API", "version": "1.0" },
  10. "port": 3000
  11. }
  • docs: swagger document links
  • base_path: Proxy Target
  • route_match: Routes for proxy

Please make note that you changed config/default.json to match all swagger document links you have

Installation & Run from Source Code

  1. git clone https://github.com/thanhson1085/swagger-combined.git

Run:

  1. cd swagger-combined
  2. npm install
  3. node index.js

Test

In the default, swagger-combined run on port 3000 and included swagger-ui. So you just run http://localhost:3000?url=http://localhost:3000/docs to see everything you need. Or you can see swagger api at http://localhost:3000/docs

Example & Demo

With config/default.json:

  1. {
  2. "list_url": [
  3. {
  4. "docs": "http://petstore.swagger.io/v2/swagger.json",
  5. "base_path": "http://petstore.swagger.io/v2",
  6. "route_match": ["/user*", "/pet*", "/store*"]
  7. },
  8. {
  9. "docs": "https://angular-admin-seed.sonnguyen.ws/docs",
  10. "base_path": "https://angular-admin-seed.sonnguyen.ws",
  11. "route_match": ["/api/v1*"]
  12. }
  13. ],
  14. "info": { "title": "Example API", "version": "1.0" },
  15. "port": 3000
  16. }

License (MIT)

Copyright (c) 2015 Nguyen Sy Thanh Son thanhson1085@gmail.com