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

Changed absolute static prefix to relative #43

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
12 changes: 10 additions & 2 deletions swagger_ui/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __init__(self,
self.parameters = copy.deepcopy(_DefaultSwaggerUIBundleParameters)
if parameters:
self.parameters.update(parameters)
self.parameters["url"] = "\"{}\"".format(self.swagger_json_uri_absolute)
self.set_swagger_url()

# oauth2_config
self.oauth2_config = oauth2_config
Expand All @@ -79,8 +79,10 @@ def static_dir(self):

@property
def doc_html(self):
prefix_split = self.url_prefix.split("/")
static_location = prefix_split.pop()
return self.env.get_template('doc.html').render(
url_prefix=self.url_prefix,
url_prefix=static_location,
title=self.title,
config_url=self.swagger_json_uri_absolute,
parameters=self.parameters,
Expand Down Expand Up @@ -162,3 +164,9 @@ def match(name):
if handler:
return handler
return None

def set_swagger_url(self):
"""Set relative swagger url."""
split_path = self.swagger_json_uri_absolute.split("/")
swagger_url_relative = "/".join(split_path[-2:])
self.parameters["url"] = f'"{swagger_url_relative}"'