Python library to convert dataclasses into marshmallow schemas.
Project description
marshmallow_dataclass
Automatic generation of marshmallow schemas from dataclasses.
How to use
from dataclasses import field
from marshmallow_dataclass import dataclass # Importing from marshmallow_dataclass instead of dataclasses
from typing import List
@dataclass
class Building:
height: float = field(metadata={'required':True})
name: str = field(default="anonymous")
@dataclass
class City:
name: str
buildings: List[Building] = field(default_factory=lambda: [])
# City.Schema contains a marshmallow schema class
city, _ = City.Schema().load({
"name": "Paris",
"buildings": [
{"name": "Eiffel Tower", "height":324}
]
})
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file marshmallow_dataclass-0.1.0.tar.gz
.
File metadata
- Download URL: marshmallow_dataclass-0.1.0.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.20.1 setuptools/40.7.3 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6809b1517d7250c4074e69888874cf50f101f494ffea692c65699e32144df5a |
|
MD5 | c3336e234037f8b4496016c98b958998 |
|
BLAKE2b-256 | 65933a43dc0f58a6e3fc85513c5726658d811d4be0cde54ff0b78a70ee9bea16 |
File details
Details for the file marshmallow_dataclass-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: marshmallow_dataclass-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.20.1 setuptools/40.7.3 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98ec417910e94277cdaee1c56437e02a9200004927b4b97c99d7c7ffca2f956e |
|
MD5 | 353736e173fe7206f281b59ae465c104 |
|
BLAKE2b-256 | a6d2d8fddd3bf85c0d5f949711a1b802447204cc4500e2b3903478a2917ecaea |