This release is a pre-release and may not be stable for production use.
Some extra sweets for marshmallow.
Examples
Use annotations for schema description.
class Response(Schema):
a: float
b: Optional[dt.datetime]
When annotations not enough
class Response(Schema):
c: str = fields.Email()
And IDE autocomplete cause now your data is instances of relevant classes
class User(Schema):
name: str
class Response(Schema):
user: User
response: Response = Response.load({"user": {"name": "Vasya Pupkin"}})
response.user.name
Mapping rules
Basic Types
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]
Many
annotation |
marshmallow field |
|---|---|
list |
fields.Raw(many=True) |
typing.List[float] |
fields.List(fields.Float()) |
Nested
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) |
Release files for marshmallow-jam 0.1.1.dev48249440
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| marshmallow-jam-0.1.1.dev48249440.tar.gz | 5.1 kB | Details |
Release files / marshmallow-jam-0.1.1.dev48249440.tar.gz
| Download URL | marshmallow-jam-0.1.1.dev48249440.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
389c205815a2e7912c0915ba9f4e660eaf36e06d6192263d37cad5197992ce67
|
|
BLAKE2b-256 checksum How to use checksums |
07dc7bcf619b507f104899dfdff5239bf810f8abbfff7ff78b8f03d361e364e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
|