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()
scheme.dump(
    Artist(
        id=1, name="Abominable Putridity",
        albums=[
            Album(
                id=1,
                name="The Anomalies of Artificial Origin"
            )
        ]
    )
)

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

Installation

marshmallow-annotations is available on pypi and installable with:

pip install marshmallow-annotations

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

Why?

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 details)

Uploaded Source

Built Distribution

marshmallow_annotations-2.4.0-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file marshmallow-annotations-2.4.0.tar.gz.

File metadata

  • Download URL: marshmallow-annotations-2.4.0.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for marshmallow-annotations-2.4.0.tar.gz
Algorithm Hash digest
SHA256 ff9e67c3e68c3bf84c90b8fdc9c04f2ac7b5c5d36083526a31909de0b3a9689d
MD5 f8e63370a96de12f09d5d8f9b0e8bce1
BLAKE2b-256 00ee684b4dae99a42381debde54fd69b527754eef5579e2c8ec64e75e32aee4d

See more details on using hashes here.

File details

Details for the file marshmallow_annotations-2.4.0-py3-none-any.whl.

File metadata

  • Download URL: marshmallow_annotations-2.4.0-py3-none-any.whl
  • Upload date:
  • Size: 13.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for marshmallow_annotations-2.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 caa248df7652f9cfa69d5cc74439abc1835ccb8c78da25a6c11b8ae4098dcd85
MD5 a24afccb0cb2b5d9645b165d4dd00711
BLAKE2b-256 23652343d9996c6fe0e35509b09b5c0d54523ef4c8f079c524e299e34c15af38

See more details on using hashes here.

Supported by

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