I must have done something wrong, imagine that.
First this appears to not work:
if TYPE_CHECKING: from sqlalchemy.ext.asyncio import AsyncSession
but this does
#if TYPE_CHECKING: from sqlalchemy.ext.asyncio import AsyncSession
This is probably related to the fact that when I run the code, I'm asked to supply a value for db_session in the OpenAPI interface.
Here is the code for that:
class ExerciseRepository(SQLAlchemyAsyncRepository[Exercise]):
"""Exercise repository."""
model_type = Exercise
async def provide_exercise_repo(db_session: AsyncSession) -> ExerciseRepository:
"""This provides a simple example demonstrating how to override the join options
for the repository."""
return ExerciseRepository(session=db_session)
class ExerciseController(Controller):
path = '/exercise'
dependencies = {
'exercise_repo': Provide(provide_exercise_repo),
}
exercise_controller_tag = ['Exercise - CRUD']
I did have this working with a different model in a different controller.
I think that this is pretty much the same as the code found here:
https://docs.litestar.dev/latest/tutorials/repository-tutorial/03-repository-controller.html
Any thoughts on what I screwed up?