flask-restx
flask-restx copied to clipboard
flask-restx is not compatible with the latest werkzeug
the 2.2.0 release of pallets/werkzeug breaks flask-restx.
Here you can find the following traceback:
../../.local/lib/python3.8/site-packages/flask_restx/__init__.py:5: in <module>
from .api import Api # noqa
../../.local/lib/python3.8/site-packages/flask_restx/api.py:50: in <module>
from .swagger import Swagger
../../.local/lib/python3.8/site-packages/flask_restx/swagger.py:18: in <module>
from werkzeug.routing import parse_rule
E ImportError: cannot import name 'parse_rule' from 'werkzeug.routing' (/home/prambaud/.local/lib/python3.8/site-packages/werkzeug/routing/__init__.py)
Repro Steps (if applicable)
- install flas-restx
- import flask-restx.swagger as frs
- Broken!
parse_rule()
is marked as :internal:
, shouldn't be used by flask-restx
https://github.com/pallets/werkzeug/blob/2.1.x/src/werkzeug/routing.py#L215
I can confirm the bug
Can also confirm the bug. Quick workaround is to downgrade Flask to v2.1.2, since the newest version requires Werkzeug >= 2.2.0 and Flask v2.1.2 just requires Werkzeug>=2.0 To prevent the flask requirement from getting the newest version of Werkzeug, it should be listed first in the requirements.txt file. Hope that solves someones issue.
Werkzeug <= 2.1.2
flask == 2.1.2
flask-restx >= 0.5.1
There is also an issue with flask-restx and werkzeug 2.1.x (https://github.com/python-restx/flask-restx/issues/422) so I would maybe recommend setting werkzeug==2.0.*
for now.
I put up a PR, #463, which should at least fix this specific problem. It seems there are some cobwebs on the CI for this project, however, so this may require some maintainer love to fix the tests and merge.
Now more urgent, with the release of Flask 2.2.0 and its associated update to latest werkzeug.
This error wasted my 30 minutes
It really needs to be fixed asap!
have the same issue... also waiting for a fix.
Having this issue as well.... I personally don't mind downgrading, but our pipeline uses a codescanner that will not allow older Werkzeug due to an open CVE
Hi folks,
I am also waiting for a patch: today I tried with these Py Package versions: flask==2.2.2 flask_restx=0.5.1 werkzeug==2.2.2 flask-login==0.6.2
It seems like flask_restx.swagger.py makes issues as werkzeug.routing.rules.py has changed. It doesn't support parse_rule function anymore. Instead there is a new _parse_rule function inside the Rule Class. I had no time to implement the new Werkzeug Rule API into Flask-RestX. However I created two patch files as an interim solution to get everything running again and to make swagger HTML accessible! Please let me know if it works for you.
Hi unrest folk,
because flask-restx
is still not compatible with werkzeug
I created small monkey patch https://github.com/Ryu-CZ/restx-monkey I am using it at work on company servers, so far so goo. I hope it helps as temporal quick solution for anyone. Enjoy :+1:
PS: It also patches flask_restx.Api
soon to be incompatible lazy swagger doc routes binding in case you bind Api
with flask.Blueprint
first, and register Blueprint
into flask app instance flask.Flask
later.
@ziirish , will this fix be released as a new version soon? - Thanks
@kannanprasanna: See #474.
So it looks fixed in the sources. Any plan to release a 0.5.2 on pypi ? Thanks.