Skip to content

Commit dadc55c

Browse files
Merge pull request #29 from Gallaecio/master
Support swagger_url=''
2 parents 6a50574 + afb5cdd commit dadc55c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

aiohttp_swagger/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ def setup_swagger(app: web.Application,
5050
_swagger_url = ("/{}".format(swagger_url)
5151
if not swagger_url.startswith("/")
5252
else swagger_url)
53-
_swagger_def_url = '{}/swagger.json'.format(_swagger_url)
53+
_base_swagger_url = _swagger_url.rstrip('/')
54+
_swagger_def_url = '{}/swagger.json'.format(_base_swagger_url)
5455

5556
# Build Swagget Info
5657
if swagger_info is None:
@@ -75,11 +76,12 @@ def setup_swagger(app: web.Application,
7576

7677
# Add API routes
7778
app.router.add_route('GET', _swagger_url, _swagger_home_func)
78-
app.router.add_route('GET', "{}/".format(_swagger_url), _swagger_home_func)
79+
app.router.add_route('GET', "{}/".format(_base_swagger_url),
80+
_swagger_home_func)
7981
app.router.add_route('GET', _swagger_def_url, _swagger_def_func)
8082

8183
# Set statics
82-
statics_path = '{}/swagger_static'.format(_swagger_url)
84+
statics_path = '{}/swagger_static'.format(_base_swagger_url)
8385
app.router.add_static(statics_path, STATIC_PATH)
8486

8587
# --------------------------------------------------------------------------

0 commit comments

Comments
 (0)