Skip to content

Commit ef122ca

Browse files
committed
Add "disable" option to skip requests recording
1 parent e09399a commit ef122ca

File tree

5 files changed

+24
-16
lines changed

5 files changed

+24
-16
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ pip install swagger-coverage
3737
API_DOCS_TYPE="swagger" # Note: "openapi" is default type of API docs
3838
API_DOCS_VERSION="2.0" # Note: "3.0.0" is default version of API docs
3939
API_DOCS_FORMAT="yaml" # Note: "json" is default format of API docs and output files
40+
IS_DISABLED=True # Skip requests recording. No files will be saved to 'swagger-coverage-output' dir
41+
4042
```
4143

4244
### 3. Add the session-scoped fixture

requirements.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
requests>=2.27.1
2-
Faker==13.3.3
3-
setuptools==61.0.0
1+
requests==2.28.1
2+
Faker==14.1.0
3+
setuptools==65.2.0
44
PyYAML~=6.0
5-
python-dotenv==0.20.0
6-
rootpath~=0.1.1
5+
python-dotenv~=0.20.0
6+
rootpath~=0.1.1
7+
environs==9.5.0

setup.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup(
77
name="swagger-coverage",
8-
version="2.2.4",
8+
version="2.2.5",
99
author="Jamal Zeinalov",
1010
author_email="jamal.zeynalov@gmail.com",
1111
description='Python adapter for "swagger-coverage" tool',
@@ -19,12 +19,13 @@
1919
"Operating System :: OS Independent",
2020
],
2121
install_requires=[
22-
"requests>=2.25.1",
23-
"Faker>=6.0.0",
24-
"setuptools>=53.0.0",
25-
"PyYAML",
26-
"python-dotenv~=0.16.0",
22+
"requests~=2.27.1",
23+
"Faker~=14.1.0",
24+
"setuptools~=65.2.0",
25+
"PyYAML~=6.0",
26+
"python-dotenv~=0.20.0",
2727
"rootpath~=0.1.1",
28+
"environs~=9.5.0",
2829

2930
],
3031
python_requires=">=3.6",

swagger_coverage_py/configs.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
import os
1+
from environs import Env
22

33
import rootpath
44
from dotenv import load_dotenv
55

66
load_dotenv(f"{rootpath.detect()}/.env")
7+
env = Env()
78

8-
API_DOCS_TYPE = os.environ.get("API_DOCS_TYPE", "openapi") # "swagger"
9-
API_DOCS_VERSION = os.environ.get("API_DOCS_VERSION", "3.0.0") # "2.0"
10-
API_DOCS_FORMAT = os.environ.get("API_DOCS_FORMAT", "json") # "yaml"
9+
API_DOCS_TYPE = env.st("API_DOCS_TYPE", default="openapi") # "swagger"
10+
API_DOCS_VERSION = env.st("API_DOCS_VERSION", default="3.0.0") # "2.0"
11+
API_DOCS_FORMAT = env.str("API_DOCS_FORMAT", default="json") # "yaml"
12+
IS_DISABLED = env.bool("API_COVERAGE_REPORTS_DISABLED", default=False) # If True then requests won't be recorded

swagger_coverage_py/listener.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import requests
22

3+
from swagger_coverage_py.configs import IS_DISABLED
34
from swagger_coverage_py.request_schema_handler import RequestSchemaHandler
45
from swagger_coverage_py.uri import URI
56

@@ -21,4 +22,5 @@ def __init__(
2122
self.__uri = URI(base_url, raw_path, **uri_params)
2223
self.response = requests.request(method, self.__uri.full, **kwargs)
2324

24-
RequestSchemaHandler(self.__uri, method, self.response, kwargs).write_schema()
25+
if not IS_DISABLED:
26+
RequestSchemaHandler(self.__uri, method, self.response, kwargs).write_schema()

0 commit comments

Comments
 (0)