forked from spec-first/connexion
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Created a metaclass for AbstractAPI (it is used to set the jsonifier for the class); - Created a new class method AbstractAPI._set_jsonifier; - Changed the code to use the new jsonifier interface; - Create a new module called coroutines_wrapper to put the wrapper functions with the 'yield from' statement. It is used to enable frameworks with coroutine handlers; - Did the AioHttpApi.get_request coroutine and add req.read() to get the request body; - Moved the flask jsonifier to utils and did it a generic jsonifier; - Created a function called 'has_coroutine' on utils module; - Added aiohttp_jinja2 to requirements-aiohttp; - Added a new python3 coreragerc file to skip only python2 lines; - Fixed the set of validation_response on test_aiohttp_simple_api.py; - Added the test to check the aiohttp body request; - Fixed the response for 'aiohttp_bytes_response' and 'aiohttp_non_str_non_json_response' paths on aiohttp/swagger_simple.yml file.
- Loading branch information
Showing
16 changed files
with
174 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import asyncio | ||
import functools | ||
|
||
|
||
def get_request_life_cycle_wrapper(function, api, mimetype): | ||
""" | ||
It is a wrapper used on `EndOfRequestLifecycleDecorator` class. | ||
This function is located in an extra module because python2.7 don't | ||
support the 'yield from' syntax. This function is used to await | ||
the coroutines to connexion does the proper validation of parameters | ||
and responses. | ||
:rtype asyncio.coroutine | ||
""" | ||
@functools.wraps(function) | ||
def wrapper(*args, **kwargs): | ||
connexion_request = api.get_request(*args, **kwargs) | ||
while asyncio.iscoroutine(connexion_request): | ||
connexion_request = yield from connexion_request | ||
|
||
connexion_response = function(connexion_request) | ||
while asyncio.iscoroutine(connexion_response): | ||
connexion_response = yield from connexion_response | ||
|
||
framework_response = api.get_response(connexion_response, mimetype, | ||
connexion_request) | ||
while asyncio.iscoroutine(framework_response): | ||
framework_response = yield from framework_response | ||
|
||
return framework_response | ||
|
||
return asyncio.coroutine(wrapper) | ||
|
||
|
||
def get_response_validator_wrapper(function, _wrapper): | ||
""" | ||
It is a wrapper used on `ResponseValidator` class. | ||
This function is located in an extra module because python2.7 don't | ||
support the 'yield from' syntax. This function is used to await | ||
the coroutines to connexion does the proper validation of parameters | ||
and responses. | ||
:rtype asyncio.coroutine | ||
""" | ||
@functools.wraps(function) | ||
def wrapper(request): | ||
response = function(request) | ||
while asyncio.iscoroutine(response): | ||
response = yield from response | ||
|
||
return _wrapper(request, response) | ||
|
||
return asyncio.coroutine(wrapper) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.