@egomobile/swagger-proxy
TypeScript icon, indicating that this package has built-in type declarations

0.6.0 • Public • Published

npm last build PRs Welcome

@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.

Package Sidebar

Install

npm i @egomobile/swagger-proxy

Weekly Downloads

2

Version

0.6.0

License

LGPL-3.0

Unpacked Size

69.8 kB

Total Files

34

Last publish

Collaborators

  • ekmobile
  • egodux
  • mkloubertego
  • mkloubert
  • ekegodigital