Home / Function/ get_redoc_html() — fastapi Function Reference

get_redoc_html() — fastapi Function Reference

Architecture documentation for the get_redoc_html() function in docs.py from the fastapi codebase.

Entity Profile

Dependency Diagram

graph TD
  609573dc_dd8d_bd61_f42b_83a7d4873d61["get_redoc_html()"]
  6383cfb2_5918_5c8c_5124_dbbbe44fbe24["docs.py"]
  609573dc_dd8d_bd61_f42b_83a7d4873d61 -->|defined in| 6383cfb2_5918_5c8c_5124_dbbbe44fbe24
  73a7d0c5_5db4_56c8_d463_a950eda03f0a["redoc_html()"]
  73a7d0c5_5db4_56c8_d463_a950eda03f0a -->|calls| 609573dc_dd8d_bd61_f42b_83a7d4873d61
  17400f79_f0b3_0e60_0033_e41c7a7cfdfd["redoc_html()"]
  17400f79_f0b3_0e60_0033_e41c7a7cfdfd -->|calls| 609573dc_dd8d_bd61_f42b_83a7d4873d61
  c029d7d0_68b4_7ce7_47cc_25c5b9dccd5d["setup()"]
  c029d7d0_68b4_7ce7_47cc_25c5b9dccd5d -->|calls| 609573dc_dd8d_bd61_f42b_83a7d4873d61
  a325402a_cab4_5fb2_49f0_ba2284d822c4["test_strings_in_generated_redoc()"]
  a325402a_cab4_5fb2_49f0_ba2284d822c4 -->|calls| 609573dc_dd8d_bd61_f42b_83a7d4873d61
  6b1d5bf4_86fc_bedc_b063_2e1e4536d0ea["test_strings_in_custom_redoc()"]
  6b1d5bf4_86fc_bedc_b063_2e1e4536d0ea -->|calls| 609573dc_dd8d_bd61_f42b_83a7d4873d61
  ff4198db_0293_f547_8f5e_2e9abc1c8717["test_google_fonts_in_generated_redoc()"]
  ff4198db_0293_f547_8f5e_2e9abc1c8717 -->|calls| 609573dc_dd8d_bd61_f42b_83a7d4873d61
  style 609573dc_dd8d_bd61_f42b_83a7d4873d61 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

fastapi/openapi/docs.py lines 183–284

def get_redoc_html(
    *,
    openapi_url: Annotated[
        str,
        Doc(
            """
            The 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](https://fastapi.tiangolo.com/how-to/conditional-openapi/#conditional-openapi-from-settings-and-env-vars)
            """
        ),
    ],
    title: Annotated[
        str,
        Doc(
            """
            The HTML `<title>` content, normally shown in the browser tab.

            Read more about it in the
            [FastAPI docs for Custom Docs UI Static Assets](https://fastapi.tiangolo.com/how-to/custom-docs-ui-assets/)
            """
        ),
    ],
    redoc_js_url: Annotated[
        str,
        Doc(
            """
            The 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](https://fastapi.tiangolo.com/how-to/custom-docs-ui-assets/)
            """
        ),
    ] = "https://cdn.jsdelivr.net/npm/redoc@2/bundles/redoc.standalone.js",
    redoc_favicon_url: Annotated[
        str,
        Doc(
            """
            The URL of the favicon to use. It is normally shown in the browser tab.
            """
        ),
    ] = "https://fastapi.tiangolo.com/img/favicon.png",
    with_google_fonts: Annotated[
        bool,
        Doc(
            """
            Load and use Google Fonts.
            """
        ),
    ] = 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)](https://fastapi.tiangolo.com/how-to/custom-docs-ui-assets/).
    """
    html = f"""
    <!DOCTYPE html>
    <html>
    <head>
    <title>{title}</title>
    <!-- needed for adaptive design -->
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    """
    if with_google_fonts:
        html += """
    <link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">
    """
    html += f"""

Domain

Subdomains

Frequently Asked Questions

What does get_redoc_html() do?
get_redoc_html() is a function in the fastapi codebase, defined in fastapi/openapi/docs.py.
Where is get_redoc_html() defined?
get_redoc_html() is defined in fastapi/openapi/docs.py at line 183.
What calls get_redoc_html()?
get_redoc_html() is called by 6 function(s): redoc_html, redoc_html, setup, test_google_fonts_in_generated_redoc, test_strings_in_custom_redoc, test_strings_in_generated_redoc.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free