debian/bullseye
|
Last change
on this file since b43efc1 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
|
| Rev | Line | |
|---|
| [3a89adb] | 1 | from connexion.apps.flask_app import FlaskJSONEncoder
|
|---|
| 2 | import six
|
|---|
| 3 |
|
|---|
| 4 | from {{modelPackage}}.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.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.