Some extra sweets for marshmallow.
Use annotations for schema description.
from jam import Schema
class Bar (Schema ):
baz : str
class Foo (Schema ):
bar : Bar
foo : Foo = Foo ().load ({"bar" : {"baz" : "quux" }})
assert foo .bar .baz == "quux"
When annotations not enough
class Foo (Schema ):
bar : str = fields .Email ()
annotation
marshmallow field
str
fields.String
float
fields.Float
bool
fields.Boolean
int
fields.Integer
uuid.UUID
fields.UUID
decimal.Decimal
fields.Decimal
dt.datetime
fields.DateTime
dt.time
fields.Time
dt.date
fields.Date
dt.timedelta
fields.TimeDelta
All fields will be required for make it optional use
typing.Optional[X]
annotation
marshmallow field
list
fields.Raw(many=True)
typing.List[float]
fields.List(fields.Float())
annotation
marshmallow field
NestedSchema
fields.Nested(NestedSchema, required=True)
typing.Optional[NestedSchema]
fields.Nested(NestedSchema, required=True)
typing.List[NestedSchema]
fields.Nested(NestedSchema, required=True, many=True)