This commit is contained in:
Aleksei Kotenko 2026-03-16 10:16:59 +00:00 committed by GitHub
commit 906348df24
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 2 deletions

View File

@ -859,6 +859,17 @@ class FastAPI(Starlette):
"""
),
] = True,
router_class: Annotated[
Type[routing.APIRouter],
Doc(
"""
The default router class to be used.
Read more in the
[FastAPI docs for Custom Router](Bigger Applications - Multiple Files).
"""
),
] = routing.APIRouter,
**extra: Annotated[
Any,
Doc(
@ -943,7 +954,7 @@ class FastAPI(Starlette):
[FastAPI docs for OpenAPI Webhooks](https://fastapi.tiangolo.com/advanced/openapi-webhooks/).
"""
),
] = webhooks or routing.APIRouter()
] = webhooks or router_class()
self.root_path = root_path or openapi_prefix
self.state: Annotated[
State,
@ -979,7 +990,7 @@ class FastAPI(Starlette):
"""
),
] = {}
self.router: routing.APIRouter = routing.APIRouter(
self.router: routing.APIRouter = router_class(
routes=routes,
redirect_slashes=redirect_slashes,
dependency_overrides_provider=self,