diff --git a/.travis.yml b/.travis.yml index 0b339e2..da56428 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,10 @@ language: python +dist: xenial sudo: false python: - - "3.4" - "3.5" - "3.6" + - "3.7" install: - python setup.py install 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/requirements-dev.txt b/requirements-dev.txt index 3cd18a0..28314a4 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,5 +1,6 @@ -r requirements.txt -pytest +pytest~=4.3.0 +attrs~=18.2.0 pytest-cov pytest-aiohttp flake8 \ No newline at end of file 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',