forked from loafle/openapi-generator-original
[python-flask] Apply template tweaks to improve lint results (#6826)
The linting results for the generated samples are as follows where the first number is the BEFORE and the second is AFTER. flaskConnexion 1843 vs. 20 flaskConnexion-python2 1841 vs. 19 For the complete details please see the following gist. https://gist.github.com/kenjones-cisco/edc9d71ef7fd2bf23714ecbb693d52b3
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
from six import iteritems
|
||||
from swagger_server.models.base_model_ import Model
|
||||
from connexion.apps.flask_app import FlaskJSONEncoder
|
||||
import six
|
||||
|
||||
from swagger_server.models.base_model_ import Model
|
||||
|
||||
|
||||
class JSONEncoder(FlaskJSONEncoder):
|
||||
include_nulls = False
|
||||
@@ -8,11 +10,11 @@ class JSONEncoder(FlaskJSONEncoder):
|
||||
def default(self, o):
|
||||
if isinstance(o, Model):
|
||||
dikt = {}
|
||||
for attr, _ in iteritems(o.swagger_types):
|
||||
for attr, _ in six.iteritems(o.swagger_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)
|
||||
return FlaskJSONEncoder.default(self, o)
|
||||
|
||||
Reference in New Issue
Block a user