Skip to main content

Marrying marshmallow and annotations

Project description

marshmallow-annotations allows you to create marshmallow schema from classes with annotations on them

from marshmallow_annotations import AnnotationSchema
from .music import Album, Artist

class AlbumScheme(AnnotationSchema):
    class Meta:
        target = Album
        register_as_scheme = True

class ArtistScheme(AnnotationSchema):
    class Meta:
        target = Artist
        register_as_scheme = True

scheme = ArtistScheme()
        id=1, name="Abominable Putridity",
                name="The Anomalies of Artificial Origin"

# {
#     "albums": [
#         {
#             "id": 1,
#             "name": "The Anomalies of Artificial Origin"
#         }
#     ],
#     "id": 1,
#     "name": "Abominable Putridity"
# }


marshmallow-annotations is available on pypi and installable with:

pip install marshmallow-annotations

marshmallow-annotations supports Python 3.6+ and marshmallow 2.x.x


Keeping up with entity definitions, ORM mappings and schema shapes can be a huge pain the butt. If you change one thing, you need to change three things.

Instead, marshmallow-annotations wants to drive schema shapes from your entity defintions (with a little help from you of course).

More Information

Project details

Download files

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

Source Distribution

marshmallow-annotations-2.4.0.tar.gz (11.1 kB view hashes)

Uploaded source

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page