Skip to content

Commit

Permalink
Merge pull request #25 from JamalZeynalov/23-coverage-recorder-didnt-…
Browse files Browse the repository at this point in the history
…support-swagger-basepath

Add "base_path" listener parameter to support basePath
  • Loading branch information
JamalZeynalov authored Jul 27, 2023
2 parents 63fffaa + 01e3d37 commit 85a78ad
Show file tree
Hide file tree
Showing 3 changed files with 5 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
4 changes: 2 additions & 2 deletions swagger_coverage_py/uri.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
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.uri_params: dict = uri_params

0 comments on commit 85a78ad

Please sign in to comment.