From b8b729b2bc2f4113fda1035f784adc1514827735 Mon Sep 17 00:00:00 2001 From: Ondrej Lichtner Date: Tue, 13 Sep 2022 12:14:54 +0200 Subject: [PATCH] paths: fix Operation request urljoin When adding operation `path` to the base_url, the use of the `+` operator can lead to doubling of `/` characters if the base_url ends with a `/`. Using urljoin should fix this. This is also a cleaner way to work with url paths. Signed-off-by: Ondrej Lichtner --- openapi3/paths.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openapi3/paths.py b/openapi3/paths.py index decb404..3956adf 100644 --- a/openapi3/paths.py +++ b/openapi3/paths.py @@ -4,8 +4,10 @@ try: from urllib.parse import urlencode + from urllib.parse import urljoin except ImportError: from urllib import urlencode + from urlparse import urljoin from .errors import SpecError, UnexpectedResponseError from .object_base import ObjectBase @@ -310,7 +312,7 @@ def request(self, base_url, security={}, data=None, parameters={}, verify=True, self._request = requests.Request(self.path[-1]) # Set self._request.url to base_url w/ path - self._request.url = base_url + self.path[-2] + self._request.url = urljoin(base_url, self.path[-2]) if security and self.security: security_requirement = None