Skip to content

🔨 fix: detect routes defined on APIRouter instances and add tests fo…#87

Open
NureddinSoltan wants to merge 1 commit intofastapi:mainfrom
NureddinSoltan:fix/detect-apirouter-routes
Open

🔨 fix: detect routes defined on APIRouter instances and add tests fo…#87
NureddinSoltan wants to merge 1 commit intofastapi:mainfrom
NureddinSoltan:fix/detect-apirouter-routes

Conversation

@NureddinSoltan
Copy link

@NureddinSoltan NureddinSoltan commented Feb 27, 2026

Fixes #85

Problem

The workspace scanner (findAllFastAPIFiles in appDiscovery.ts) pre-filters files by checking for "FastAPI(" to avoid running tree-sitter on every Python file. This meant router-only files (using APIRouter() without a FastAPI() instance) were silently skipped, which is the standard pattern in larger FastAPI projects.

Fix

Extended the text pre-filter to also match "APIRouter(":

- if (new TextDecoder().decode(content).includes("FastAPI(")) {
+ const text = new TextDecoder().decode(content)
+ if (text.includes("FastAPI(") || text.includes("APIRouter(")) {

The core parsing pipeline already fully supports APIRouter , no other changes needed.

Testing

  • Added router-only fixture (standalone APIRouter(), no FastAPI())
  • Added test "builds graph from standalone APIRouter-only file" in routerResolver.test.ts
  • All 425 tests passing ✅

Before / After

A real FastAPI project - routers were invisible before, fully discovered after.

Before:

Untitled-2025-11-26-2202

After:

Untitled-2025-11-26-2202 (2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Registered routes are not picked up

1 participant