From db7fb708098bde542f401152bc5fd95b715c1a7a Mon Sep 17 00:00:00 2001 From: Jamal Date: Thu, 27 Jul 2023 13:41:31 +0300 Subject: [PATCH 1/2] Add "base_path" listener parameter to support basePath --- setup.py | 2 +- swagger_coverage_py/listener.py | 4 ++-- swagger_coverage_py/uri.py | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index 602145b..c49d3ed 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name="swagger-coverage", - version="3.2.0", + version="3.3.0", author="Jamal Zeinalov", author_email="jamal.zeynalov@gmail.com", description='Python adapter for "swagger-coverage" tool', diff --git a/swagger_coverage_py/listener.py b/swagger_coverage_py/listener.py index 6edaa9b..dd66cd8 100644 --- a/swagger_coverage_py/listener.py +++ b/swagger_coverage_py/listener.py @@ -7,7 +7,7 @@ class CoverageListener: def __init__( - self, method: str, base_url: str, raw_path: str, uri_params: dict, **kwargs + self, method: str, base_url: str, raw_path: str, uri_params: dict, base_path: str = "", **kwargs ): """Records an HTTP request as a file in swagger format @@ -19,7 +19,7 @@ def __init__( :param kwargs: Optional arguments that are applicable for appropriate request of "requests" library. (e.g. "auth", "headers", "cookies", etc.) """ - self.__uri = URI(base_url, raw_path, **uri_params) + self.__uri = URI(base_url, base_path, raw_path, **uri_params) self.response = requests.request(method, self.__uri.full, **kwargs) if not IS_DISABLED: diff --git a/swagger_coverage_py/uri.py b/swagger_coverage_py/uri.py index e150a6e..b8a72b9 100644 --- a/swagger_coverage_py/uri.py +++ b/swagger_coverage_py/uri.py @@ -1,7 +1,8 @@ class URI: - def __init__(self, host: str, unformatted_path: str, **uri_params): + def __init__(self, host: str, base_path, unformatted_path: str, **uri_params): self.host = host - self.formatted = unformatted_path.format(**uri_params) + self.formatted = base_path + unformatted_path.format(**uri_params) self.full = f"{self.host}{self.formatted}" self.raw = unformatted_path + self.base_path = base_path self.uri_params: dict = uri_params From 01e3d37730961102ccdc6fc602e4b8ea08f130f2 Mon Sep 17 00:00:00 2001 From: Jamal Date: Thu, 27 Jul 2023 14:06:22 +0300 Subject: [PATCH 2/2] remove redundant line --- swagger_coverage_py/uri.py | 1 - 1 file changed, 1 deletion(-) diff --git a/swagger_coverage_py/uri.py b/swagger_coverage_py/uri.py index b8a72b9..3e89df8 100644 --- a/swagger_coverage_py/uri.py +++ b/swagger_coverage_py/uri.py @@ -4,5 +4,4 @@ def __init__(self, host: str, base_path, unformatted_path: str, **uri_params): self.formatted = base_path + unformatted_path.format(**uri_params) self.full = f"{self.host}{self.formatted}" self.raw = unformatted_path - self.base_path = base_path self.uri_params: dict = uri_params