diff --git a/swagger_ui/core.py b/swagger_ui/core.py index 8279371..d2fa13a 100644 --- a/swagger_ui/core.py +++ b/swagger_ui/core.py @@ -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 @@ -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, @@ -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}"'