Skip to content

Library to generate marshmallow schema from attrs class.

Notifications You must be signed in to change notification settings

KoHcoJlb/attrs-marshmallow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

attrs-marshmallow

attrs-marshmallow is a Python library that generates marshmallow schema for attrs decorated classes.

Example

from attrs_marshmallow import add_schema, marshmallow_opts


@add_schema
class Example:
    hello: str = marshmallow_opts()
    world: int


if __name__ == "__main__":
    e = Example(hello="value", world=3)
    data = e.Schema().dump(e)
    print(data)

Usage remarks

To alter marshmallow field creation you can use marshmallow_opts function.

If you need further customization you can pass custom attr-to-field to add_schema/attrs_schema or register it globally using register_field_hook.

About

Library to generate marshmallow schema from attrs class.

Topics

Resources

Stars

Watchers

Forks

Languages