mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 19:33:55 +00:00
18 lines
616 B
Python
18 lines
616 B
Python
from six import iteritems
|
|
from swagger_server.models.base_model_ import Model
|
|
from connexion.apps.flask_app import FlaskJSONEncoder
|
|
|
|
class JSONEncoder(FlaskJSONEncoder):
|
|
include_nulls = False
|
|
|
|
def default(self, o):
|
|
if isinstance(o, Model):
|
|
dikt = {}
|
|
for attr, _ in iteritems(o.swagger_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) |