Description
The FastAPI extension fails to discover routes when app.include_router() is called with a router reference that is not a direct import name.
In the example only the route defined directly in main.py (GET /) is visible in the path explorer. All routes from the included router items are missing.
✅ Working example
❌ Using indirect router reference
Extension logs
2026-04-22 15:00:03.012 [info] Discovering FastAPI apps in 1 workspace folder(s)...
2026-04-22 15:00:03.041 [info] Found 1 candidate FastAPI file(s) in fastapi-extension
2026-04-22 15:00:03.044 [info] Analyzed "file://.../main.py": 1 routes, 1 routers, 1 include_router calls
2026-04-22 15:00:03.044 [info] Resolving include_router: router (prefix: {prefix})
2026-04-22 15:00:03.044 [info] No import found for router reference: router
2026-04-22 15:00:03.044 [info] Found 1 FastAPI app(s) with 1 route(s) in fastapi-extension
Repository link (if open source)
No response
Project structure
fastapi-extension/
├── items.py
└── main.py
FastAPI app and router setup
from fastapi import APIRouter, FastAPI
from items import router as items_router
app = FastAPI()
# Case 1 : Working
# app.include_router(items_router, prefix="/items", tags=["items"])
# Case 2 : Not working
routers: list[tuple[APIRouter, str, str]] = [
(items_router, "/items", "items"),
]
for router, prefix, tag in routers:
app.include_router(router, prefix=prefix, tags=[tag])
# Case 3 : Not working
# routers: list[tuple[APIRouter, str, str]] = [
# (items_router, "/items", "items"),
# ]
# app.include_router(routers[0][0], prefix=routers[0][1], tags=[routers[0][2]])
@app.get("/")
async def root():
return {"message": "Hello World"}
VS Code version
1.116.0
FastAPI extension version
0.2.0
Python version
3.11.11
FastAPI version
0.115.12
Operating system
macOS 26.3.1 (a) (25D771280a)
Description
The FastAPI extension fails to discover routes when
app.include_router()is called with a router reference that is not a direct import name.In the example only the route defined directly in main.py (
GET /) is visible in the path explorer. All routes from the included routeritemsare missing.✅ Working example
❌ Using indirect router reference
Extension logs
Repository link (if open source)
No response
Project structure
FastAPI app and router setup
VS Code version
1.116.0
FastAPI extension version
0.2.0
Python version
3.11.11
FastAPI version
0.115.12
Operating system
macOS 26.3.1 (a) (25D771280a)