Skip to content

✨ Add endpoint discovery service for Endpoint Explorer#2

Merged
savannahostrowski merged 37 commits intomainfrom
endpoint-discovery
Jan 14, 2026
Merged

✨ Add endpoint discovery service for Endpoint Explorer#2
savannahostrowski merged 37 commits intomainfrom
endpoint-discovery

Conversation

@savannahostrowski
Copy link
Member

@savannahostrowski savannahostrowski commented Jan 12, 2026

Closes https://github.com/fastapilabs/cloud/issues/2418 and https://github.com/fastapilabs/cloud/issues/2452

Apologies for the fairly large PR - it's a fairly large component (it's basically the guts of the extension) and I wanted the end result to be something we could play with as a team. The PR is really about ~1700 lines of implementation and then a whole lot of tests/fixtures.

This PR:

  • Adds a new endpoint discovery service that parses the program's AST to extract FastAPI routes, routers, etc. and resolves imports to follow router chains across files
  • Updates the tree view to group routers by declared prefixes, creates synthetic groups when multiple routes share the same prefix segment, creates display labels (prefix, tag, file in that priority order), and shows the number of routes per router

Key files to review
Please prioritize 🙏:

  • src/core/routerResolver.ts - Main entry point, builds the router graph by following imports
  • src/core/importResolver.ts - Resolves Python imports (relative, absolute, re-exports). This is also probably the most complicated piece IMO.
  • src/core/transformer.ts - Converts router graph to tree view structure
  • src/core/extractors/ - Individual extractors for decorators, routers, imports, etc.

At this point, users can:

  • Expand/collapse all routes to see/hide routes in the app
  • Right-click to copy full path/prefix
  • Click a route to navigate to it
  • Click refresh to re-scan the workspace (file watching is up next!)
  • Exposes a setting to allow a user to specify an app entry point outside of what's currently supported - see defaultPatterns in extension.ts

Other considerations

  • I considered using ast-grep for this but this would mean that we couldn't distribute a single VSIX anymore since it imports a native module (~7MB per platform vs ~350KB WASM that works everywhere).
  • I want to add proper logging in a separate PR via https://github.com/fastapilabs/cloud/issues/2527

Review order:

@savannahostrowski savannahostrowski changed the title Endpoint Discovery + View Updates ✨ Endpoint Discovery + View Updates Jan 12, 2026
@savannahostrowski savannahostrowski changed the title ✨ Endpoint Discovery + View Updates ✨ Add endpoint discovery service for Endpoint Explorer Jan 13, 2026
@savannahostrowski savannahostrowski requested review from buurro and patrick91 and removed request for buurro and patrick91 January 14, 2026 18:04
@savannahostrowski
Copy link
Member Author

savannahostrowski commented Jan 14, 2026

Copy link
Member

@buurro buurro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally and works great!

Found a bug, but it will be handled on a separate PR

/**
* Finds the main FastAPI app or APIRouter in the list of routers.
*/
function findAppRouter(routers: RouterInfo[]): RouterInfo | undefined {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is the problematic bit for #7

@savannahostrowski savannahostrowski merged commit 3827e3f into main Jan 14, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants