From 06533e390c4f338bb08e6d7e209faef7e9117110 Mon Sep 17 00:00:00 2001 From: cultron Date: Wed, 28 Oct 2026 22:12:30 -0500 Subject: [PATCH] fix: serve generated routes and install greenlet for async SQLAlchemy main.py never included app.autogen's autogen_router, so a generated Python service served no entity routes. The template's app/autogen/__init__.py now defines an empty router so the import works before the first apso generate. SQLAlchemy 2.1 no longer installs greenlet, which the asyncio extension needs, so the app failed to import. Depend on sqlalchemy[asyncio]. --- app/autogen/__init__.py | 6 ++++++ app/main.py | 10 +++++----- pyproject.toml | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/autogen/__init__.py b/app/autogen/__init__.py index 8269fd8..e75382a 100644 --- a/app/autogen/__init__.py +++ b/app/autogen/__init__.py @@ -1,2 +1,8 @@ # Code generated by APSO CLI. DO NOT EDIT. # This file is auto-generated - any changes will be overwritten. +from fastapi import APIRouter + +# `apso generate` replaces this with a router that includes every entity. +autogen_router = APIRouter(prefix="/api") + +__all__ = ["autogen_router"] diff --git a/app/main.py b/app/main.py index f22b83b..8d2aa9b 100644 --- a/app/main.py +++ b/app/main.py @@ -52,11 +52,11 @@ async def api_root(): return {"message": "APSO API", "version": "1.0.0"} -# Import and include autogen routers -# Entity routers will be registered here by the APSO CLI -# Example: -# from app.autogen.routers import organization, user -# app.include_router(organization.router, prefix="/api/organizations", tags=["Organizations"]) +# Routes generated from .apsorc (`apso generate` writes app/autogen). +# Include your own routers before this one to override a generated route. +from app.autogen import autogen_router # noqa: E402 + +app.include_router(autogen_router) if __name__ == "__main__": diff --git a/pyproject.toml b/pyproject.toml index 4f43b80..2991092 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,7 +15,7 @@ authors = [ dependencies = [ "fastapi>=0.109.0", "uvicorn[standard]>=0.27.0", - "sqlalchemy>=2.0.25", + "sqlalchemy[asyncio]>=2.0.25", "asyncpg>=0.29.0", "alembic>=1.13.1", "pydantic>=2.5.3",