diff --git a/app/api/endpoints/plugin.py b/app/api/endpoints/plugin.py index 2af1d9f90..418819b73 100644 --- a/app/api/endpoints/plugin.py +++ b/app/api/endpoints/plugin.py @@ -86,7 +86,7 @@ from app.schemas.types import SystemConfigKey from app.startup.composition.context import HostRuntime router = ResponseAPIRouter() -router.include_router(plugin_folders_router) +router.routes.extend(plugin_folders_router.routes) _plugin_release_refresh_tasks: set[asyncio.Task] = set() diff --git a/app/api/endpoints/subscribe.py b/app/api/endpoints/subscribe.py index f259065ca..35fbbed54 100644 --- a/app/api/endpoints/subscribe.py +++ b/app/api/endpoints/subscribe.py @@ -88,7 +88,7 @@ from app.schemas.workflow import MediaInfo as _SchemaMediaInfo from app.schemas.workflow import Subscribe as _SchemaSubscribe router = ResponseAPIRouter() -router.include_router(subscribe_maintenance_router) +router.routes.extend(subscribe_maintenance_router.routes) __all__ = [ "check_subscribes", diff --git a/app/api/endpoints/system.py b/app/api/endpoints/system.py index 3bbed30df..5ba63e24f 100644 --- a/app/api/endpoints/system.py +++ b/app/api/endpoints/system.py @@ -70,7 +70,7 @@ from app.schemas.types import SystemConfigKey from app.startup.composition.context import HostRuntime router = ResponseAPIRouter() -router.include_router(system_identifiers_router) +router.routes.extend(system_identifiers_router.routes) _PUBLIC_SYSTEM_CONFIG_KEYS = { item.value: item diff --git a/tests/test_router_aggregation.py b/tests/test_router_aggregation.py index 922a14661..5a160b9dd 100644 --- a/tests/test_router_aggregation.py +++ b/tests/test_router_aggregation.py @@ -162,6 +162,15 @@ def test_compatibility_api_router_keeps_public_contract(): assert expected_paths <= paths +def test_split_endpoint_routes_are_flattened_into_parent_routers(): + """拆分端点合并后父路由只应暴露可执行路由,避免测试和工具遇到包装节点。""" + from app.api.endpoints import plugin, subscribe, system + + for endpoint in (plugin, subscribe, system): + assert endpoint.router.routes + assert all(isinstance(route, APIRoute) for route in endpoint.router.routes) + + def test_init_routers_accepts_composition_root_api_prefix(): """路由初始化应使用组合根传入的 API 前缀。""" from app.startup.initializers.routers import init_routers