Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions swagger_coverage_py/reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __get_ignored_paths_from_config(self) -> List[str]:
return paths_to_ignore

def setup(
self, path_to_swagger_json: str, auth: object = None, cookies: dict = None
self, path_to_swagger_json: str, auth: object = None, cookies: dict = None
):
"""Setup all required attributes to generate report

Expand Down Expand Up @@ -80,14 +80,20 @@ def generate_report(self):
).exists(), (
f"No commandline tools is found in following locations:\n{cmd_path}\n"
)
command = [cmd_path, "-s", self.swagger_doc_file, "-i", self.output_dir]
if self.swagger_coverage_config:
command.extend(["-c", self.swagger_coverage_config])

# Adjust the file paths for Windows
if platform.system() == "Windows":
command = [arg.replace("/", "\\") for arg in command]

cmd_path_with_ext = f"{cmd_path}.bat"
assert Path(cmd_path_with_ext).exists(), f"File not found: {cmd_path_with_ext}"
command = [arg.replace("/", "\\") for arg in
[cmd_path_with_ext, "-s", self.swagger_doc_file, "-i", self.output_dir]]
# Adjust the file paths for Unix (Linux/MacOS)
else:
command = [cmd_path, "-s", self.swagger_doc_file, "-i", self.output_dir]

if self.swagger_coverage_config:
command.extend(["-c", self.swagger_coverage_config])

# Suppress all output if not in debug mode
if not DEBUG_MODE:
with open(os.devnull, 'w') as devnull:
Expand Down