flask-restx icon indicating copy to clipboard operation
flask-restx copied to clipboard

Migrate from flask-restplus

Open nick4u opened this issue 4 years ago • 4 comments

Hello. Is there any document describing procedure of migrating application from flask-restplus to flask-restx? Are there any issues converting or known hacks to be applied? I am preparing to switch project with about 50k+ lines and just searching for some courage :)

nick4u avatar Mar 24 '20 09:03 nick4u

Hello,

For now, Flask-RESTX is a drop in replacement for Flask-RESTPlus so all you need to do is run something like find . -type f -name "*.py" | xargs sed -i "s/flask_restplus/flask_restx/g"

There are also a couple configuration options that have been renamed in the process.

Overall the migration process should be straightforward.

ziirish avatar Mar 24 '20 09:03 ziirish

Success! All tests passed. All I did was to replace in my pyproject.toml

Werkzeug = "^0.16.1"
flask-restplus = "^0.13"

with

#Werkzeug = "^0.16.1" <- this pin is no longer needed  
#flask-restplus = "^0.13"
flask-restx = "^0.2.0"

do

poetry update

execute in project dir:

find . -type f -name "*.py" | xargs sed -i "s/flask_restplus/flask_restx/g"

and (almost) done I had to change config variable from RESTPLUS_JSON to RESTX_JSON

    RESTX_JSON = {
        "ensure_ascii": False,
        "encode_html_chars": True,
        "escape_forward_slashes": False
    }

I must say documentation on this subject is weakest. I did not find any documentation section that would have all RESTX_* variables listed with explanation in project docs...

Search for RESTX_JSON returns 0/zero meaningful results. I hope docs will some day expand and include all settings without looking at code itself. For now I asume changing all flask config settings named RESTPLUS_* to RESTX_* is enough.

Thx for your work guys!

nick4u avatar Mar 24 '20 10:03 nick4u

Sure we'll improve the doc. I had a PR ready in the restplus project with a better documentation of the configuration options. I'll adapt it to restx.

About the migration process I'll see if we can add a basic exemple.

Thanks for the feedback

ziirish avatar Mar 24 '20 10:03 ziirish

there is a page with some documentation

engFelipeMonteiro avatar Mar 07 '24 13:03 engFelipeMonteiro