Back to Sanic

Sanic Extensions - OAS UI

guide/content/en/plugins/sanic-ext/openapi/ui.md

25.12.02.2 KB
Original Source

UI

Sanic Extensions comes with both Redoc and Swagger interfaces. You have a choice to use one, or both of them. Out of the box, the following endpoints are setup for you, with the bare /docs displaying Redoc.

  • /docs
  • /docs/openapi.json
  • /docs/redoc
  • /docs/swagger
  • /docs/openapi-config

Config options

KeyTypeDefaultDesctiption
OAS_IGNORE_HEADboolTrueWhether to display HEAD endpoints.
OAS_IGNORE_OPTIONSboolTrueWhether to display OPTIONS endpoints.
OAS_PATH_TO_REDOC_HTMLOptional[str]NonePath to HTML to override the default Redoc HTML
OAS_PATH_TO_SWAGGER_HTMLOptional[str]NonePath to HTML to override the default Swagger HTML
OAS_UI_DEFAULTOptional[str]"redoc"Can be set to redoc or swagger. Controls which UI to display on the base route. If set to None, then the base route will not be setup.
OAS_UI_REDOCboolTrueWhether to enable Redoc UI.
OAS_UI_SWAGGERboolTrueWhether to enable Swagger UI.
OAS_URI_TO_CONFIGstr"/openapi-config"URI path to the OpenAPI config used by Swagger
OAS_URI_TO_JSONstr"/openapi.json"URI path to the JSON document.
OAS_URI_TO_REDOCstr"/redoc"URI path to Redoc.
OAS_URI_TO_SWAGGERstr"/swagger"URI path to Swagger.
OAS_URL_PREFIXstr"/docs"URL prefix to use for the Blueprint for OpenAPI docs.