forked from loafle/openapi-generator-original
* Remove trailing underscore in security_controller_.py and base_model_.py * Regenerating sample files * Clean-up files with trailing underscore in samples * Update security extension to use the new security_controller * Regenerate unmaintained samples
21 lines
607 B
Python
21 lines
607 B
Python
from connexion.apps.flask_app import FlaskJSONEncoder
|
|
import six
|
|
|
|
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 six.iteritems(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)
|