From f35b4b94e5a75bbc8cc41749ca2e3800bbc7a44e Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Thu, 13 Jun 2024 13:50:38 -0400 Subject: [PATCH] Make more fields truely optional (behavior change in pydantic v2). --- etebase_server/fastapi/routers/collection.py | 14 +++++++------- etebase_server/fastapi/routers/invitation.py | 2 +- etebase_server/fastapi/routers/member.py | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/etebase_server/fastapi/routers/collection.py b/etebase_server/fastapi/routers/collection.py index 2de35a8..e5990b6 100644 --- a/etebase_server/fastapi/routers/collection.py +++ b/etebase_server/fastapi/routers/collection.py @@ -72,7 +72,7 @@ class CollectionItemRevisionInOut(BaseModel): class CollectionItemCommon(BaseModel): uid: str version: int - encryptionKey: t.Optional[bytes] + encryptionKey: t.Optional[bytes] = None content: CollectionItemRevisionInOut @@ -93,12 +93,12 @@ class CollectionItemOut(CollectionItemCommon): class CollectionItemIn(CollectionItemCommon): - etag: t.Optional[str] + etag: t.Optional[str] = None class CollectionCommon(BaseModel): # FIXME: remove optional once we finish collection-type-migration - collectionType: t.Optional[bytes] + collectionType: t.Optional[bytes] = None collectionKey: bytes @@ -132,7 +132,7 @@ class RemovedMembershipOut(BaseModel): class CollectionListResponse(BaseModel): data: t.List[CollectionOut] - stoken: t.Optional[str] + stoken: t.Optional[str] = None done: bool removedMemberships: t.Optional[t.List[RemovedMembershipOut]] = None @@ -140,13 +140,13 @@ class CollectionListResponse(BaseModel): class CollectionItemListResponse(BaseModel): data: t.List[CollectionItemOut] - stoken: t.Optional[str] + stoken: t.Optional[str] = None done: bool class CollectionItemRevisionListResponse(BaseModel): data: t.List[CollectionItemRevisionInOut] - iterator: t.Optional[str] + iterator: t.Optional[str] = None done: bool @@ -173,7 +173,7 @@ class ItemDepIn(BaseModel): class ItemBatchIn(BaseModel): items: t.List[CollectionItemIn] - deps: t.Optional[t.List[ItemDepIn]] + deps: t.Optional[t.List[ItemDepIn]] = None def validate_db(self): if self.deps is not None: diff --git a/etebase_server/fastapi/routers/invitation.py b/etebase_server/fastapi/routers/invitation.py index 43a182f..a2f5371 100644 --- a/etebase_server/fastapi/routers/invitation.py +++ b/etebase_server/fastapi/routers/invitation.py @@ -85,7 +85,7 @@ class CollectionInvitationOut(CollectionInvitationCommon): class InvitationListResponse(BaseModel): data: t.List[CollectionInvitationOut] - iterator: t.Optional[str] + iterator: t.Optional[str] = None done: bool diff --git a/etebase_server/fastapi/routers/member.py b/etebase_server/fastapi/routers/member.py index 71da4c7..50d0025 100644 --- a/etebase_server/fastapi/routers/member.py +++ b/etebase_server/fastapi/routers/member.py @@ -48,7 +48,7 @@ class CollectionMemberOut(BaseModel): class MemberListResponse(BaseModel): data: t.List[CollectionMemberOut] - iterator: t.Optional[str] + iterator: t.Optional[str] = None done: bool