source: src/mapservice/codegen/templates/encoder.mustache@ 1cd45dd

debian/bullseye
Last change on this file since 1cd45dd was 5e4cb73, checked in by Joachim Langenbach <joachim.langenbach@…>, 8 years ago

Refactored mapservice

  • mapservice is a connexion python webservice with openapi defined api
  • mapservice-webclient is a angular app, consuming the openapi webservice mapservice
  • Property mode set to 100644
File size: 603 bytes
RevLine 
[3a89adb]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.