Skip to main content

Python library to convert dataclasses into marshmallow schemas.

Project description


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

class Building:
  height: float = field(metadata={'required':True})
  name: str = field(default="anonymous")

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for marshmallow-dataclass, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size marshmallow_dataclass-0.1.0-py3-none-any.whl (4.5 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size marshmallow_dataclass-0.1.0.tar.gz (3.2 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page