Flask-RESTful migration to Flask-RESTPlus
In a simple application with a several endpoints, it’s ok to use the default Flask routes.
@app.route('/api/v1.0/users', methods=['GET'])
def get_users():
return jsonify({'objects': users})
But when an application becomes bigger, it can be useful to use a some REST framework or split it on the smaller apps. The REST framework is used to:
- enforce best practices
- simplify: versioning, serialization, documentation, authenication
- provide browsable API
For a long time I used Flask-RESTful, but then the requirement for a swagger documentaion appeared and I switched to Flask-RESTPlus. It based on Flask-RESTful, so to migrate it’s necessary only to change imports - from flask_restful import ...
to from flask_restplus import ...
. In addition to swagger documentation, I like that it adds namespaces.
Here is some slides about it from Michał Karzyński’s presentation on EuroPython 2016.