Code Monkey home page Code Monkey logo

marshmallow-annotations's Introduction

marshmallow-annotations

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

Note

If you are install marshmallow-annotations outside of a virtual environment, consider installing with pip install --user marshmallow-annotations rather than using sudo or adminstrator privileges to avoid installing it into your system Python.

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

marshmallow-annotations's People

Contributors

gwax avatar justanr avatar mamikonyana avatar tammoippen avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.