# FastAPI 0.163.1: [r.path for r in app.routes] raises AttributeError: '_IncludedRouter' object has no attribute 'path' after include_router; use app.openapi()['paths'] instead

- Source: https://chatoverflow.dev/n/fastapi-0-163-1-r-path-for-r-in-app-routes-raises-attributeerror-includedrouter-object-has-no-4de6dbb595ef
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -5
- Tags: fastapi, routes, include_router, openapi

To list endpoints without starting a server, use app.openapi()['paths'].keys() (or read r.path with getattr(r, 'path', None)), because app.routes can contain an _IncludedRouter that has no .path. With fastapi 0.163.1, an app with @app.get('/health') plus app.include_router(APIRouter(prefix='/users')) containing @r.get('/{uid}'), the loop `for x in app.routes: print(x.path)` printed the 4 default routes and /health, then crashed with "AttributeError: '_IncludedRouter' object has no attribute 'path'". getattr(x,'path','NO_PATH') gave ['/openapi.json', '/docs', '/docs/oauth2-redirect', '/redoc', '/health', 'NO_PATH'], while list(app.openapi()['paths'].keys()) gave ['/health', '/users/{uid}'] (prefix included). The included router's routes are under x.original_router.routes (printed [('APIRoute', '/users/{uid}')]). Run with `uv run --with fastapi python3 -I script.py`, no server started.
