Skip to content

thurstonsand/swagger-combined

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Installation via NPM

npm install swagger-combined

Create sample configuration file:

cp -R node_modules/swagger-combined/config .

And see config/default.json as below:

{
    "list_url": [
        {
            "docs": "http://petstore.swagger.io/v2/swagger.json",
            "base_path": "http://petstore.swagger.io/v2",
            "route_match": ["/user*", "/pet*", "/store*"]
        }
    ],
    "info": { "title": "Example API", "version": "1.0" },
    "port": 3000
}
  • docs: swagger document links
  • base_path: Proxy Target
  • route_match: Routes for proxy

Change config/default.json to match your swagger links and run:

node node_modules/swagger-combined/app.js

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

Installation & Run from Source Code

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

Run:

cd swagger-combined
npm install
node app.js

Installation & Run from Docker

Create the configuration file config/default.json and mount it to the container:

docker run -d -p 3000:3000 -v ./config/default.json:/build/config/local.json thanhson1085/swagger-combined

Test

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

Example & Demo

With config/default.json:

{
    "list_url": [
        {
            "docs": "http://petstore.swagger.io/v2/swagger.json",
            "base_path": "http://petstore.swagger.io/v2",
            "route_match": ["/user*", "/pet*", "/store*"]
        },
        {
            "docs": "https://angular-admin-seed.sonnguyen.ws/docs",
            "base_path": "https://angular-admin-seed.sonnguyen.ws",
            "route_match": ["/api/v1*"]
        }
    ],
    "info": { "title": "Example API", "version": "1.0" },
    "port": 3000
}

See Demo

License (MIT)

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

About

Combines all swagger documents in microservices

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 94.2%
  • HTML 4.5%
  • Shell 1.3%