I just ran into an opaque error due to the fact that flask-restx imports dumps from either ujson or json, depending on whether the former is installed.
The issue is with custom JSON encoding classes, e.g.
app.config["RESTX_JSON"] = {"cls": CustomEncoder}
json.dumps supports the cls arg but ujson.dumps does not, so having ujson installed on a system will cause the code to crash.
The only way to address it is to uninstall ujson, I think. I wonder if either a more descriptive error message or a way to force the default json.dumps would help avoid this issue? Or perhaps it's worth considering a more current 'fast JSON' library that aligns more closely with the API of the default one?
I just ran into an opaque error due to the fact that flask-restx imports
dumps
from either ujson or json, depending on whether the former is installed.The issue is with custom JSON encoding classes, e.g.
app.config["RESTX_JSON"] = {"cls": CustomEncoder}
json.dumps
supports thecls
arg butujson.dumps
does not, so havingujson
installed on a system will cause the code to crash.The only way to address it is to uninstall
ujson
, I think. I wonder if either a more descriptive error message or a way to force the defaultjson.dumps
would help avoid this issue? Or perhaps it's worth considering a more current 'fast JSON' library that aligns more closely with the API of the default one?