From 7ce6279c574b324f5a9a1c5ee5d7d162afe8baa5 Mon Sep 17 00:00:00 2001 From: tzh <2375626546@qq.com> Date: Fri, 8 Mar 2019 11:02:43 +0800 Subject: [PATCH 1/6] fix class based view --- aiohttp_swagger/__init__.py | 11 +++++++---- aiohttp_swagger/helpers/builders.py | 3 ++- setup.py | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/aiohttp_swagger/__init__.py b/aiohttp_swagger/__init__.py index 828dc28..b22dda5 100644 --- a/aiohttp_swagger/__init__.py +++ b/aiohttp_swagger/__init__.py @@ -1,4 +1,5 @@ import asyncio +import re from os.path import abspath, dirname, join from types import FunctionType @@ -91,12 +92,14 @@ def setup_swagger(app: web.Application, # -------------------------------------------------------------------------- app["SWAGGER_DEF_CONTENT"] = swagger_info with open(join(STATIC_PATH, "index.html"), "r") as f: + SWAGGER_CONFIG_STR = '/{}{}'.format(api_base_url, _swagger_def_url) + SWAGGER_CONFIG_STR = re.sub(r'/+', '/', SWAGGER_CONFIG_STR) + STATIC_PATH_STR = '/{}{}'.format(api_base_url, statics_path) + STATIC_PATH_STR = re.sub(r'/+', '/', STATIC_PATH_STR) app["SWAGGER_TEMPLATE_CONTENT"] = ( f.read() - .replace("##SWAGGER_CONFIG##", '/{}{}'. - format(api_base_url.lstrip('/'), _swagger_def_url)) - .replace("##STATIC_PATH##", '/{}{}'. - format(api_base_url.lstrip('/'), statics_path)) + .replace("##SWAGGER_CONFIG##", SWAGGER_CONFIG_STR) + .replace("##STATIC_PATH##", STATIC_PATH_STR) ) diff --git a/aiohttp_swagger/helpers/builders.py b/aiohttp_swagger/helpers/builders.py index e8bbdc0..9e87971 100644 --- a/aiohttp_swagger/helpers/builders.py +++ b/aiohttp_swagger/helpers/builders.py @@ -1,3 +1,4 @@ +import inspect from collections import defaultdict from os.path import abspath, dirname, join @@ -40,7 +41,7 @@ def _build_doc_from_func_doc(route): out = {} - if issubclass(route.handler, web.View) and route.method == METH_ANY: + if inspect.isclass(route.handler) and issubclass(route.handler, web.View) and route.method == METH_ANY: method_names = { attr for attr in dir(route.handler) \ if attr.upper() in METH_ALL diff --git a/setup.py b/setup.py index 4c7ca06..b59e052 100755 --- a/setup.py +++ b/setup.py @@ -55,7 +55,7 @@ def run(self): setup( name='aiohttp-swagger', - version='1.0.5', + version='1.0.6', install_requires=required, url='https://github.com/cr0hn/aiohttp-swagger', license='BSD', From 278144f2923abe74a2d10be814aa6c27e264116b Mon Sep 17 00:00:00 2001 From: tzh <2375626546@qq.com> Date: Fri, 8 Mar 2019 11:29:52 +0800 Subject: [PATCH 2/6] change python version --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0b339e2..38a6ff6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,9 @@ language: python sudo: false python: - - "3.4" - "3.5" - "3.6" + - "3.7" install: - python setup.py install From 752b922c4baba5a76c58488dbccc57796d7eaf26 Mon Sep 17 00:00:00 2001 From: tzh <2375626546@qq.com> Date: Fri, 8 Mar 2019 11:41:03 +0800 Subject: [PATCH 3/6] change pytest version --- .travis.yml | 12 ++++++------ requirements-dev.txt | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 38a6ff6..41b5248 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,12 +19,12 @@ after_success: deploy: # Deploy to PyPI - provider: pypi - user: $PYPI_USER - password: $PYPI_PASSWD - distributions: "sdist" - on: - branch: master + # provider: pypi + # user: $PYPI_USER + # password: $PYPI_PASSWD + # distributions: "sdist" + # on: + # branch: master # - provider: script # script: deploy/pypi.sh diff --git a/requirements-dev.txt b/requirements-dev.txt index 3cd18a0..6709407 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,5 +1,5 @@ -r requirements.txt -pytest +pytest~=4.3.0 pytest-cov pytest-aiohttp flake8 \ No newline at end of file From 134adcc128a9069cea0896f0c2ffc44d03fbd43d Mon Sep 17 00:00:00 2001 From: tzh <2375626546@qq.com> Date: Fri, 8 Mar 2019 12:41:38 +0800 Subject: [PATCH 4/6] add attrs --- requirements-dev.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements-dev.txt b/requirements-dev.txt index 6709407..28314a4 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,5 +1,6 @@ -r requirements.txt pytest~=4.3.0 +attrs~=18.2.0 pytest-cov pytest-aiohttp flake8 \ No newline at end of file From f5de7beaebc3345d75e96f0925dba073de4d76eb Mon Sep 17 00:00:00 2001 From: tzh <2375626546@qq.com> Date: Fri, 8 Mar 2019 12:43:50 +0800 Subject: [PATCH 5/6] change --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 41b5248..d635f7b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ language: python +dist: xenial sudo: false python: - "3.5" From 30c9fb6a506e4a796676679a93b6ae06b70f03da Mon Sep 17 00:00:00 2001 From: tzh <2375626546@qq.com> Date: Fri, 8 Mar 2019 12:58:27 +0800 Subject: [PATCH 6/6] rollback --- .travis.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index d635f7b..da56428 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,12 +20,12 @@ after_success: deploy: # Deploy to PyPI - # provider: pypi - # user: $PYPI_USER - # password: $PYPI_PASSWD - # distributions: "sdist" - # on: - # branch: master + provider: pypi + user: $PYPI_USER + password: $PYPI_PASSWD + distributions: "sdist" + on: + branch: master # - provider: script # script: deploy/pypi.sh