Skip to content

Path Operation Explorer only shows routes from main.py, not routes added via include_router #133

@UmaiZ

Description

@UmaiZ

Description

Hi, I am using a basic FastAPI project structure like this:

project/
└── src/
    └── app/
        ├── main.py
        ├── api/
        │   └── example1.py
        ├── core/
        │   └── enums/
        │       └── example1.py
        ├── db/
        │   └── session.py
        ├── models/
        │   └── example1.py
        ├── schemas/
        │   └── example1.py
        ├── services/
        │   └── example1.py
        └── utils/
            ├── example1.py
            └── logs/
                └── logger.py

In main.py, I include all routers from the api package:


from fastapi import FastAPI
from app.db.session import engine, Base

from app.api import api_router
from contextlib import asynccontextmanager


@asynccontextmanager
async def lifespan(app: FastAPI):
    async with engine.begin() as conn:
        await conn.run_sync(Base.metadata.create_all)

    yield


app = FastAPI(lifespan=lifespan)


@app.get("/")
async def root():
    return {"message": "Server is up and running"}


app.include_router(api_router)

And in app/api/init.py, I register routers like this:

from fastapi import APIRouter
from app.api import auth, mood, habits, planner, quicknote, specialday, daily_affirmation, affirmation_category

api_router = APIRouter()

api_router.include_router(auth.router, prefix="/api/v1/auth", tags=["auth"])
api_router.include_router(mood.router, prefix="/api/v1/actions", tags=["actions"])
api_router.include_router(daily_affirmation.router, prefix="/api/v1/actions", tags=["actions"])
api_router.include_router(affirmation_category.router, prefix="/api/v1/actions", tags=["actions"])
api_router.include_router(habits.router, prefix="/api/v1/habits", tags=["habits"])
api_router.include_router(planner.router, prefix="/api/v1/planner", tags=["planner"])
api_router.include_router(quicknote.router, prefix="/api/v1/quick-note", tags=["quick-note"])
api_router.include_router(specialday.router, prefix="/api/v1/special-day", tags=["special-day"])

The issue is that in Path Operation Explorer, I only see the route defined directly in main.py:

@app.get("/")
The routes added through app.include_router(api_router) are not shown.

I am not sure whether this extension currently supports routes registered through include_router(), or if I am missing some configuration.

Is this expected behavior?

Image

Extension logs

routes, 1 routers, 1 include_router calls
2026-03-19 02:20:08.251 [info] Resolving include_router: api_router (prefix: none)
2026-03-19 02:20:08.251 [info] Could not resolve import: app.api
2026-03-19 02:20:08.251 [info] Found 1 FastAPI app(s) with 1 route(s) in yesdoer-backend

Repository link (if open source)

No response

Project structure

project/
└── src/
    └── app/
        ├── main.py
        ├── api/
        │   └── example1.py
        ├── core/
        │   └── enums/
        │       └── example1.py
        ├── db/
        │   └── session.py
        ├── models/
        │   └── example1.py
        ├── schemas/
        │   └── example1.py
        ├── services/
        │   └── example1.py
        └── utils/
            ├── example1.py
            └── logs/
                └── logger.py

FastAPI app and router setup

pyproject.toml [tool.fastapi] section (if present)

[project]
name = "yes-doer-backend"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.13"
dependencies = [
    "aiosmtplib>=5.0.0",
    "alembic>=1.17.1",
    "bcrypt==3.2.2",
    "black>=25.9.0",
    "fastapi>=0.121.0",
    "passlib[bcrypt]>=1.7.4",
    "psycopg[binary]>=3.2.12",
    "pydantic[email]>=2.12.4",
    "python-dotenv>=1.2.1",
    "python-jose>=3.5.0",
    "sqlalchemy[asyncio]>=2.0.44",
    "uvicorn[standard]>=0.38.0",
]

VS Code version

1.111.0

FastAPI extension version

0.1.5

Python version

3.14.2

FastAPI version

0.121.0

Operating system

Windows 11

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions