11from __future__ import annotations
22
33import datetime
4- from typing import List , Literal , Optional , Union
4+ from typing import Any , Dict , List , Literal , Optional , Union
55
66import pydantic
77
@@ -32,21 +32,23 @@ class BaseFieldDescriptor(pydantic.BaseModel):
3232 A description for this field e.g. “The recipient of the funds”
3333 """
3434
35- missingValues : Optional [List [str ]] = None
35+ missing_values : Optional [List [str ]] = pydantic .Field (
36+ default = None , alias = "missingValues"
37+ )
3638 """
3739 A list of field values to consider as null values
3840 """
3941
40- # @pydantic.model_validator(mode="before")
41- # @classmethod
42- # def compat(cls, data: Dict[str, Any]) -> Dict[str, Any]:
43- # # field.format
44- # format = data.get("format")
45- # if format :
46- # if format .startswith("fmt:"):
47- # data["format"] = format [4:]
42+ @pydantic .model_validator (mode = "before" )
43+ @classmethod
44+ def compat (cls , data : Dict [str , Any ]) -> Dict [str , Any ]:
45+ # field.format
46+ format_ = data .get ("format" )
47+ if format_ :
48+ if format_ .startswith ("fmt:" ):
49+ data ["format" ] = format_ [4 :]
4850
49- # return data
51+ return data
5052
5153
5254class BooleanFieldDescriptor (BaseFieldDescriptor ):
@@ -57,12 +59,11 @@ class BooleanFieldDescriptor(BaseFieldDescriptor):
5759 format : Optional [Literal ["default" ]] = None
5860 constraints : Optional [BaseConstraints [bool ]] = None
5961
60- trueValues : Optional [List [str ]] = None
61- """
62- Values to be interpreted as “true” for boolean fields
62+ true_values : Optional [List [str ]] = pydantic .Field (default = None , alias = "trueValues" )
6363 """
64+ Values to be interpreted as “true” for boolean fields """
6465
65- falseValues : Optional [List [str ]] = None
66+ false_values : Optional [List [str ]] = pydantic . Field ( default = None , alias = "falseValues" )
6667 """
6768 Values to be interpreted as “false” for boolean fields
6869 """
@@ -76,7 +77,9 @@ class ArrayFieldDescriptor(BaseFieldDescriptor):
7677 constraints : Optional [JSONConstraints ] = None
7778
7879 # TODO type is not accurate : array item are unnamed, not described etc
79- arrayItem : Optional [FieldDescriptor ] = None
80+ array_item : Optional [FieldDescriptor ] = pydantic .Field (
81+ default = None , alias = "arrayItem"
82+ )
8083
8184
8285class AnyFieldDescriptor (BaseFieldDescriptor ):
@@ -156,18 +159,20 @@ class IntegerFieldDescriptor(BaseFieldDescriptor):
156159 Property to restrict the field to a finite set of possible values
157160 """
158161
159- categoriesOrdered : bool = False
162+ categories_ordered : Optional [bool ] = pydantic .Field (
163+ default = None , alias = "categoriesOrdered"
164+ )
160165 """
161166 When categoriesOrdered is true, implementations SHOULD regard the order of
162167 appearance of the values in the categories property as their natural order.
163168 """
164169
165- groupChar : Optional [str ] = None
170+ group_char : Optional [str ] = pydantic . Field ( default = None , alias = "groupChar" )
166171 """
167172 String whose value is used to group digits for integer/number fields
168173 """
169174
170- bareNumber : bool = True
175+ bare_number : Optional [ bool ] = pydantic . Field ( default = None , alias = "bareNumber" )
171176 """
172177 If false leading and trailing non numbers will be removed for integer/number fields
173178 """
@@ -200,7 +205,7 @@ class ListFieldDescriptor(BaseFieldDescriptor):
200205 Specifies the character sequence which separates lexically represented list items.
201206 """
202207
203- itemType : Optional [IItemType ] = None
208+ item_type : Optional [IItemType ] = pydantic . Field ( default = None , alias = "itemType" )
204209 """
205210 Specifies the list item type in terms of existent Table Schema types.
206211 """
@@ -213,17 +218,17 @@ class NumberFieldDescriptor(BaseFieldDescriptor):
213218 format : Optional [Literal ["default" ]] = None
214219 constraints : Optional [ValueConstraints [float ]] = None
215220
216- decimalChar : Optional [str ] = None
221+ decimal_char : Optional [str ] = pydantic . Field ( default = None , alias = "decimalChar" )
217222 """
218223 String whose value is used to represent a decimal point for number fields
219224 """
220225
221- groupChar : Optional [str ] = None
226+ group_char : Optional [str ] = pydantic . Field ( default = None , alias = "groupChar" )
222227 """
223228 String whose value is used to group digits for integer/number fields
224229 """
225230
226- bareNumber : Optional [bool ] = None
231+ bare_number : Optional [bool ] = pydantic . Field ( default = None , alias = "bareNumber" )
227232 """
228233 If false leading and trailing non numbers will be removed for integer/number fields
229234 """
@@ -260,7 +265,7 @@ class StringFieldDescriptor(BaseFieldDescriptor):
260265 Property to restrict the field to a finite set of possible values
261266 """
262267
263- categoriesOrdered : bool = False
268+ categoriesOrdered : Optional [ bool ] = None
264269 """
265270 When categoriesOrdered is true, implementations SHOULD regard the order of
266271 appearance of the values in the categories property as their natural order.
0 commit comments