diff --git a/marshmallow_mongoengine/conversion/fields.py b/marshmallow_mongoengine/conversion/fields.py index 848931f..21e7a22 100644 --- a/marshmallow_mongoengine/conversion/fields.py +++ b/marshmallow_mongoengine/conversion/fields.py @@ -62,6 +62,16 @@ def _get_marshmallow_field_cls(self): ) +class EnumBuilder(MetaFieldBuilder): + AVAILABLE_PARAMS = () + MARSHMALLOW_FIELD_CLS = ma_fields.Enum + + def _get_marshmallow_field_cls(self): + return functools.partial( + self.MARSHMALLOW_FIELD_CLS, self.mongoengine_field._enum_cls + ) + + class ReferenceBuilder(MetaFieldBuilder): AVAILABLE_PARAMS = () MARSHMALLOW_FIELD_CLS = ma_fields.Reference @@ -212,6 +222,7 @@ class Builder(MetaFieldBuilder): register_field( me.fields.URLField, ma_fields.URL, available_params=(params.LengthParam,) ) +register_field_builder(me.fields.EnumField, EnumBuilder) register_field_builder(me.fields.EmbeddedDocumentField, EmbeddedDocumentBuilder) register_field_builder(me.fields.ListField, ListBuilder) register_field_builder(me.fields.MapField, MapBuilder)