Anis 00de163655
[python-flask] adopt python3.5+ syntax (#16375)
* adopt python3.5+ syntax

removing some residual python2 code, since it is not supported anymore, like:
- no need for `six` anymore
- no need for encoding utf8 in top file
- remove `object` inheritance in base model
- remove absolute import `__future__`

* generate samples

applying the new templates

* update python ignore pattern

ignore all the `.venv` folders
2023-08-23 10:42:40 +08:00

20 lines
578 B
Python

from connexion.apps.flask_app import FlaskJSONEncoder
from openapi_server.models.base_model import Model
class JSONEncoder(FlaskJSONEncoder):
include_nulls = False
def default(self, o):
if isinstance(o, Model):
dikt = {}
for attr in o.openapi_types:
value = getattr(o, attr)
if value is None and not self.include_nulls:
continue
attr = o.attribute_map[attr]
dikt[attr] = value
return dikt
return FlaskJSONEncoder.default(self, o)