Skip to content

Commit 660aa19

Browse files
committed
Update models.py
1 parent dedc349 commit 660aa19

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

api/src/workspaces/models.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import requests
77
from geoalchemy2 import WKBElement
88
from jsonschema import ValidationError, validate
9-
from pydantic import BaseModel, ConfigDict, Field, Json, field_validator
9+
from pydantic import BaseModel, ConfigDict, Field, Json, field_serializer, field_validator
1010
from typing_extensions import Annotated
1111

1212
from api.core.config import Settings
@@ -115,6 +115,12 @@ class WorkspaceBase(BaseModel):
115115

116116
model_config = ConfigDict(from_attributes=True)
117117

118+
# emulate the prior Tasking Manager's behavior of dumping JSON as a string and not an object (FIXME?)
119+
@field_serializer('tdeiMetadata', when_used='json')
120+
def serialize_data_as_string(self, data: dict[str, Any], _info) -> str:
121+
"""Serializes the dictionary data into a JSON string."""
122+
return json.dumps(data)
123+
118124
# there are some legacy records with '', which is not valid JSON, so map those to None
119125
@field_validator("*", mode="before")
120126
@classmethod

0 commit comments

Comments
 (0)