I'm using Flask version 2.3.2 and FireO ORM 2.1.0
FireO models are not directly compatible with Flask's jsonify. Meaning that they are not serializables by default and need to be converted into a dictionary before passing them to jsonify.
Ex:
users_dicts = [user.to_dict() for user in users]
return jsonify(users_dicts), 200
# or
return jsonify(user.to_dict()), 200
So my idea was to extend either FireO Models or Flask so I could just do:
jsonify(users), 200 # Users is a FireO QueryIterator
jsonify(user), 200 # User is a FireO model
I achieved the desired behavior by extending Flask's DefaultJSONProvider. But as the majority of the information that I found online was outdated, here is how I did it.
P.S: I was hoping to extend FireO's Model classes, but I'm having some difficulties understanding the inner workings of Flask's jsonify and dumps, especially what they require for class serialization.Any advice here would be great.