Function sourcesFromEnvVars

  • Creates a Swagger document fetcher for a local file.

    Example

    import createServer from "@egomobile/http-server"
    import { setupSwaggerProxy, sourcesFromEnvVars } from "@egomobile/swagger-proxy"

    async function main() {
    const app = createServer()

    setupSwaggerProxy(app, {
    "baseDocument": {
    "info": {
    "title": "My merged API",
    "version": "1.0.0"
    }
    },

    "sources": [
    // setup environments like this:
    //
    // SWAGGER_SOURCE_1=https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v3.0/petstore.yaml
    // SWAGGER_SOURCE_2=https://petstore.swagger.io/v2/swagger.json
    // SWAGGER_SOURCE_3=/path/to/local/file.yaml
    ...sourcesFromEnvVars(),
    ]
    })

    await app.listen(8080)
    }

    main().catch(console.error)

    Returns

    The sources.

    Returns SwaggerSourceValue[]

Generated using TypeDoc