@egomobile/swagger-proxy
v0.6.0
Published
Connects to multiply Swagger / OpenAPI instances and merge their documents to one.
Downloads
18
Readme
@egomobile/swagger-proxy
Extension for @egomobile/http-server, which connects to multiply Swagger / OpenAPI instances and merge their documents to one.
Install
Execute the following command from your project folder, where your
package.json
file is stored:
npm install --save @egomobile/swagger-proxy
Usage
import createServer from "@egomobile/http-server";
import { setupSwaggerProxy } from "@egomobile/swagger-proxy";
async function main() {
const app = createServer();
setupSwaggerProxy(app, {
baseDocument: {
info: {
title: "My merged API",
version: "1.0.0",
},
},
sources: [
{
url: "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v3.0/link-example.json",
},
{
url: "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v3.0/callback-example.yaml",
},
{
url: "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v3.0/petstore.yaml",
},
],
});
await app.listen(8080);
const baseURL = `http://localhost:${app.port}/swagger`;
console.log("You should now be able to access documentation at:");
console.log(`- ${baseURL}`);
console.log();
console.log("You can download documentation as files from:");
console.log(`- JSON: ${baseURL}/json`);
console.log(`- YAML: ${baseURL}/yaml`);
}
main().catch(console.error);
Documentation
The API documentation can be found here.