Skip to content

Commit

Permalink
feat: upgrade to use marshmallow 3.0.0rc9
Browse files Browse the repository at this point in the history
marshmallow 3.0.0 use strict: True by default for schem

also patch EnumField, revert it once justanr/marshmallow_enum#23 is resolved
  • Loading branch information
e-cloud committed Aug 12, 2019
1 parent 09f16f9 commit 972d6d4
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 10 deletions.
7 changes: 7 additions & 0 deletions app/models/enum_field.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from marshmallow_enum import EnumField as BaseEnumField


# todo: revert it once https://github.com/justanr/marshmallow_enum/issues/23 is resolved
class EnumField(BaseEnumField):
def _deserialize(self, value, attr, data, **kwargs):
super(EnumField, self)._deserialize(value, attr, data)
2 changes: 1 addition & 1 deletion app/resources/auth/schemas.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from flask_marshmallow import Schema
from marshmallow import fields
from marshmallow_enum import EnumField

from .models import EnumGender
from app.models.enum_field import EnumField


class CreateAuthClientParameters(Schema):
Expand Down
8 changes: 3 additions & 5 deletions app/resources/complaints/schemas.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from flask_marshmallow.sqla import TableSchema
from marshmallow import fields
from marshmallow import Schema
from marshmallow_enum import EnumField

from .models import Complaint
from .models import EnumComplaintState
from .models import EnumComplaintType
from app.models.enum_field import EnumField
from app.resources.users.schemas import UserSchema


Expand All @@ -31,11 +31,9 @@ class ComplaintSchema(Schema):
trade_info = fields.String(description='tradeInfo')
relatedProducts = fields.String(description='relatedProducts')
purchase_timestamp = fields.DateTime(description='purchase_timestamp')
invoice_files = fields.List(
fields.String(), description='uploaded invoice file list'
)
invoice_files = fields.List(fields.URL(), description='uploaded invoice file list')
evidence_files = fields.List(
fields.String(), description='uploaded evidence file list'
fields.URL(), description='uploaded evidence file list'
)


Expand Down
4 changes: 1 addition & 3 deletions app/resources/uploads/schemas.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from flask_marshmallow import Schema
from marshmallow import ValidationError
from marshmallow_enum import EnumField

from .models import EnumUploadFileType
from .models import FileField
from app.models.enum_field import EnumField


def file_validate(file):
Expand All @@ -12,8 +12,6 @@ def file_validate(file):


class FileUploadFormParameters(Schema):
class Meta:
strict = True

upload_type = EnumField(
EnumUploadFileType,
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jsonschema==3.0.2
lazy-object-proxy==1.4.1
Mako==1.1.0
MarkupSafe==1.1.1
marshmallow==2.19.5
marshmallow==3.0.0rc9
marshmallow-enum==1.4.1
marshmallow-jsonschema==0.6.0
marshmallow-sqlalchemy==0.17.0
Expand Down
1 change: 1 addition & 0 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ flask-migrate~=2.5.0
flask-rest-api~=0.16.1
flask-sqlalchemy~=2.4.0
flask~=1.1.0
marshmallow==3.0.0rc9
marshmallow-enum~=1.4.1
marshmallow-jsonschema~=0.6.0
marshmallow-sqlalchemy~=0.17.0
Expand Down

0 comments on commit 972d6d4

Please sign in to comment.