mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-31 23:26:23 -05:00
Fix serialisation of callbacks
Because the IDs of our callback and inbound SMS APIs were stored in lists instead of directly on the serialised model they weren’t getting cast to a string before trying to JSONify them. And JSON doesn’t know what to do with a UUID object. For some reason this was only affecting the endpoint for fetching inbound SMS.
This commit is contained in:
@@ -63,9 +63,16 @@ class UUIDsAsStringsMixin:
|
||||
@post_dump()
|
||||
def __post_dump(self, data):
|
||||
for key, value in data.items():
|
||||
|
||||
if isinstance(value, UUID):
|
||||
data[key] = str(value)
|
||||
|
||||
if isinstance(value, list):
|
||||
data[key] = [
|
||||
(str(item) if isinstance(item, UUID) else item)
|
||||
for item in value
|
||||
]
|
||||
|
||||
|
||||
class BaseSchema(ma.ModelSchema):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user