Skip to main content

get_redoc_html

Generate and return the HTML response that loads ReDoc for the alternative API docs (normally served at /redoc). You would only call this function yourself if you needed to override some parts, for example the URLs to use to load ReDoc's JavaScript and CSS.

def get_redoc_html(
openapi_url: str,
title: str,
redoc_js_url: str = https://cdn.jsdelivr.net/npm/redoc@2/bundles/redoc.standalone.js,
redoc_favicon_url: str = https://fastapi.tiangolo.com/img/favicon.png,
with_google_fonts: bool = True
) - > HTMLResponse

Generate and return the HTML response that loads ReDoc for the alternative API docs (normally served at /redoc). You would only call this function yourself if you needed to override some parts, for example the URLs to use to load ReDoc's JavaScript and CSS. Read more about it in the FastAPI docs for Custom Docs UI Static Assets (Self-Hosting).

Parameters

NameTypeDescription
openapi_urlstrThe OpenAPI URL that ReDoc should load and use. This is normally done automatically by FastAPI using the default URL /openapi.json. Read more about it in the FastAPI docs for Conditional OpenAPI
titlestrThe HTML < title > content, normally shown in the browser tab. Read more about it in the FastAPI docs for Custom Docs UI Static Assets
redoc_js_urlstr = https://cdn.jsdelivr.net/npm/redoc@2/bundles/redoc.standalone.jsThe URL to use to load the ReDoc JavaScript. It is normally set to a CDN URL. Read more about it in the FastAPI docs for Custom Docs UI Static Assets
redoc_favicon_urlstr = https://fastapi.tiangolo.com/img/favicon.pngThe URL of the favicon to use. It is normally shown in the browser tab.
with_google_fontsbool = TrueLoad and use Google Fonts.

Returns

TypeDescription
HTMLResponseThe HTML response that loads ReDoc.