mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-17 10:42:25 -05:00
Remove strict = True from Marshmallow schemas
Since Marshmallow 3, schemas are now strict by default, and the strict parameter has been removed. There were some schemas where we had not specified `strict = True`, but we weren't relying on strict being False, so this does not cause any issues. https://marshmallow.readthedocs.io/en/stable/upgrading.html#schemas-are-always-strict
This commit is contained in:
@@ -107,7 +107,6 @@ class UserSchema(BaseSchema):
|
|||||||
"updated_at",
|
"updated_at",
|
||||||
"verify_codes",
|
"verify_codes",
|
||||||
)
|
)
|
||||||
strict = True
|
|
||||||
|
|
||||||
@validates('name')
|
@validates('name')
|
||||||
def validate_name(self, value):
|
def validate_name(self, value):
|
||||||
@@ -147,7 +146,6 @@ class UserUpdateAttributeSchema(BaseSchema):
|
|||||||
'updated_at',
|
'updated_at',
|
||||||
'verify_codes',
|
'verify_codes',
|
||||||
)
|
)
|
||||||
strict = True
|
|
||||||
|
|
||||||
@validates('name')
|
@validates('name')
|
||||||
def validate_name(self, value):
|
def validate_name(self, value):
|
||||||
@@ -180,7 +178,6 @@ class UserUpdatePasswordSchema(BaseSchema):
|
|||||||
|
|
||||||
class Meta(BaseSchema.Meta):
|
class Meta(BaseSchema.Meta):
|
||||||
model = models.User
|
model = models.User
|
||||||
strict = True
|
|
||||||
|
|
||||||
@validates_schema(pass_original=True)
|
@validates_schema(pass_original=True)
|
||||||
def check_unknown_fields(self, data, original_data):
|
def check_unknown_fields(self, data, original_data):
|
||||||
@@ -194,7 +191,6 @@ class ProviderDetailsSchema(BaseSchema):
|
|||||||
|
|
||||||
class Meta(BaseSchema.Meta):
|
class Meta(BaseSchema.Meta):
|
||||||
model = models.ProviderDetails
|
model = models.ProviderDetails
|
||||||
strict = True
|
|
||||||
|
|
||||||
|
|
||||||
class ProviderDetailsHistorySchema(BaseSchema):
|
class ProviderDetailsHistorySchema(BaseSchema):
|
||||||
@@ -202,7 +198,6 @@ class ProviderDetailsHistorySchema(BaseSchema):
|
|||||||
|
|
||||||
class Meta(BaseSchema.Meta):
|
class Meta(BaseSchema.Meta):
|
||||||
model = models.ProviderDetailsHistory
|
model = models.ProviderDetailsHistory
|
||||||
strict = True
|
|
||||||
|
|
||||||
|
|
||||||
class ServiceSchema(BaseSchema, UUIDsAsStringsMixin):
|
class ServiceSchema(BaseSchema, UUIDsAsStringsMixin):
|
||||||
@@ -261,7 +256,6 @@ class ServiceSchema(BaseSchema, UUIDsAsStringsMixin):
|
|||||||
'users',
|
'users',
|
||||||
'version',
|
'version',
|
||||||
)
|
)
|
||||||
strict = True
|
|
||||||
|
|
||||||
@validates('permissions')
|
@validates('permissions')
|
||||||
def validate_permissions(self, value):
|
def validate_permissions(self, value):
|
||||||
@@ -322,7 +316,6 @@ class DetailedServiceSchema(BaseSchema):
|
|||||||
class NotificationModelSchema(BaseSchema):
|
class NotificationModelSchema(BaseSchema):
|
||||||
class Meta(BaseSchema.Meta):
|
class Meta(BaseSchema.Meta):
|
||||||
model = models.Notification
|
model = models.Notification
|
||||||
strict = True
|
|
||||||
exclude = ('_personalisation', 'job', 'service', 'template', 'api_key',)
|
exclude = ('_personalisation', 'job', 'service', 'template', 'api_key',)
|
||||||
|
|
||||||
status = fields.String(required=False)
|
status = fields.String(required=False)
|
||||||
@@ -341,7 +334,6 @@ class BaseTemplateSchema(BaseSchema):
|
|||||||
class Meta(BaseSchema.Meta):
|
class Meta(BaseSchema.Meta):
|
||||||
model = models.Template
|
model = models.Template
|
||||||
exclude = ("service_id", "jobs", "service_letter_contact_id")
|
exclude = ("service_id", "jobs", "service_letter_contact_id")
|
||||||
strict = True
|
|
||||||
|
|
||||||
|
|
||||||
class TemplateSchema(BaseTemplateSchema, UUIDsAsStringsMixin):
|
class TemplateSchema(BaseTemplateSchema, UUIDsAsStringsMixin):
|
||||||
@@ -417,7 +409,6 @@ class ApiKeySchema(BaseSchema):
|
|||||||
class Meta(BaseSchema.Meta):
|
class Meta(BaseSchema.Meta):
|
||||||
model = models.ApiKey
|
model = models.ApiKey
|
||||||
exclude = ("service", "_secret")
|
exclude = ("service", "_secret")
|
||||||
strict = True
|
|
||||||
|
|
||||||
|
|
||||||
class JobSchema(BaseSchema):
|
class JobSchema(BaseSchema):
|
||||||
@@ -454,14 +445,9 @@ class JobSchema(BaseSchema):
|
|||||||
'notifications_failed',
|
'notifications_failed',
|
||||||
'notifications_sent',
|
'notifications_sent',
|
||||||
)
|
)
|
||||||
strict = True
|
|
||||||
|
|
||||||
|
|
||||||
class NotificationSchema(ma.Schema):
|
class NotificationSchema(ma.Schema):
|
||||||
|
|
||||||
class Meta:
|
|
||||||
strict = True
|
|
||||||
|
|
||||||
status = fields.String(required=False)
|
status = fields.String(required=False)
|
||||||
personalisation = fields.Dict(required=False)
|
personalisation = fields.Dict(required=False)
|
||||||
|
|
||||||
@@ -502,7 +488,6 @@ class SmsTemplateNotificationSchema(SmsNotificationSchema):
|
|||||||
class NotificationWithTemplateSchema(BaseSchema):
|
class NotificationWithTemplateSchema(BaseSchema):
|
||||||
class Meta(BaseSchema.Meta):
|
class Meta(BaseSchema.Meta):
|
||||||
model = models.Notification
|
model = models.Notification
|
||||||
strict = True
|
|
||||||
exclude = ('_personalisation',)
|
exclude = ('_personalisation',)
|
||||||
|
|
||||||
template = fields.Nested(
|
template = fields.Nested(
|
||||||
@@ -597,7 +582,6 @@ class InvitedUserSchema(BaseSchema):
|
|||||||
|
|
||||||
class Meta(BaseSchema.Meta):
|
class Meta(BaseSchema.Meta):
|
||||||
model = models.InvitedUser
|
model = models.InvitedUser
|
||||||
strict = True
|
|
||||||
|
|
||||||
@validates('email_address')
|
@validates('email_address')
|
||||||
def validate_to(self, value):
|
def validate_to(self, value):
|
||||||
@@ -608,10 +592,6 @@ class InvitedUserSchema(BaseSchema):
|
|||||||
|
|
||||||
|
|
||||||
class EmailDataSchema(ma.Schema):
|
class EmailDataSchema(ma.Schema):
|
||||||
|
|
||||||
class Meta:
|
|
||||||
strict = True
|
|
||||||
|
|
||||||
email = fields.Str(required=True)
|
email = fields.Str(required=True)
|
||||||
|
|
||||||
def __init__(self, partial_email=False):
|
def __init__(self, partial_email=False):
|
||||||
@@ -629,10 +609,6 @@ class EmailDataSchema(ma.Schema):
|
|||||||
|
|
||||||
|
|
||||||
class NotificationsFilterSchema(ma.Schema):
|
class NotificationsFilterSchema(ma.Schema):
|
||||||
|
|
||||||
class Meta:
|
|
||||||
strict = True
|
|
||||||
|
|
||||||
template_type = fields.Nested(BaseTemplateSchema, only=['template_type'], many=True)
|
template_type = fields.Nested(BaseTemplateSchema, only=['template_type'], many=True)
|
||||||
status = fields.Nested(NotificationModelSchema, only=['status'], many=True)
|
status = fields.Nested(NotificationModelSchema, only=['status'], many=True)
|
||||||
page = fields.Int(required=False)
|
page = fields.Int(required=False)
|
||||||
@@ -700,7 +676,6 @@ class ApiKeyHistorySchema(ma.Schema):
|
|||||||
class EventSchema(BaseSchema):
|
class EventSchema(BaseSchema):
|
||||||
class Meta(BaseSchema.Meta):
|
class Meta(BaseSchema.Meta):
|
||||||
model = models.Event
|
model = models.Event
|
||||||
strict = True
|
|
||||||
|
|
||||||
|
|
||||||
class UnarchivedTemplateSchema(BaseSchema):
|
class UnarchivedTemplateSchema(BaseSchema):
|
||||||
|
|||||||
Reference in New Issue
Block a user