All Downloads are FREE. Search and download functionalities are using the official Maven repository.

flaskConnexion.encoder.mustache Maven / Gradle / Ivy

There is a newer version: 3.0.0-rc1
Show newest version
from connexion.apps.flask_app import FlaskJSONEncoder
import six

from {{modelPackage}}.base_model_ import Model


class JSONEncoder(FlaskJSONEncoder):
    include_nulls = False

    def default(self, o):
        if isinstance(o, Model):
            dikt = {}
            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)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy