Commit 0886b7fb authored by Jonas Braathen's avatar Jonas Braathen
Browse files

Set real default values. Simplifiy BaseModel.dict keyword defaults

parent 8599e72e
......@@ -16,17 +16,9 @@ class BaseModel(pydantic.BaseModel):
data = json.loads(json_data)
return cls.from_dict(data)
def _force_serialization_arguments(func):
def fun(self, *args, **kwargs):
kwargs['by_alias'] = True
kwargs['skip_defaults'] = True
return func(self, *args, **kwargs)
return fun
# TBD: Do we want to do the following for copy() and json()?
@_force_serialization_arguments
def dict(self, *args, **kwargs):
return super(BaseModel, self).dict(*args, **kwargs)
def dict(self, by_alias=True, skip_defaults=True, *args, **kwargs):
return super().dict(
by_alias=by_alias, skip_defaults=skip_defaults, *args, **kwargs)
class Identifier(BaseModel):
......@@ -76,13 +68,13 @@ class AddressTypeEnum(str, Enum):
class Address(BaseModel):
street: Optional[str]
number: Optional[str]
street: Optional[str] = ''
number: Optional[str] = ''
country: Optional[Reference]
city: Optional[str]
county: Optional[str]
postcode: Optional[str]
memo: Optional[str]
city: Optional[str] = ''
county: Optional[str] = ''
postcode: Optional[str] = ''
memo: Optional[str] = ''
type: Optional[AddressTypeEnum]
class Config:
......@@ -100,18 +92,18 @@ class BranchTypeEnum(str, Enum):
class Branch(BaseModel):
id: str = None
name: str = None
specification: str = None
client_reference_number: str = None
name: str = ''
specification: str = ''
client_reference_number: str = ''
timezone: str = None
extra_a: Optional[Reference]
extra_b: Optional[Reference]
phone: str = None
fax: str = None
phone: str = ''
fax: str = ''
address: Address = None
postal_address: Address = None
email: str = None
website: str = None
email: str = ''
website: str = ''
type: Optional[BranchTypeEnum]
head_branch: Optional[Identifier]
creator: Optional[Reference]
......@@ -141,7 +133,6 @@ class Branch(BaseModel):
return super().dict(*args, **kwargs)
class BranchReference(BaseModel):
id: str
name: str
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment