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.

Read more about it in the
[FastAPI docs for Custom Docs UI Static Assets (Self-Hosting)](https://fastapi.tiangolo.com/how-to/custom-docs-ui-assets/).
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.

Parameters

NameTypeDescription
openapi_urlstrThe OpenAPI URL that ReDoc should load and use to generate the documentation.
titlestrThe HTML < title > content, normally shown in the browser tab.
redoc_js_urlstr = https://cdn.jsdelivr.net/npm/redoc@2/bundles/redoc.standalone.jsThe URL to use to load the ReDoc JavaScript bundle, typically a CDN link.
redoc_favicon_urlstr = https://fastapi.tiangolo.com/img/favicon.pngThe URL of the favicon to use in the browser tab for the documentation page.
with_google_fontsbool = TrueControls whether to load and use Google Fonts (Montserrat and Roboto) in the UI.

Returns

TypeDescription
HTMLResponseThe complete HTML document as a response object, configured to initialize the ReDoc documentation UI.