marshmallow-code / marshmallow-code/apispec-webframeworks
Can't use apispec tornado plugin icw complex paths
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 33
- Forks
- 24
- Avg merge
- 5h 38m
- Merged PRs (30d)
- 4
Description
**Issue by [p0psicles](https://github.com/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
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
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\\w+)/episode(?:(?:(?:(?:/(?P[\\w-]+))|/?)(?:(?:/(?P\\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?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with apispec/ext/tornado.py around the matcher._path handling and apispec/core.py where add_path raises the error; compare these with Tornado's routing.py behavior for the reported route. Reproduce the complex route and add a regression test showing the plugin supplies a valid OpenAPI path template without breaking simpler routes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100