Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build_resource failure for root path with no tags #116

Open
macisamuele opened this issue Sep 9, 2016 · 1 comment
Open

build_resource failure for root path with no tags #116

macisamuele opened this issue Sep 9, 2016 · 1 comment

Comments

@macisamuele
Copy link
Collaborator

The issue is related to what is reported in bravado issue #239.

An small example of the issue is

Python 2.7.9 (default, Aug 23 2016, 10:24:57)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from bravado_core.spec import Spec
>>> import yaml
>>>
>>> spec_text = """
info:
...   version: 0.0.0
...   title: Simple API
... paths:
...   /:
...     get:
...       responses:
...         '200':
...           description: OK
... swagger: '2.0'
... """
>>> spec_dict = yaml.load(spec_text)
>>> print spec_dict
{'info': {'version': '0.0.0', 'title': 'Simple API'}, 'paths': {'/': {'get': {'responses': {'200': {'description': 'OK'}}}}}, 'swagger': '2.0'}
>>> swagger_spec = Spec.from_dict(spec_dict)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/maci/pg/bravado/.tox/py27/lib/python2.7/site-packages/bravado_core/spec.py", line 152, in from_dict
    spec.build()
  File "/Users/maci/pg/bravado/.tox/py27/lib/python2.7/site-packages/bravado_core/spec.py", line 175, in build
    self.resources = build_resources(self)
  File "/Users/maci/pg/bravado/.tox/py27/lib/python2.7/site-packages/bravado_core/resource.py", line 67, in build_resources
    tags.append(convert_path_to_resource(path_name))
  File "/Users/maci/pg/bravado/.tox/py27/lib/python2.7/site-packages/bravado_core/resource.py", line 31, in convert_path_to_resource
    raise SwaggerMappingError(err_msg.format(path_name))
bravado_core.exception.SwaggerMappingError: Could not extract resource name from path /

The issue seems caused by the assumption that the path will match the following regexp /.+ (resource.py)

@jkrukoff
Copy link
Contributor

Just ran into this issue. Was fortunate enough to also be in control of the swagger spec, so as to be able to add a superfluous tag to my root path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants