📝 Add hints for model-to-schema conversion

This commit is contained in:
Brian Wiborg 2025-09-27 05:33:05 +02:00
parent 67d4264f0d
commit cb5bfdebe1
No known key found for this signature in database

View file

@ -2,8 +2,9 @@
> OhMyAPI == Application scaffolding for FastAPI+TortoiseORM. > OhMyAPI == Application scaffolding for FastAPI+TortoiseORM.
OhMyAPI is a blazingly fast, async Python web application framework with batteries included. OhMyAPI is a Django-flavored web-application scaffolding framework.
It is built around FastAPI and TortoiseORM and is thus 100% async. It is blazingly fast, async and has batteries included.
Built around FastAPI and TortoiseORM makes it 100% async.
Features: Features:
@ -23,7 +24,7 @@ Features:
**Creating a Project** **Creating a Project**
``` ```
pip install ohmyapi # TODO: not yet published pip install ohmyapi
ohmyapi startproject myproject ohmyapi startproject myproject
cd myproject cd myproject
``` ```
@ -93,13 +94,13 @@ router = APIRouter(prefix="/myapp")
@router.get("/") @router.get("/")
async def list(): async def list():
return await Person.all() return await Person.Schema.many.from_queryset(Person.all())
@router.get("/:id") @router.get("/:id")
async def get(id: int): async def get(id: int):
try: try:
await Person.get(pk=id) return await Person.Schema.one(Person.get(pk=id))
except DoesNotExist: except DoesNotExist:
raise HTTPException(status_code=404, detail="item not found") raise HTTPException(status_code=404, detail="item not found")