Incompatibility with flask 2.3
totycro opened this issue · comments
The relase notes for flask 2.3 contain this:
json_encoder and json_decoder attributes on app and blueprint, and the corresponding json.JSONEncoder and JSONDecoder classes, are removed.
There is some more information in the docs for 2.2 about JSONEncoder
.
Currently JSONEncoder
is used here in flasgger, leading to this import error:
my_api/__init__.py:9: in <module>
from flasgger import Swagger
/usr/local/lib/python3.10/site-packages/flasgger/__init__.py:10: in <module>
from .base import Swagger, Flasgger, NO_SANITIZER, BR_SANITIZER, MK_SANITIZER, LazyJSONEncoder # noqa
/usr/local/lib/python3.10/site-packages/flasgger/base.py:28: in <module>
from flask.json import JSONEncoder
E ImportError: cannot import name 'JSONEncoder' from 'flask.json' (/usr/local/lib/python3.10/site-packages/flask/json/__init__.py)
I think the fix would be to port the serialization behavior to JSONProvider.
There is some information in the PR that introduced JSONProvider about why they changed this.