diff --git a/nicegui/ui_run.py b/nicegui/ui_run.py
index 78be41d26..31d9d3fc6 100644
--- a/nicegui/ui_run.py
+++ b/nicegui/ui_run.py
@@ -2,7 +2,7 @@
import os
import sys
from pathlib import Path
-from typing import Any, List, Literal, Optional, Tuple, Union
+from typing import Any, List, Literal, Optional, Tuple, TypedDict, Union
from starlette.routing import Route
from uvicorn.main import STARTUP_FAILURE
@@ -21,6 +21,28 @@
APP_IMPORT_STRING = 'nicegui:app'
+class ContactDict(TypedDict):
+ name: Optional[str]
+ url: Optional[str]
+ email: Optional[str]
+
+
+class LicenseInfoDict(TypedDict):
+ name: str
+ identifier: Optional[str]
+ url: Optional[str]
+
+
+class DocsConfig(TypedDict):
+ title: Optional[str]
+ summary: Optional[str]
+ description: Optional[str]
+ version: Optional[str]
+ terms_of_service: Optional[str]
+ contact: Optional[ContactDict]
+ license_info: Optional[LicenseInfoDict]
+
+
def run(*,
host: Optional[str] = None,
port: Optional[int] = None,
@@ -31,7 +53,7 @@ def run(*,
language: Language = 'en-US',
binding_refresh_interval: float = 0.1,
reconnect_timeout: float = 3.0,
- fastapi_docs: bool = False,
+ fastapi_docs: Union[bool, DocsConfig] = False,
show: bool = True,
on_air: Optional[Union[str, Literal[True]]] = None,
native: bool = False,
@@ -64,7 +86,7 @@ def run(*,
:param language: language for Quasar elements (default: `'en-US'`)
:param binding_refresh_interval: time between binding updates (default: `0.1` seconds, bigger is more CPU friendly)
:param reconnect_timeout: maximum time the server waits for the browser to reconnect (default: 3.0 seconds)
- :param fastapi_docs: whether to enable FastAPI's automatic documentation with Swagger UI, ReDoc, and OpenAPI JSON (default: `False`)
+ :param fastapi_docs: enable FastAPI's automatic documentation with Swagger UI, ReDoc, and OpenAPI JSON (bool or dictionary as described `here`_, default: `False`)
:param show: automatically open the UI in a browser tab (default: `True`)
:param on_air: tech preview: `allows temporary remote access `_ if set to `True` (default: disabled)
:param native: open the UI in a native window of size 800x600 (default: `False`, deactivates `show`, automatically finds an open port)
@@ -113,6 +135,16 @@ def run(*,
core.app.redoc_url = '/redoc'
if not core.app.openapi_url:
core.app.openapi_url = '/openapi.json'
+ if isinstance(fastapi_docs, dict):
+ core.app.title = fastapi_docs.get('title') or title
+ core.app.summary = fastapi_docs.get('summary')
+ core.app.description = fastapi_docs.get('description') or ''
+ core.app.version = fastapi_docs.get('version') or '0.1.0'
+ core.app.terms_of_service = fastapi_docs.get('terms_of_service')
+ contact = fastapi_docs.get('contact')
+ license_info = fastapi_docs.get('license_info')
+ core.app.contact = dict(contact) if contact else None
+ core.app.license_info = dict(license_info) if license_info else None
core.app.setup()
if on_air: