Serve custom OAS
ahopkins opened this issue · comments
Adam Hopkins commented
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())