sanic-org / sanic-ext

Extended Sanic functionality

Home Page:https://sanic.dev/en/plugins/sanic-ext/getting-started.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Serve custom OAS

ahopkins opened this issue · comments

Is your feature request related to a problem? Please describe your use case.
Many users have asked about serving custom OAS files to the /docs endpoints.

Describe the solution you'd like
A config value that overrides the building of a spec.

app.config.OAS_CUSTOM_FILE = "/path/to/my/oas.json"

Additional context
https://github.com/sanic-org/sanic-ext/blob/a7f63a091a526b239bad6d352465c00b69a7de48/sanic_ext/extensions/openapi/blueprint.py

    @bp.get(config.OAS_URI_TO_JSON)
    def spec(request: Request):
        if config.OAS_CUSTOM_FILE:
            return await file(config.OAS_CUSTOM_FILE)
        return json(SpecificationBuilder().build(request.app).serialize())