Skip to content

Commit 6bbe9f7

Browse files
committed
add
1 parent 51e9212 commit 6bbe9f7

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

swagger_py_codegen/templates/jsonschema/schemas.tpl

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,44 @@
22

33
import six
44
from jsonschema import RefResolver
5-
from swagger_py_codegen.parser import RefNode
6-
75
# TODO: datetime support
86

7+
class RefNode(object):
8+
9+
def __init__(self, data, ref):
10+
self.ref = ref
11+
self._data = data
12+
13+
def __getitem__(self, key):
14+
return self._data.__getitem__(key)
15+
16+
def __setitem__(self, key, value):
17+
return self._data.__setitem__(key, value)
18+
19+
def __getattr__(self, key):
20+
return self._data.__getattribute__(key)
21+
22+
def __iter__(self):
23+
return self._data.__iter__()
24+
25+
def __repr__(self):
26+
return repr({'$ref': self.ref})
27+
28+
def __eq__(self, other):
29+
if isinstance(other, RefNode):
30+
return self._data == other._data and self.ref == other.ref
31+
elif six.PY2:
32+
return object.__eq__(other)
33+
elif six.PY3:
34+
return object.__eq__(self, other)
35+
else:
36+
return False
37+
38+
def __deepcopy__(self, memo):
39+
return RefNode(copy.deepcopy(self._data), self.ref)
40+
41+
def copy(self):
42+
return RefNode(self._data, self.ref)
943

1044
{% include '_do_not_change.tpl' %}
1145

0 commit comments

Comments
 (0)