1 |
d35c7f1f
|
Captain_Trojan
|
from connexion.apps.flask_app import FlaskJSONEncoder
|
2 |
|
|
import six
|
3 |
|
|
|
4 |
|
|
from swagger_server.models.base_model_ import Model
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
class JSONEncoder(FlaskJSONEncoder):
|
8 |
|
|
include_nulls = False
|
9 |
|
|
|
10 |
|
|
def default(self, o):
|
11 |
|
|
if isinstance(o, Model):
|
12 |
|
|
dikt = {}
|
13 |
|
|
for attr, _ in six.iteritems(o.swagger_types):
|
14 |
|
|
value = getattr(o, attr)
|
15 |
|
|
if value is None and not self.include_nulls:
|
16 |
|
|
continue
|
17 |
|
|
attr = o.attribute_map[attr]
|
18 |
|
|
dikt[attr] = value
|
19 |
|
|
return dikt
|
20 |
|
|
return FlaskJSONEncoder.default(self, o)
|