-
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.
- Loading branch information
1 parent
582ec75
commit 3756b8b
Showing
62 changed files
with
6,806 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[run] | ||
omit = | ||
version.py | ||
*__init__* | ||
|
||
branch = True |
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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
# sublime-text | ||
*.sublime-* | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
|
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,13 @@ | ||
language: python | ||
python: | ||
- "3.5" | ||
- "3.6" | ||
services: | ||
- mysql | ||
- redis | ||
script: py.test -c pytest-travis.ini | ||
install: | ||
- pip install -r requirements.txt -r requirements-dev.txt | ||
- pip install coveralls | ||
after_success: | ||
- coveralls |
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,6 @@ | ||
include swaggerit/swagger_schema_extended.json | ||
include swaggerit/swagger_template.json | ||
include README.md | ||
include requirements.txt | ||
include requirements-dev.txt | ||
include version.py |
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,28 @@ | ||
# Sets the SWAGGERIT_DEV_HOME variable to your working directory | ||
# export SWAGGERIT_DEV_HOME=$HOME/dev/swaggerit | ||
|
||
|
||
function docker-compose-wrapper-swaggerit { | ||
docker-compose -f $SWAGGERIT_DEV_HOME/docker/docker-compose.yml "${@}" | ||
} | ||
|
||
|
||
function swaggerit-exec { | ||
docker-compose-wrapper-swaggerit exec swaggerit "${@}" | ||
} | ||
|
||
|
||
function swaggerit-up { | ||
docker-compose-wrapper-swaggerit up -d "${@}" | ||
} | ||
|
||
|
||
function swaggerit-kill { | ||
docker-compose-wrapper-swaggerit kill "${@}" | ||
} | ||
|
||
|
||
function swaggerit-tests { | ||
swaggerit-up &>/dev/null | ||
docker-compose-wrapper-swaggerit exec swaggerit run-tests "${@}" | ||
} |
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,9 @@ | ||
FROM python:3.6-alpine | ||
|
||
MAINTAINER Diogo Dutra <dutradda@gmail.com> | ||
RUN apk update && apk add bash alpine-sdk | ||
RUN git clone http://github.com/dutradda/swaggerit --branch forking_from_falcon_swagger_with_redis_async /tmp/swaggerit | ||
RUN pip install -r /tmp/swaggerit/requirements-dev.txt -r /tmp/swaggerit/requirements.txt | ||
RUN rm -rf /tmp/swaggerit | ||
ADD run_tests.sh /usr/bin/run-tests | ||
ENTRYPOINT /bin/bash |
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,25 @@ | ||
version: "2" | ||
services: | ||
mysql: | ||
image: wangxian/alpine-mysql | ||
container_name: swaggerit-mysql | ||
environment: | ||
MYSQL_ROOT_PASSWORD: root | ||
redis: | ||
image: redis:alpine | ||
container_name: swaggerit-redis | ||
swaggerit: | ||
build: . | ||
image: swaggerit | ||
container_name: swaggerit | ||
stdin_open: true | ||
tty: true | ||
depends_on: | ||
- mysql | ||
- redis | ||
links: | ||
- mysql:swaggerit-mysql | ||
- redis:swaggerit-redis | ||
volumes: | ||
- $SWAGGERIT_DEV_HOME:/swaggerit | ||
- $MYRECO_DEV_HOME:/myreco |
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,5 @@ | ||
#!/bin/bash | ||
|
||
cd /swaggerit | ||
pip install -r requirements-dev.txt -r requirements.txt | ||
py.test -c pytest-docker.ini $@ |
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,14 @@ | ||
{ | ||
"database": { | ||
"host": "swaggerit-mysql", | ||
"port": 3306, | ||
"user": "root", | ||
"password": "root", | ||
"database": "swaggerit_test" | ||
}, | ||
"redis": { | ||
"host": "swaggerit-redis", | ||
"port": 6379, | ||
"db": 0 | ||
} | ||
} |
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,2 @@ | ||
[pytest] | ||
addopts = --cov=swaggerit --no-cov-on-fail --exitfirst --variables pytest-docker-vars.json |
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,14 @@ | ||
{ | ||
"database": { | ||
"host": "localhost", | ||
"port": 3306, | ||
"user": "root", | ||
"password": null, | ||
"database": "swaggerit_test" | ||
}, | ||
"redis": { | ||
"host": "localhost", | ||
"port": 6379, | ||
"db": 0 | ||
} | ||
} |
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,2 @@ | ||
[pytest] | ||
addopts = --cov=swaggerit --no-cov-on-fail --exitfirst --variables pytest-travis-vars.json |
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,14 @@ | ||
{ | ||
"database": { | ||
"host": "localhost", | ||
"port": 3306, | ||
"user": "root", | ||
"password": "root", | ||
"database": "swaggerit_test" | ||
}, | ||
"redis": { | ||
"host": "localhost", | ||
"port": 6379, | ||
"db": 5 | ||
} | ||
} |
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,2 @@ | ||
[pytest] | ||
addopts = --cov=swaggerit --cov-report=html --no-cov-on-fail --exitfirst --variables pytest-vars.json |
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,7 @@ | ||
pytest==3.0.5 | ||
pytest-cov==2.4.0 | ||
pytest-variables[hjson]==1.4 | ||
pytest-aiohttp==0.1.3 | ||
ipython==5.1.0 | ||
PyMySQL==0.7.9 | ||
requests |
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,8 @@ | ||
SQLAlchemy==1.1.1 | ||
jsonschema==2.5.1 | ||
ujson==1.35 | ||
hiredis==0.2.0 | ||
aioredis==0.2.9 | ||
aiohttp==1.2.0 | ||
uvloop==0.7.1 | ||
https://github.com/dutradda/sanic/archive/master.tar.gz |
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,73 @@ | ||
# MIT License | ||
|
||
# Copyright (c) 2016 Diogo Dutra <dutradda@gmail.com> | ||
|
||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
|
||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
|
||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
|
||
|
||
from version import VERSION | ||
from setuptools import setup, find_packages | ||
|
||
|
||
long_description = '' | ||
|
||
|
||
install_requires = [] | ||
with open('requirements.txt') as requirements: | ||
install_requires = requirements.readlines()[:-1] | ||
|
||
|
||
tests_require = [] | ||
with open('requirements-dev.txt') as requirements_dev: | ||
tests_require = requirements_dev.readlines() | ||
|
||
|
||
setup( | ||
name='swaggerit', | ||
packages=find_packages('.'), | ||
include_package_data=True, | ||
version=VERSION, | ||
description='A Framework featuring Swagger, SQLAlchemy and Redis', | ||
long_description=long_description, | ||
author='Diogo Dutra', | ||
author_email='dutradda@gmail.com', | ||
url='https://github.com/dutradda/swaggerit', | ||
download_url='http://github.com/dutradda/swaggerit/archive/master.zip', | ||
license='MIT', | ||
keywords='framework swagger openapi sqlalchemy redis crud', | ||
setup_requires=[ | ||
'pytest-runner==2.9', | ||
'setuptools==28.3.0' | ||
], | ||
tests_require=tests_require, | ||
install_requires=install_requires, | ||
dependency_links=[ | ||
'https://github.com/dutradda/sanic/archive/master.tar.gz' | ||
], | ||
classifiers=[ | ||
'License :: OSI Approved :: MIT License', | ||
'Development Status :: 3 - Alpha', | ||
'Intended Audience :: Developers', | ||
'Natural Language :: English', | ||
'Programming Language :: Python :: 3.5', | ||
'Topic :: Internet :: WWW/HTTP :: WSGI :: Middleware', | ||
'Topic :: Database :: Front-Ends', | ||
'Topic :: Software Development :: Libraries :: Python Modules' | ||
] | ||
) |
Empty file.
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,64 @@ | ||
# MIT License | ||
|
||
# Copyright (c) 2016 Diogo Dutra <dutradda@gmail.com> | ||
|
||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
|
||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
|
||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
|
||
|
||
from swaggerit.api import SwaggerAPI | ||
from swaggerit.request import SwaggerRequest | ||
from aiohttp.web import Application, Response as AioHttpResponse | ||
from aiohttp.streams import EmptyStreamReader | ||
from urllib.parse import parse_qs | ||
import ujson | ||
|
||
|
||
class AioHttpAPI(SwaggerAPI, Application): | ||
|
||
def __init__(self, models, *, sqlalchemy_bind=None, redis_bind=None, | ||
swagger_json_template=None, title=None, version='1.0.0', | ||
authorizer=None, get_swagger_req_auth=True, loop=None): | ||
Application.__init__(self, loop=loop) | ||
SwaggerAPI.__init__(self, models, sqlalchemy_bind, redis_bind, swagger_json_template, | ||
title, version, authorizer, get_swagger_req_auth) | ||
|
||
def _set_handler_decorator(self, method): | ||
method = self._method_decorator(method) | ||
|
||
async def _method_wrapper(req): | ||
req = self._cast_request(req) | ||
resp = await method(req) | ||
return self._cast_response(resp) | ||
return _method_wrapper | ||
|
||
def _set_route(self, path, method, handler): | ||
self.router.add_route(method.upper(), path, handler) | ||
|
||
def _cast_request(self, req): | ||
query = {k: ','.join(v) for k, v in parse_qs(req.rel_url.query_string).items()} | ||
headers = {k.decode().lower(): v.decode() for k, v in req.raw_headers} | ||
body = None if isinstance(req.content, EmptyStreamReader) else req.content | ||
return SwaggerRequest( | ||
path_params=req.match_info, | ||
query=query, headers=headers, | ||
body=body) | ||
|
||
def _cast_response(self, resp): | ||
return AioHttpResponse(body=resp.body.encode(), status=resp.status_code, | ||
headers=resp.headers) |
Oops, something went wrong.