source: buildhelpers/codegen/templates/encoder.mustache@ 34ce2a3

debian/bullseye
Last change on this file since 34ce2a3 was 43fd35c, checked in by Joachim Langenbach <joachim.langenbach@…>, 7 years ago

Refactored code to have one gnuboat python structure

  • Property mode set to 100644
File size: 603 bytes
Line 
1from connexion.apps.flask_app import FlaskJSONEncoder
2import six
3
4from {{modelPackage}}.base_model_ import Model
5
6
7class 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.openapi_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)
Note: See TracBrowser for help on using the repository browser.