Skip to content

Commit fd32863

Browse files
committed
Fix RawResultItem raw field should be result item itself
1 parent 0fccf80 commit fd32863

File tree

5 files changed

+14
-106
lines changed

5 files changed

+14
-106
lines changed

.openapi-generator/FILES

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,3 @@ regula/documentreader/webclient/gen/models/transaction_info.py
7777
regula/documentreader/webclient/gen/models/verification_result.py
7878
regula/documentreader/webclient/gen/models/verified_field_map.py
7979
regula/documentreader/webclient/gen/rest.py
80-
requirements.txt
81-
setup.py

example/example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
with DocumentReaderApi(host) as api:
1515
api.license = license
1616

17-
process_params = ProcessParams(Scenario.FULL_PROCESS, [Result.STATUS, Result.TEXT, Result.IMAGES])
17+
process_params = ProcessParams(Scenario.FULL_PROCESS, [Result.STATUS, Result.TEXT, Result.IMAGES, 6])
1818
process_images = [RecognitionImage(image_payload, Light.WHITE)]
1919
request = RecognitionRequest(process_params, process_images)
2020

generator-templates/api_client.mustache

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -631,25 +631,14 @@ class ApiClient(object):
631631
klass.openapi_types is not None and
632632
isinstance(data, (list, dict))):
633633

634-
is_other_enable = "OTHER" in six.iterkeys(klass.openapi_types)
635-
if is_other_enable:
636-
tmp_data = copy(data)
637-
else:
638-
tmp_data = {}
634+
if "raw" in six.iterkeys(klass.openapi_types):
635+
kwargs[klass.attribute_map["raw"]] = copy(data)
639636

640637
for attr, attr_type in six.iteritems(klass.openapi_types):
641-
642-
if klass.attribute_map[attr] in data and tmp_data:
643-
value = tmp_data.pop(klass.attribute_map[attr])
644-
kwargs[attr] = self.__deserialize(value, attr_type)
645-
646-
elif klass.attribute_map[attr] in data:
638+
if klass.attribute_map[attr] in data:
647639
value = data[klass.attribute_map[attr]]
648640
kwargs[attr] = self.__deserialize(value, attr_type)
649641

650-
if tmp_data:
651-
kwargs[klass.attribute_map["OTHER"]] = tmp_data.popitem()[1]
652-
653642
instance = klass(**kwargs)
654643
if has_discriminator:
655644
klass_name = instance.get_real_child_model(data)
Lines changed: 7 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,28 @@
1-
import pprint
21
from copy import copy
32

43
from regula.documentreader.webclient.gen.models.result_item import ResultItem
54

65

7-
class RawResultItem:
6+
class RawResultItem(ResultItem):
87
openapi_types = copy(ResultItem.openapi_types)
9-
openapi_types["OTHER"] = "Any"
8+
openapi_types["raw"] = "dict"
109

1110
attribute_map = copy(ResultItem.attribute_map)
12-
attribute_map["OTHER"] = "raw"
11+
attribute_map["raw"] = "raw"
1312

1413
def __init__(self, buf_length=None, light=None, list_idx=None, page_idx=None, result_type=None, raw=None,
1514
local_vars_configuration=None):
16-
self.result_item = ResultItem(buf_length, light, list_idx, page_idx, result_type, local_vars_configuration)
15+
super().__init__(buf_length, light, list_idx, page_idx, result_type, local_vars_configuration)
1716
self.__raw = raw
1817

19-
@property
20-
def result_item(self):
21-
return self.__result_item
22-
23-
@result_item.setter
24-
def result_item(self, value):
25-
self.__result_item = value
26-
27-
@property
28-
def buf_length(self):
29-
return self.result_item.buf_length
30-
31-
@buf_length.setter
32-
def buf_length(self, value):
33-
self.result_item.buf_length = value
34-
35-
@property
36-
def light(self):
37-
return self.result_item.light
38-
39-
@light.setter
40-
def light(self, value):
41-
self.result_item.light = value
42-
43-
@property
44-
def list_idx(self):
45-
return self.result_item.list_idx
46-
47-
@list_idx.setter
48-
def list_idx(self, value):
49-
self.result_item.list_idx = value
50-
51-
@property
52-
def page_idx(self):
53-
return self.result_item.page_idx
54-
55-
@page_idx.setter
56-
def page_idx(self, value):
57-
self.result_item.page_idx = value
58-
59-
@property
60-
def result_type(self):
61-
return self.result_item.result_type
62-
63-
@result_type.setter
64-
def result_type(self, value):
65-
self.result_item.result_type = value
66-
6718
@property
6819
def raw(self):
6920
return self.__raw
7021

71-
@raw.setter
72-
def raw(self, value):
73-
self.__raw = value
74-
7522
def to_dict(self):
76-
result = self.result_item.to_dict()
23+
result = super(RawResultItem, self).to_dict()
7724
result["raw"] = self.__raw
7825
return result
7926

80-
def to_str(self):
81-
return pprint.pformat(self.to_dict())
82-
83-
def __repr__(self):
84-
return self.to_str()
85-
86-
def __eq__(self, other):
87-
if not isinstance(other, RawResultItem):
88-
return False
89-
90-
return self.to_dict() == other.to_dict()
91-
92-
def __ne__(self, other):
93-
if not isinstance(other, RawResultItem):
94-
return False
95-
96-
return self.to_dict() != other.to_dict()
27+
def get_real_child_model(self, data):
28+
return None

regula/documentreader/webclient/gen/api_client.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -607,25 +607,14 @@ def __deserialize_model(self, data, klass):
607607
klass.openapi_types is not None and
608608
isinstance(data, (list, dict))):
609609

610-
is_other_enable = "OTHER" in six.iterkeys(klass.openapi_types)
611-
if is_other_enable:
612-
tmp_data = copy(data)
613-
else:
614-
tmp_data = {}
610+
if "raw" in six.iterkeys(klass.openapi_types):
611+
kwargs[klass.attribute_map["raw"]] = copy(data)
615612

616613
for attr, attr_type in six.iteritems(klass.openapi_types):
617-
618-
if klass.attribute_map[attr] in data and tmp_data:
619-
value = tmp_data.pop(klass.attribute_map[attr])
620-
kwargs[attr] = self.__deserialize(value, attr_type)
621-
622-
elif klass.attribute_map[attr] in data:
614+
if klass.attribute_map[attr] in data:
623615
value = data[klass.attribute_map[attr]]
624616
kwargs[attr] = self.__deserialize(value, attr_type)
625617

626-
if tmp_data:
627-
kwargs[klass.attribute_map["OTHER"]] = tmp_data.popitem()[1]
628-
629618
instance = klass(**kwargs)
630619
if has_discriminator:
631620
klass_name = instance.get_real_child_model(data)

0 commit comments

Comments
 (0)