forked from loafle/openapi-generator-original
Python AIOHTTP server generator (#1470)
* Astract factory for generators based on connexion * Add aiohttp server generator * Fix flask tests * Normalize python-flask folder names
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
from connexion.apps.flask_app import FlaskJSONEncoder
|
||||
import six
|
||||
|
||||
from openapi_server.models.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.openapi_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)
|
||||
Reference in New Issue
Block a user