Skip to content

Commit 9ae0b1b

Browse files
Merge pull request #26 from mapswipe/fix/optional-list-and-mapping
fix: make list and mapping optional
2 parents 572fdbe + 4b5e430 commit 9ae0b1b

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

functions/definition/models.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,7 @@ FbMappingTaskValidateCreateOnlyInput:
475475
taskId:
476476
type: string
477477
geojson:
478+
# NOTE: This is not optional
478479
type:
479480
type: map
480481
valueType: any
@@ -532,6 +533,7 @@ FbMappingResult:
532533
startTime:
533534
type: timestamp
534535
results:
536+
optional: true
535537
type:
536538
# NOTE: The key is taskId
537539
type: map

functions/definition/tutorial/common.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ FbInformationPage:
3939
type:
4040
type: list
4141
elementType: FbInformationPageBlock
42+
optional: true
4243

4344
FbScreenBlock:
4445
model: alias
@@ -84,6 +85,7 @@ FbBaseTutorial:
8485
type:
8586
type: list
8687
elementType: FbInformationPage
88+
optional: true
8789
lookFor:
8890
type: string
8991
name:
@@ -108,6 +110,7 @@ FbBaseTutorial:
108110
type:
109111
type: list
110112
elementType: FbScreen
113+
optional: true
111114

112115
FbBaseTutorialGroup:
113116
model: alias

functions/generated/pyfirebase/pyfirebase_mapswipe/models.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ class FbMappingResult(TypesyncModel):
594594
clientType: str | TypesyncUndefined | None = UNDEFINED
595595
endTime: datetime.datetime
596596
startTime: datetime.datetime
597-
results: dict[str, int]
597+
results: dict[str, int] | TypesyncUndefined | None = UNDEFINED
598598
usergroups: dict[str, bool] | TypesyncUndefined | None = UNDEFINED
599599

600600
class Config:
@@ -605,6 +605,8 @@ class Config:
605605
def __setattr__(self, name: str, value: typing.Any) -> None:
606606
if name == "clientType" and value is None:
607607
raise ValueError("'clientType' field cannot be set to None")
608+
if name == "results" and value is None:
609+
raise ValueError("'results' field cannot be set to None")
608610
if name == "usergroups" and value is None:
609611
raise ValueError("'usergroups' field cannot be set to None")
610612
super().__setattr__(name, value)
@@ -675,14 +677,16 @@ def __setattr__(self, name: str, value: typing.Any) -> None:
675677
class FbInformationPage(TypesyncModel):
676678
pageNumber: int
677679
title: str
678-
blocks: list[FbInformationPageBlock]
680+
blocks: list[FbInformationPageBlock] | TypesyncUndefined | None = UNDEFINED
679681

680682
class Config:
681683
use_enum_values = False
682684
extra = "forbid"
683685

684686
@typing.override
685687
def __setattr__(self, name: str, value: typing.Any) -> None:
688+
if name == "blocks" and value is None:
689+
raise ValueError("'blocks' field cannot be set to None")
686690
super().__setattr__(name, value)
687691

688692

@@ -724,7 +728,7 @@ class FbBaseTutorial(TypesyncModel):
724728
pydantic.Field(deprecated=True),
725729
] = UNDEFINED
726730
contributorCount: int
727-
informationPages: list[FbInformationPage]
731+
informationPages: list[FbInformationPage] | TypesyncUndefined | None = UNDEFINED
728732
lookFor: str
729733
name: str
730734
progress: int
@@ -733,7 +737,7 @@ class FbBaseTutorial(TypesyncModel):
733737
projectTopicKey: typing.Annotated[str, pydantic.Field(deprecated=True)]
734738
status: typing.Literal["tutorial"]
735739
tutorialDraftId: typing.Annotated[str, pydantic.Field(deprecated=True)]
736-
screens: list[FbScreen]
740+
screens: list[FbScreen] | TypesyncUndefined | None = UNDEFINED
737741

738742
class Config:
739743
use_enum_values = False
@@ -745,6 +749,10 @@ def __setattr__(self, name: str, value: typing.Any) -> None:
745749
raise ValueError("'exampleImage1' field cannot be set to None")
746750
if name == "exampleImage2" and value is None:
747751
raise ValueError("'exampleImage2' field cannot be set to None")
752+
if name == "informationPages" and value is None:
753+
raise ValueError("'informationPages' field cannot be set to None")
754+
if name == "screens" and value is None:
755+
raise ValueError("'screens' field cannot be set to None")
748756
super().__setattr__(name, value)
749757

750758

0 commit comments

Comments
 (0)