pyopenapi/pyswagger

HTTP Error 400: Bad Request

machinekoder opened this issue · 1 comments

When I try:

from pyswagger import App
app = App._create_('https://api.shoeboxed.com/v2/explorer/swagger.json')

I get:

  File "/home/alexander/projects/roesslersystems/buchhaltung/src/buchhaltung/apis/shoeboxed2.py", line 24, in <module>
    app = App._create_('https://api.shoeboxed.com/v2/explorer/swagger.json')
  File "/home/alexander/projects/roesslersystems/buchhaltung/.venv/lib/python3.6/site-packages/pyswagger/core.py", line 364, in create
    app = kls.load(url)
  File "/home/alexander/projects/roesslersystems/buchhaltung/.venv/lib/python3.6/site-packages/pyswagger/core.py", line 285, in load
    app.__raw, app.__version = app.load_obj(url, getter=getter, parser=parser)
  File "/home/alexander/projects/roesslersystems/buchhaltung/.venv/lib/python3.6/site-packages/pyswagger/core.py", line 174, in load_obj
    ctx.parse(obj, jref, self.__resolver, getter)
  File "/home/alexander/projects/roesslersystems/buchhaltung/.venv/lib/python3.6/site-packages/pyswagger/spec/v1_2/parser.py", line 186, in parse
    res = resolver.resolve(url, getter)
  File "/home/alexander/projects/roesslersystems/buchhaltung/.venv/lib/python3.6/site-packages/pyswagger/resolve.py", line 62, in resolve
    obj = six.advance_iterator(getter)
  File "/home/alexander/projects/roesslersystems/buchhaltung/.venv/lib/python3.6/site-packages/pyswagger/getter.py", line 32, in __next__
    obj = self.load(self.urls.pop(0))
  File "/home/alexander/projects/roesslersystems/buchhaltung/.venv/lib/python3.6/site-packages/pyswagger/getter.py", line 138, in load
    return self.__simple_getter_callback__.__func__(path)
  File "/home/alexander/projects/roesslersystems/buchhaltung/.venv/lib/python3.6/site-packages/pyswagger/getter.py", line 144, in _url_load
    f = six.moves.urllib.request.urlopen(path)
  File "/usr/local/lib/python3.6/urllib/request.py", line 223, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/local/lib/python3.6/urllib/request.py", line 532, in open
    response = meth(req, response)
  File "/usr/local/lib/python3.6/urllib/request.py", line 642, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/local/lib/python3.6/urllib/request.py", line 570, in error
    return self._call_chain(*args)
  File "/usr/local/lib/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/usr/local/lib/python3.6/urllib/request.py", line 650, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request

Any ideas why this does not work?

The targeting spec from https://api.shoeboxed.com/v2/explorer/swagger.json is Swagger 1.2 spec, however, it looks like an API Declaration object instead of a Resource Listing object.

The entry point of Swagger 1.2 document should be a Resource Listing object. When pyswagger trying to load it as a Resource Listing object, it would trying to resolve all path fields and it won't work in that case.