Skip to content

Commit e6ec834

Browse files
committed
fix raw models serde
1 parent fdd3094 commit e6ec834

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

generator-templates/api_client.mustache

+3-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ class ModelSerDe:
6666
elif isinstance(obj, (datetime.datetime, datetime.date)):
6767
return obj.isoformat()
6868

69-
if isinstance(obj, dict):
69+
if isinstance(obj, regula.documentreader.webclient.ext.models.RawResultItem):
70+
obj_dict = obj.raw
71+
elif isinstance(obj, dict):
7072
obj_dict = obj
7173
else:
7274
# Convert model obj to dict except

regula/documentreader/webclient/ext/models/raw_result_item.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ def raw(self):
2020
return self.__raw
2121

2222
def to_dict(self):
23-
result = super(RawResultItem, self).to_dict()
24-
result["raw"] = self.__raw
25-
return result
23+
return self.__raw
2624

2725
def get_real_child_model(self, data):
2826
return None

regula/documentreader/webclient/ext/models/recognition_response.py

+5
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,8 @@ def result_by_type(self, result_type: int) -> Optional[ResultItem]:
6161

6262
def results_by_type(self, result_type) -> List[ResultItem]:
6363
return [r for r in self.low_lvl_response.container_list.list if r.result_type == result_type]
64+
65+
def __eq__(self, other: object) -> bool:
66+
if not isinstance(other, RecognitionResponse):
67+
return False
68+
return self.low_lvl_response == other.low_lvl_response

0 commit comments

Comments
 (0)