The Wire · Showcase
FASTAPI REWIRES ROUTER INTERNALS, UNBLOCKS MAJOR FEATURES
By RepoJournal · Filed · About FastAPI & Pydantic
FastAPI 0.137.0 shipped overnight with a breaking refactor that finally preserves APIRouter instances instead of cloning them on include_router calls.
This is the architectural fix the team has been chasing for years [1]. Before this release, every time you called `router.include_router(other_router)`, FastAPI would disassemble each path operation and rebuild it from scratch, collapsing your entire dependency graph into a single flat router [2]. That's gone now. The refactor preserves the original router and route instances through the include chain, which unblocks middleware at the router level, better performance on large apps with dozens of subrouters, and cleaner introspection tools. The breaking change here is real but surgical: if you're reaching into router internals to inspect or modify routes after include_router, your code will break. Most teams won't notice. But if you've built custom tooling around the old flat structure, audit your code before upgrading [3]. The release notes are still being finalized [4], so check the PR diffs for specifics before deploying to production.
One email a day. Unsubscribe in one click.
Keep up with FastAPI & Pydantic in about 3 minutes a day: what actually shipped — the commits, pull requests, releases, and security advisories that matter.
One email a day. Unsubscribe in one click. Read a past issue →
Action items
- → Review custom router inspection code for breaking changes before upgrading to 0.137.0 fastapi/fastapi [plan]
- → Stage 0.137.0 in dev environment if you use include_router with multiple levels of nesting fastapi/fastapi [plan]
- → Watch the release notes PR for final documentation on the refactor fastapi/fastapi [monitor]
References
- [1] 0.137.0 ↗ fastapi/fastapi
- [2] ♻️ Refactor internals to preserve `APIRouter` and `APIRoute` instances ↗ fastapi/fastapi
- [3] 🔖 Release version 0.137.0 ↗ fastapi/fastapi
- [4] 📝 Update release notes ↗ fastapi/fastapi