Local swagger API doc parse fails looking for nested swagger.{json.yml} files
bedge opened this issue · 1 comments
Pyswagger appears to be expecting nested swagger.{json.yml} docs at each 'path' in the API tree for an API specified as a local files, (file://):
I have a swagger 1.2 doc, applications.json, handed to me from another team from which to develop a client.
(output truncated for brevity)
----> 3 api_applications = App.create('./applications.json')
~/.pyenv/versions/3.6.5/envs/3.6/lib/python3.6/site-packages/pyswagger/core.py in create(kls, url, strict)
--> 364 app = kls.load(url)
365 app.prepare(strict=strict)
366~/.pyenv/versions/3.6.5/envs/3.6/lib/python3.6/site-packages/pyswagger/core.py in load(kls, url, > --> 285 app.__raw, app.__version = app.load_obj(url, getter=getter, parser=parser)
~/.pyenv/versions/3.6.5/envs/3.6/lib/python3.6/site-packages/pyswagger/core.py in load_obj(self, jref, getter, parser)
--> 174 ctx.parse(obj, jref, self.__resolver, getter)~/.pyenv/versions/3.6.5/envs/3.6/lib/python3.6/site-packages/pyswagger/spec/v1_2/parser.py in parse(self, obj, root_url, resolver, getter)
--> 186 res = resolver.resolve(url, getter)~/.pyenv/versions/3.6.5/envs/3.6/lib/python3.6/site-packages/pyswagger/resolve.py in resolve(self, jref, getter)
---> 54 getter = LocalGetter(os.path.join(p.netloc, p.path))~/.pyenv/versions/3.6.5/envs/3.6/lib/python3.6/site-packages/pyswagger/getter.py in init(self, path)
102 break
103 else:
--> 104 raise ValueError('Unable to locate resource file: [{0}]'.format(path))
105
106 def load(self, path):ValueError: Unable to locate resource file: [/Users/bedge/git/test_apis/applications/{application}]
It's looking for additional swagger json/yml files for each path in the API doc.
I thought perhaps it was intended to work only for http:// API docs, but it does check for file:// as a valid URL type.
This is a swagger 1.2 doc.
I confirmed that this does not happen with a local copy of http://petstore.swagger.io/v2/swagger.json.
@bedge Sorry for late reply.
A Swagger API spec in 1.2 would expect an API Declaration for each API you described in Resource Listing. For example, a valid Swagger 1.2 file structure can be something looks like:
resource_list.json # root document
pet.json # pet api
store.json # store api
user.json # user api
An example can be found in tests under this project.