Generate and return the HTML that loads Swagger UI for the interactive API docs (normally served at `/docs`). You would only call this function yourself if you needed to override some parts, for example the URLs to use to load Swagger UI's JavaScript and CSS. Read more about
(
*,
openapi_url: Annotated[
str,
Doc(
"""
The OpenAPI URL that Swagger UI 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/)
"""
),
],
swagger_js_url: Annotated[
str,
Doc(
"""
The URL to use to load the Swagger UI 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/swagger-ui-dist@5/swagger-ui-bundle.js",
swagger_css_url: Annotated[
str,
Doc(
"""
The URL to use to load the Swagger UI CSS.
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/swagger-ui-dist@5/swagger-ui.css",
swagger_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",
oauth2_redirect_url: Annotated[
str | None,
Doc(
"""
The OAuth2 redirect URL, it is normally automatically handled by FastAPI.
Read more about it in the
[FastAPI docs for Custom Docs UI Static Assets](https://fastapi.tiangolo.com/how-to/custom-docs-ui-assets/)
"""
),
] = None,
init_oauth: Annotated[
dict[str, Any] | None,
Doc(
"""
A dictionary with Swagger UI OAuth2 initialization configurations.
Read more about the available configuration options in the
[Swagger UI docs](https://swagger.io/docs/open-source-tools/swagger-ui/usage/oauth2/).
"""
),
] = None,
swagger_ui_parameters: Annotated[
dict[str, Any] | None,
Doc(
"""
Configuration parameters for Swagger UI.
It defaults to [swagger_ui_default_parameters][fastapi.openapi.docs.swagger_ui_default_parameters].
Read more about it in the
[FastAPI docs about how to Configure Swagger UI](https://fastapi.tiangolo.com/how-to/configure-swagger-ui/).
"""
),
] = None,
)
| 38 | |
| 39 | |
| 40 | def get_swagger_ui_html( |
| 41 | *, |
| 42 | openapi_url: Annotated[ |
| 43 | str, |
| 44 | Doc( |
| 45 | """ |
| 46 | The OpenAPI URL that Swagger UI should load and use. |
| 47 | |
| 48 | This is normally done automatically by FastAPI using the default URL |
| 49 | `/openapi.json`. |
| 50 | |
| 51 | Read more about it in the |
| 52 | [FastAPI docs for Conditional OpenAPI](https://fastapi.tiangolo.com/how-to/conditional-openapi/#conditional-openapi-from-settings-and-env-vars) |
| 53 | """ |
| 54 | ), |
| 55 | ], |
| 56 | title: Annotated[ |
| 57 | str, |
| 58 | Doc( |
| 59 | """ |
| 60 | The HTML `<title>` content, normally shown in the browser tab. |
| 61 | |
| 62 | Read more about it in the |
| 63 | [FastAPI docs for Custom Docs UI Static Assets](https://fastapi.tiangolo.com/how-to/custom-docs-ui-assets/) |
| 64 | """ |
| 65 | ), |
| 66 | ], |
| 67 | swagger_js_url: Annotated[ |
| 68 | str, |
| 69 | Doc( |
| 70 | """ |
| 71 | The URL to use to load the Swagger UI JavaScript. |
| 72 | |
| 73 | It is normally set to a CDN URL. |
| 74 | |
| 75 | Read more about it in the |
| 76 | [FastAPI docs for Custom Docs UI Static Assets](https://fastapi.tiangolo.com/how-to/custom-docs-ui-assets/) |
| 77 | """ |
| 78 | ), |
| 79 | ] = "https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/swagger-ui-bundle.js", |
| 80 | swagger_css_url: Annotated[ |
| 81 | str, |
| 82 | Doc( |
| 83 | """ |
| 84 | The URL to use to load the Swagger UI CSS. |
| 85 | |
| 86 | It is normally set to a CDN URL. |
| 87 | |
| 88 | Read more about it in the |
| 89 | [FastAPI docs for Custom Docs UI Static Assets](https://fastapi.tiangolo.com/how-to/custom-docs-ui-assets/) |
| 90 | """ |
| 91 | ), |
| 92 | ] = "https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/swagger-ui.css", |
| 93 | swagger_favicon_url: Annotated[ |
| 94 | str, |
| 95 | Doc( |
| 96 | """ |
| 97 | The URL of the favicon to use. It is normally shown in the browser tab. |
searching dependent graphs…