Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix class based view #59

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
language: python
dist: xenial
sudo: false
python:
- "3.4"
- "3.5"
- "3.6"
- "3.7"

install:
- python setup.py install
Expand Down
11 changes: 7 additions & 4 deletions aiohttp_swagger/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncio
import re
from os.path import abspath, dirname, join
from types import FunctionType

Expand Down Expand Up @@ -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)
)


Expand Down
3 changes: 2 additions & 1 deletion aiohttp_swagger/helpers/builders.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import inspect
from collections import defaultdict
from os.path import abspath, dirname, join

Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-r requirements.txt
pytest
pytest~=4.3.0
attrs~=18.2.0
pytest-cov
pytest-aiohttp
flake8
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down