Skip to content

Commit 28dc190

Browse files
Add parameter dynamic_url
1 parent afdab20 commit 28dc190

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

flask_apidoc/apidoc.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,14 @@ class ApiDoc(object):
2626
ApiDoc hosts the apidoc files in a specified url.
2727
"""
2828

29-
def __init__(self, folder_path=None, url_path=None, app=None):
29+
def __init__(self, folder_path=None, url_path=None, dynamic_url=True, app=None):
3030
"""
3131
Initializes a new instance of ApiDoc.
3232
33-
:param folder_path: the folder with apidoc files. Defaults to the 'docs' folder in the flask static folder.
34-
:param url_path: the url path for the apidoc files. Defaults to the '/docs'.
35-
:param app: the flask application.
33+
:param folder_path: The folder with apidoc files. Defaults to the 'docs' folder in the flask static folder.
34+
:param url_path: The url path for the apidoc files. Defaults to the '/docs'.
35+
:param dynamic_url: Set `True` to replace all the urls in ApiDoc files by the current url.
36+
:param app: The flask application.
3637
"""
3738

3839
self.folder_path = folder_path
@@ -44,6 +45,8 @@ def __init__(self, folder_path=None, url_path=None, app=None):
4445
if self.url_path is None:
4546
self.url_path = '/docs'
4647

48+
self.dynamic_url = dynamic_url
49+
4750
self.app = None
4851

4952
if app:
@@ -78,7 +81,7 @@ def __send_static_file(self, path=None):
7881

7982
# the api_project.js has the absolute url
8083
# hard coded so we replace them by the current url.
81-
if path == 'api_project.js':
84+
if self.dynamic_url and path == 'api_project.js':
8285
return self.__send_api_file(file_name)
8386

8487
# Any other apidoc file is treated as a normal static file

0 commit comments

Comments
 (0)