Function setupSwaggerProxy

  • Sets up a IHttpServer instance for a Swagger proxy.

    Example

    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)

    Parameters

    Returns void

Generated using TypeDoc