apispec-webframeworks
apispec-webframeworks copied to clipboard
Can't use apispec tornado plugin icw complex paths
Issue by p0psicles
Monday Dec 11, 2017 at 19:41 GMT
Originally opened as https://github.com/marshmallow-code/apispec/issues/176
I'm trying to use apispec icw the 'apispec.ext.tornado' and 'apispec.ext.marshmallow' plugins. Only i'm getting the following error:
Traceback (most recent call last):
File "D:\JetBrains\PyCharm 2017.2.4\helpers\pydev\pydevd.py", line 1599, in <module>
globals = debugger.run(setup['file'], None, None, is_module)
File "D:\JetBrains\PyCharm 2017.2.4\helpers\pydev\pydevd.py", line 1026, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "D:\myproj/start.py", line 7, in <module>
main()
File "D:\myproj\medusa\__main__.py", line 2104, in main
application.start(sys.argv[1:])
File "D:\myproj\medusa\__main__.py", line 347, in start
self.web_server = AppWebServer(self.web_options)
File "D:\myproj\medusa\server\core.py", line 230, in __init__
spec.add_path(urlspec=urlspec)
File "D:\Python27\lib\site-packages\apispec\core.py", line 211, in add_path
raise APISpecError('Path template is not specified')
apispec.exceptions.APISpecError: Path template is not specified
It seems to be happening because matcher._path is None. https://github.com/marshmallow-code/apispec/blob/dev/apispec/ext/tornado.py#L95
urlspec.matcher._path
returns None, because of this:
https://github.com/tornadoweb/tornado/blob/master/tornado/routing.py#L571
And my route looks like this:
'/api/v2/series/(?P<series_slug>\\w+)/episode(?:(?:(?:(?:/(?P<episode_slug>[\\w-]+))|/?)(?:(?:/(?P<path_param>\\w+))|/?))|/?)/?$'
So because the tornado plugin uses the matcher._path, it's can't translate to an OpenApi compliant path. Is there anything I can do about it?