You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

21 line
608 B

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