swagger-aggregator
swagger-aggregator is a tool to merge multiple swagger REST API schemas into one schema.
This is helpful if you are using an API Gateway approach to your REST API.
Example Usage
swagger.yaml
swagger: '2.0'info: version: "1.0.0" title: "API Gateway" description: This swagger file was aggregated using swagger-aggregator! basePath: /v2 x-apis: pet: https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v2.0/yaml/petstore.yaml uber: https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v2.0/json/uber.json trains: local/file/trains.yaml
The x-apis
property is the list of external or local schemas to aggregate.
To use swagger-aggregator
, simply require it and pass the file name to aggregate. swagger-aggregator
returns a promise with the JSON object result.
npm install --save-dev swagger-aggregator
const aggregator = ; const fs = ; module { return ; };