Skip to content

Commit

Permalink
Add "base_path" listener parameter to support basePath
Browse files Browse the repository at this point in the history
  • Loading branch information
JamalZeynalov committed Jul 27, 2023
1 parent 63fffaa commit db7fb70
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name="swagger-coverage",
version="3.2.0",
version="3.3.0",
author="Jamal Zeinalov",
author_email="[email protected]",
description='Python adapter for "swagger-coverage" tool',
Expand Down
4 changes: 2 additions & 2 deletions swagger_coverage_py/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions swagger_coverage_py/uri.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit db7fb70

Please sign in to comment.