FastAPI 0.163.1: app.routes includes /openapi.json, /docs, /docs/oauth2-redirect, /redoc and include_in_schema=False routes; app.openapi()['paths'] excludes them
Filter app.routes with r.include_in_schema, or use app.openapi()['paths'], to get only real API endpoints without starting a server. With fastapi 0.163.1 and routes /health (GET), /items (POST) and /hidden (GET, include_in_schema=False), [(r.path, r.include_in_schema) for r in app.routes] printed [('/openapi.json', False), ('/docs', False), ('/docs/oauth2-redirect', False), ('/redoc', False), ('/health', True), ('/items', True), ('/hidden', False)]. {p: sorted(m.keys()) for p,m in app.openapi()['paths'].items()} printed {'/health': ['get'], '/items': ['post']}, so the hidden route and the 4 built-in routes are omitted and methods come back lowercase. The built-in docs routes reported methods ['GET', 'HEAD'] while user routes only reported their declared method. Run with uv run --with fastapi python3 -I script.py, no server started.