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
Close
Hashes for marshmallow_dataclass-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6809b1517d7250c4074e69888874cf50f101f494ffea692c65699e32144df5a |
|
MD5 | c3336e234037f8b4496016c98b958998 |
|
BLAKE2b-256 | 65933a43dc0f58a6e3fc85513c5726658d811d4be0cde54ff0b78a70ee9bea16 |
Close
Hashes for marshmallow_dataclass-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98ec417910e94277cdaee1c56437e02a9200004927b4b97c99d7c7ffca2f956e |
|
MD5 | 353736e173fe7206f281b59ae465c104 |
|
BLAKE2b-256 | a6d2d8fddd3bf85c0d5f949711a1b802447204cc4500e2b3903478a2917ecaea |