Skip to content

Commit 1d65d6a

Browse files
authored
Merge pull request #150 from mission-liao/feature/fix-yaml-status-code
Fix the error when loading yaml with status-code in integer
2 parents a353247 + 7e3c7a8 commit 1d65d6a

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

pyswagger/core.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,11 @@ def prepare_obj(self, obj, jref):
210210

211211
s.scan(root=obj, route=[AssignParent()])
212212

213+
# fix for yaml that treat response code as number
214+
s.scan(root=obj, route=[YamlFixer()], leaves=[Operation])
213215
# normalize $ref
214216
url, jp = utils.jr_split(jref)
215217
s.scan(root=obj, route=[NormalizeRef(url)])
216-
# fix for yaml that treat response code as number
217-
s.scan(root=obj, route=[YamlFixer()], leaves=[Operation])
218-
219218
# cache this object
220219
if url not in self.__objs:
221220
if jp == '#':
@@ -316,8 +315,8 @@ def prepare(self, strict=True):
316315
:param bool strict: when in strict mode, exception would be raised if not valid.
317316
"""
318317

319-
self.validate(strict=strict)
320318
self.__root = self.prepare_obj(self.raw, self.__url)
319+
self.validate(strict=strict)
321320

322321
if hasattr(self.__root, 'schemes') and self.__root.schemes:
323322
if len(self.__root.schemes) > 0:

pyswagger/tests/test_yaml.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,9 @@ def test_load(self):
2525

2626
self.assertEqual((True, ''), app_json.raw.compare(app_yaml.raw))
2727

28+
def test_create(self):
29+
""" make sure we could load a yml with status-code in int """
30+
app = App.create(get_test_data_folder(
31+
version='2.0',
32+
which='yaml'
33+
))

0 commit comments

Comments
 (0)