Skip to content

Commit 61d8a05

Browse files
committed
convert Item/User to ItemPublic/UserPublic
1 parent 0922a66 commit 61d8a05

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

backend/app/api/routes/items.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ def read_items(
4141
)
4242
items = session.exec(statement).all()
4343

44-
return ItemsPublic(data=items, count=count)
44+
items_public = [ItemPublic.model_validate(item) for item in items]
45+
return ItemsPublic(data=items_public, count=count)
4546

4647

4748
@router.get("/{id}", response_model=ItemPublic)

backend/app/api/routes/users.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ def read_users(session: SessionDep, skip: int = 0, limit: int = 100) -> Any:
4747
)
4848
users = session.exec(statement).all()
4949

50-
return UsersPublic(data=users, count=count)
50+
users_public = [UserPublic.model_validate(user) for user in users]
51+
return UsersPublic(data=users_public, count=count)
5152

5253

5354
@router.post(

0 commit comments

Comments
 (0)