Skip to content

Commit

Permalink
fixed #123
Browse files Browse the repository at this point in the history
  • Loading branch information
gusibi committed Sep 20, 2018
1 parent 7f163a8 commit e7df322
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion swagger_py_codegen/_version.py
@@ -1,4 +1,4 @@
"""Version information."""

# The following line *must* be the last in the module, exactly as formatted:
__version__ = "0.3.3"
__version__ = "0.3.4"
18 changes: 11 additions & 7 deletions swagger_py_codegen/parser.py
Expand Up @@ -19,7 +19,6 @@ def __init__(self, data, ref):
self.ref = ref
self._data = data


def __getitem__(self, key):
return self._data.__getitem__(key)

Expand All @@ -33,17 +32,22 @@ def __iter__(self):
return self._data.__iter__()

def __repr__(self):
return repr({'$ref':self.ref})
return repr({'$ref': self.ref})

def __eq__(self, other):
if isinstance(other, RefNode):
return self._data == other._data and self.ref == other.ref
else:
elif six.PY2:
return object.__eq__(other)
elif six.PY3:
return object.__eq__(self, other)
else:
return False

def copy(self):
return RefNode(self._data, self.ref)


class Swagger(object):

separator = '\0'
Expand All @@ -61,7 +65,7 @@ def _process_ref(self):
"""
resolve all references util no reference exists
"""
for path, ref in self.search(['**', '$ref']):
for path, ref in self.search(['**', '$ref']):
data = resolve(self.data, ref)
path = path[:-1]
self.set(path, RefNode(data, ref))
Expand Down Expand Up @@ -97,15 +101,15 @@ def get_definition_refs():
}
if not ready:
continue
#msg = '$ref circular references found!\n'
#raise ValueError(msg)
# msg = '$ref circular references found!\n'
# raise ValueError(msg)
for definition in ready:
del definition_refs[definition]
for refs in six.itervalues(definition_refs):
refs.difference_update(ready)

self._definitions += ready
self._definitions.sort(key=lambda x :x[1])
self._definitions.sort(key=lambda x: x[1])

def search(self, path):
for p, d in dpath.util.search(
Expand Down

0 comments on commit e7df322

Please sign in to comment.