Refactor TemplateField class in base.py
This commit is contained in:
parent
43fdc7bbba
commit
ee86334286
1 changed files with 10 additions and 2 deletions
|
|
@ -68,7 +68,9 @@ class TemplateField(BaseModel):
|
|||
refresh: Optional[bool] = None
|
||||
"""Specifies if the field should be refreshed. Defaults to False."""
|
||||
|
||||
range_spec: Optional[RangeSpec] = Field(default=None, serialization_alias="rangeSpec")
|
||||
range_spec: Optional[RangeSpec] = Field(
|
||||
default=None, serialization_alias="rangeSpec"
|
||||
)
|
||||
"""Range specification for the field. Defaults to None."""
|
||||
|
||||
title_case: bool = False
|
||||
|
|
@ -88,6 +90,8 @@ class TemplateField(BaseModel):
|
|||
result["input_types"].append("Text")
|
||||
if self.field_type == "Text":
|
||||
result["type"] = "str"
|
||||
else:
|
||||
result["type"] = self.field_type
|
||||
return result
|
||||
|
||||
@field_serializer("file_path")
|
||||
|
|
@ -117,6 +121,10 @@ class TemplateField(BaseModel):
|
|||
if not isinstance(value, list):
|
||||
raise ValueError("file_types must be a list")
|
||||
return [
|
||||
(f".{file_type}" if isinstance(file_type, str) and not file_type.startswith(".") else file_type)
|
||||
(
|
||||
f".{file_type}"
|
||||
if isinstance(file_type, str) and not file_type.startswith(".")
|
||||
else file_type
|
||||
)
|
||||
for file_type in value
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue