Skip to content

Commit

Permalink
Uncouple all flask functions from base code.
Browse files Browse the repository at this point in the history
removed test_decorators and test_parameter (this test is useless now);
removed the request/response containers and add new request response classes;
created a abstract api class and a api flask class;
derived classes will implements the get_response/get_request methods that will convert framework req/resp types to connexion req/resp types;
moved the jsonifier from produces to flask api;
created a abstract app class and a app flask class;
changed all validators to use the ConnexionRequest instead flask request;
changed the problem function to generate a ConnexionRequest;
created a new user variables container called context (this is a property of ConnexionRequest). this will be passed as kwargs to all operations functions;
this context is used on authentication;
fixed all tests to new API;
some changes that I did may not be documented in this commit.
  • Loading branch information
dutradda committed Mar 14, 2017
1 parent c353be5 commit a472d52
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 26 deletions.
4 changes: 4 additions & 0 deletions connexion/apps/flask_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from ..apis.flask_api import FlaskApi
from .abstract import AbstractApp
from flask import json
from decimal import Decimal

logger = logging.getLogger('connexion.app')

Expand Down Expand Up @@ -152,4 +153,7 @@ def default(self, o):
if isinstance(o, datetime.date):
return o.isoformat()

if isinstance(o, Decimal):
return float(o)

return json.JSONEncoder.default(self, o)
26 changes: 0 additions & 26 deletions connexion/decorators/produces.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@
import functools
import logging

from decimal import Decimal

import flask
import six
from flask import json

from .decorator import BaseDecorator

logger = logging.getLogger('connexion.decorators.produces')
Expand All @@ -18,26 +12,6 @@
NoContent = object()


class JSONEncoder(json.JSONEncoder):
def default(self, o):
if isinstance(o, datetime.datetime):
if o.tzinfo:
# eg: '2015-09-25T23:14:42.588601+00:00'
return o.isoformat('T')
else:
# No timezone present - assume UTC.
# eg: '2015-09-25T23:14:42.588601Z'
return o.isoformat('T') + 'Z'

if isinstance(o, datetime.date):
return o.isoformat()

if isinstance(o, Decimal):
return float(o)

return json.JSONEncoder.default(self, o)


class BaseSerializer(BaseDecorator):
def __init__(self, mimetype='text/plain'):
"""
Expand Down

0 comments on commit a472d52

Please sign in to comment.