python-restx / flask-restx

Fork of Flask-RESTPlus: Fully featured framework for fast, easy and documented API development with Flask
https://flask-restx.readthedocs.io/en/latest/
Other
2.17k stars 336 forks source link

Migrate from flask-restplus #99

Open nick4u opened 4 years ago

nick4u commented 4 years ago

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 :)

ziirish commented 4 years ago

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.

nick4u commented 4 years ago

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!

ziirish commented 4 years ago

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

engFelipeMonteiro commented 8 months ago

there is a page with some documentation