Skip to content

Commit

Permalink
Update get_swagger.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Pactortester authored Oct 7, 2021
1 parent 68df693 commit 4c448c7
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions swaggerjmx/get_swagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import requests
import json

import urllib3


def get_test_plan(swagger_url=None, swagger_url_json_path=None, swagger_json=None):
"""
Expand All @@ -20,7 +22,9 @@ def get_test_plan(swagger_url=None, swagger_url_json_path=None, swagger_json=Non
raise TypeError('Only one parameter can be passed!')

elif swagger_url is not None:
response = requests.get(swagger_url)
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
# requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
response = requests.get(swagger_url, verify=False)
data = json.loads(response.text, strict=False)

elif swagger_url_json_path is not None:
Expand Down Expand Up @@ -59,10 +63,14 @@ def get_test_plan(swagger_url=None, swagger_url_json_path=None, swagger_json=Non
else:
for param in sample_value.get("parameters"):
model_name = (param.get("name"))[0].upper() + (param.get("name"))[1:]
if model_name in list(definitions.keys()):
model_value = definitions.get(model_name)
for param_name, param_value in model_value.get("properties").items():
parameters[param_name] = "${" + param_name + "}"
# support YApi docs
try:
if model_name in list(definitions.keys()):
model_value = definitions.get(model_name)
for param_name, param_value in model_value.get("properties").items():
parameters[param_name] = "${" + param_name + "}"
except AttributeError:
pass
thread_group['sample'].append(
{"path": base_path + path_key, "method": method, "params": parameters,
"sampler_comments": sample_value.get("summary")})
Expand Down

0 comments on commit 4c448c7

Please sign in to comment.