ValueError: invalid obj passed <class 'list'> from spec/base.py
colinglaes opened this issue · 0 comments
colinglaes commented
I got the following error when trying to generate an App off of the polygon.io swagger json file (https://polygon.io/docs/swagger.json). Is this likely to be an issue with the swagger data itself or is this a bug?
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.3.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from pyswagger import App, Security
In [2]: from pyswagger.contrib.client.requests import Client
In [3]: from pyswagger.utils import jp_compose
In [4]: app = App._create_('https://polygon.io/docs/swagger.json')
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-4-58433a254d07> in <module>
----> 1 app = App._create_('https://polygon.io/docs/swagger.json')
~/.pyenv/mve/lib/python3.6/site-packages/pyswagger/core.py in create(kls, url, strict)
362 :raises NotImplementedError: the swagger version is not supported.
363 """
--> 364 app = kls.load(url)
365 app.prepare(strict=strict)
366
~/.pyenv/mve/lib/python3.6/site-packages/pyswagger/core.py in load(kls, url, getter, parser, url_load_hook, sep, prim, mime_codec, resolver)
283 url = utils.normalize_url(url)
284 app = kls(url, url_load_hook=url_load_hook, sep=sep, prim=prim, mime_codec=mime_codec, resolver=resolver)
--> 285 app.__raw, app.__version = app.load_obj(url, getter=getter, parser=parser)
286 if app.__version not in ['1.2', '2.0']:
287 raise NotImplementedError('Unsupported Version: {0}'.format(self.__version))
~/.pyenv/mve/lib/python3.6/site-packages/pyswagger/core.py in load_obj(self, jref, getter, parser)
176 # swagger 2.0
177 with SwaggerContext(tmp, '_tmp_') as ctx:
--> 178 ctx.parse(obj)
179 elif version == None and parser:
180 with parser(tmp, '_tmp_') as ctx:
~/.pyenv/mve/lib/python3.6/site-packages/pyswagger/spec/base.py in parse(self, obj)
161 functools.partial(_apply, ctx_kls, key),
162 functools.partial(_apply_dict, ctx_kls, key),
--> 163 functools.partial(_apply_dict_before_list, key)
164 )
165
~/.pyenv/mve/lib/python3.6/site-packages/pyswagger/spec/base.py in container_apply(ct, v, f, fd, fdl)
37 ret = {}
38 for k, vv in six.iteritems(v):
---> 39 ret[k] = fd(ct, vv, k) if fd else f(ct, vv)
40 elif ct == ContainerType.dict_of_list_:
41 ret = {}
~/.pyenv/mve/lib/python3.6/site-packages/pyswagger/spec/base.py in _apply_dict(x, kk, ct, v, k)
138 self._obj[kk][k] = {} if ct == ContainerType.dict_ else []
139 with x(self._obj[kk], k) as ctx:
--> 140 ctx.parse(obj=v)
141
142 def _apply_dict_before_list(kk, ct, v, k):
~/.pyenv/mve/lib/python3.6/site-packages/pyswagger/spec/base.py in parse(self, obj)
161 functools.partial(_apply, ctx_kls, key),
162 functools.partial(_apply_dict, ctx_kls, key),
--> 163 functools.partial(_apply_dict_before_list, key)
164 )
165
~/.pyenv/mve/lib/python3.6/site-packages/pyswagger/spec/base.py in container_apply(ct, v, f, fd, fdl)
37 ret = {}
38 for k, vv in six.iteritems(v):
---> 39 ret[k] = fd(ct, vv, k) if fd else f(ct, vv)
40 elif ct == ContainerType.dict_of_list_:
41 ret = {}
~/.pyenv/mve/lib/python3.6/site-packages/pyswagger/spec/base.py in _apply_dict(x, kk, ct, v, k)
138 self._obj[kk][k] = {} if ct == ContainerType.dict_ else []
139 with x(self._obj[kk], k) as ctx:
--> 140 ctx.parse(obj=v)
141
142 def _apply_dict_before_list(kk, ct, v, k):
~/.pyenv/mve/lib/python3.6/site-packages/pyswagger/spec/base.py in parse(self, obj)
161 functools.partial(_apply, ctx_kls, key),
162 functools.partial(_apply_dict, ctx_kls, key),
--> 163 functools.partial(_apply_dict_before_list, key)
164 )
165
~/.pyenv/mve/lib/python3.6/site-packages/pyswagger/spec/base.py in container_apply(ct, v, f, fd, fdl)
29
30 if ct == None:
---> 31 ret = f(ct, v)
32 elif ct == ContainerType.list_:
33 ret = []
~/.pyenv/mve/lib/python3.6/site-packages/pyswagger/spec/base.py in _apply(x, kk, ct, v)
132 self._obj[kk] = {} if ct == None else []
133 with x(self._obj, kk) as ctx:
--> 134 ctx.parse(obj=v)
135
136 def _apply_dict(x, kk, ct, v, k):
~/.pyenv/mve/lib/python3.6/site-packages/pyswagger/spec/base.py in parse(self, obj)
126
127 if not isinstance(obj, dict):
--> 128 raise ValueError('invalid obj passed: ' + str(type(obj)))
129
130 def _apply(x, kk, ct, v):
ValueError: invalid obj passed: <class 'list'>
In [5]: