Skip to content

Commit

Permalink
fix enum json serialization, deserialization missing
Browse files Browse the repository at this point in the history
  • Loading branch information
dittmar committed Feb 27, 2024
1 parent 70c2dad commit af6b0f7
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ def _list_extensions(self):
'extensionPrintName': extension.print_name,
'extensionType': extension.extension_type})

return Response(response=json.dumps(result_dict), status=200, mimetype="application/json")
return Response(response=json.dumps(result_dict, default=str), status=200, mimetype="application/json")
3 changes: 3 additions & 0 deletions src/cadenzaanalytics/data/attribute_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
class AttributeRole(Enum):
DIMENSION = "dimension"
MEASURE = "measure"

def __str__(self):
return self.value
2 changes: 1 addition & 1 deletion src/cadenzaanalytics/data/data_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def _to_dict(self) -> dict:
return result

def to_json(self, indent=None) -> str:
return json.dumps(self._to_dict(), indent=indent)
return json.dumps(self._to_dict(), indent=indent, default=str)

@classmethod
def _from_dict(cls, data: dict):
Expand Down
3 changes: 3 additions & 0 deletions src/cadenzaanalytics/data/data_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ class DataType(Enum):
FLOAT64 = "float64"
ZONEDDATETIME = "zonedDateTime"
GEOMETRY = "geometry"

def __str__(self):
return self.value
3 changes: 3 additions & 0 deletions src/cadenzaanalytics/data/extension_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ class ExtensionType(Enum):
VISUALIZATION = "visualization"
ENRICHMENT = "enrichment"
CALCULATION = "calculation"

def __str__(self):
return self.value
3 changes: 3 additions & 0 deletions src/cadenzaanalytics/data/geometry_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ class GeometryType(Enum):
MULTIPOINT = "multipoint"
MULTILINESTRING = "multilinestring"
MULTIPOLYGON = "multipolygon"

def __str__(self):
return self.value
3 changes: 3 additions & 0 deletions src/cadenzaanalytics/data/measure_aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ class MeasureAggregation(Enum):
AVERAGE = "average"
MIN = "min"
MAX = "max"

def __str__(self):
return self.value
3 changes: 3 additions & 0 deletions src/cadenzaanalytics/data/parameter_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ class ParameterType(Enum):
GEOMETRY = "geometry"
SELECT = "select"
BOOLEAN = "boolean"

def __str__(self):
return self.value
2 changes: 1 addition & 1 deletion src/cadenzaanalytics/response/error_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def _get_response_json(self, message: str):
"message": message
}

return json.dumps(error_message)
return json.dumps(error_message, default=str)

def _create_response(self, message: str):
return Response(response=self._get_response_json(message), status=self._status, mimetype="application/json")
2 changes: 1 addition & 1 deletion src/cadenzaanalytics/response/extension_data_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def _get_response_metadata(self, column_metadata):
]
}

return json.dumps(metadata)
return json.dumps(metadata, default=str)

def _create_response(self, data, column_metadata=None):
multipart_response = MultipartEncoder(
Expand Down

0 comments on commit af6b0f7

Please sign in to comment.