http-content-parser 0.0.20__tar.gz → 0.0.21__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {http_content_parser-0.0.20 → http_content_parser-0.0.21}/PKG-INFO +1 -1
- {http_content_parser-0.0.20 → http_content_parser-0.0.21}/pyproject.toml +1 -1
- {http_content_parser-0.0.20 → http_content_parser-0.0.21}/src/http_content_parser/api_parser.py +51 -0
- {http_content_parser-0.0.20 → http_content_parser-0.0.21}/tests/test_api_model_parser.py +1 -1
- {http_content_parser-0.0.20 → http_content_parser-0.0.21}/.gitignore +0 -0
- {http_content_parser-0.0.20 → http_content_parser-0.0.21}/LICENSE +0 -0
- {http_content_parser-0.0.20 → http_content_parser-0.0.21}/README.md +0 -0
- {http_content_parser-0.0.20 → http_content_parser-0.0.21}/requirements.txt +0 -0
- {http_content_parser-0.0.20 → http_content_parser-0.0.21}/src/http_content_parser/__init__.py +0 -0
- {http_content_parser-0.0.20 → http_content_parser-0.0.21}/src/http_content_parser/curl_parser.py +0 -0
- {http_content_parser-0.0.20 → http_content_parser-0.0.21}/src/http_content_parser/generate_api_file.py +0 -0
- {http_content_parser-0.0.20 → http_content_parser-0.0.21}/src/http_content_parser/openapi_parser.py +0 -0
- {http_content_parser-0.0.20 → http_content_parser-0.0.21}/src/http_content_parser/param_util.py +0 -0
- {http_content_parser-0.0.20 → http_content_parser-0.0.21}/src/http_content_parser/postman_parser.py +0 -0
- {http_content_parser-0.0.20 → http_content_parser-0.0.21}/src/http_content_parser/req_data.py +0 -0
- {http_content_parser-0.0.20 → http_content_parser-0.0.21}/src/http_content_parser/swagger2_parser.py +0 -0
- {http_content_parser-0.0.20 → http_content_parser-0.0.21}/tests/test_curl.py +0 -0
{http_content_parser-0.0.20 → http_content_parser-0.0.21}/src/http_content_parser/api_parser.py
RENAMED
|
@@ -19,6 +19,15 @@ class ApiModelParser:
|
|
|
19
19
|
new_payload_list = self.__handle_duplicate_api_label(payload_list)
|
|
20
20
|
return new_payload_list
|
|
21
21
|
|
|
22
|
+
def get_api_list_for_curl(self, curl_file, curl_filter=None) -> list[dict]:
|
|
23
|
+
# convert curl
|
|
24
|
+
payload_list = self.convert_curl_data_to_list(
|
|
25
|
+
curl_file_path=curl_file, url_filter=curl_filter
|
|
26
|
+
)
|
|
27
|
+
# handle duplicate key
|
|
28
|
+
new_payload_list = self.__handle_duplicate_api_label_for_dict(payload_list)
|
|
29
|
+
return new_payload_list
|
|
30
|
+
|
|
22
31
|
def get_api_model_for_postman(self, json_dict: dict) -> list[ReqData]:
|
|
23
32
|
payload_list = self.convert_postman_to_model(postman_dict=json_dict)
|
|
24
33
|
# handle duplicate key
|
|
@@ -37,6 +46,34 @@ class ApiModelParser:
|
|
|
37
46
|
new_payload_list = self.__handle_duplicate_api_label(payload_list)
|
|
38
47
|
return new_payload_list
|
|
39
48
|
|
|
49
|
+
def convert_curl_data_to_list(
|
|
50
|
+
self, curl_file_path: str, url_filter=None
|
|
51
|
+
) -> list[dict]:
|
|
52
|
+
curl_parser = CurlParser()
|
|
53
|
+
payload_list = []
|
|
54
|
+
with open(curl_file_path, "rt") as f:
|
|
55
|
+
lines = f.readlines()
|
|
56
|
+
line_num_array = curl_parser.get_curl_line_num_scope(lines=lines)
|
|
57
|
+
for r in line_num_array:
|
|
58
|
+
res_dict = curl_parser.split_curl_to_struct(
|
|
59
|
+
lines, r[0], r[1], url_filter
|
|
60
|
+
)
|
|
61
|
+
req_list = res_dict
|
|
62
|
+
url_content = curl_parser.parse_url(req_list["original_url"])
|
|
63
|
+
req_list["temp_api_label"] = (
|
|
64
|
+
self.__replace_api_label_chars(url_content["path"][1:])
|
|
65
|
+
+ "_"
|
|
66
|
+
+ req_list["method"]
|
|
67
|
+
)
|
|
68
|
+
# req_list["header"] = json.dumps(req_list["header"])
|
|
69
|
+
if url_content["query_params"]:
|
|
70
|
+
req_list["query_param"] = json.dumps(url_content["query_params"])
|
|
71
|
+
else:
|
|
72
|
+
req_list["query_param"] = {}
|
|
73
|
+
req_list["path"] = url_content["path"][1:]
|
|
74
|
+
payload_list.append(req_list)
|
|
75
|
+
return payload_list
|
|
76
|
+
|
|
40
77
|
def convert_curl_data_to_model(
|
|
41
78
|
self, curl_file_path: str, url_filter=None
|
|
42
79
|
) -> list[ReqData]:
|
|
@@ -166,3 +203,17 @@ class ApiModelParser:
|
|
|
166
203
|
else:
|
|
167
204
|
key_filter[k] = 2
|
|
168
205
|
return new_payload_list
|
|
206
|
+
|
|
207
|
+
def __handle_duplicate_api_label_for_dict(
|
|
208
|
+
self, payload_list: list[dict]
|
|
209
|
+
) -> list[list]:
|
|
210
|
+
key_filter = {}
|
|
211
|
+
new_payload_list = copy.deepcopy(payload_list)
|
|
212
|
+
for payload, p_copy in zip(payload_list, new_payload_list):
|
|
213
|
+
k = payload["temp_api_label"]
|
|
214
|
+
if k in key_filter.keys():
|
|
215
|
+
p_copy["temp_api_label"] = k + "_" + str(key_filter[k])
|
|
216
|
+
key_filter[k] += 1
|
|
217
|
+
else:
|
|
218
|
+
key_filter[k] = 2
|
|
219
|
+
return new_payload_list
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{http_content_parser-0.0.20 → http_content_parser-0.0.21}/src/http_content_parser/__init__.py
RENAMED
|
File without changes
|
{http_content_parser-0.0.20 → http_content_parser-0.0.21}/src/http_content_parser/curl_parser.py
RENAMED
|
File without changes
|
|
File without changes
|
{http_content_parser-0.0.20 → http_content_parser-0.0.21}/src/http_content_parser/openapi_parser.py
RENAMED
|
File without changes
|
{http_content_parser-0.0.20 → http_content_parser-0.0.21}/src/http_content_parser/param_util.py
RENAMED
|
File without changes
|
{http_content_parser-0.0.20 → http_content_parser-0.0.21}/src/http_content_parser/postman_parser.py
RENAMED
|
File without changes
|
{http_content_parser-0.0.20 → http_content_parser-0.0.21}/src/http_content_parser/req_data.py
RENAMED
|
File without changes
|
{http_content_parser-0.0.20 → http_content_parser-0.0.21}/src/http_content_parser/swagger2_parser.py
RENAMED
|
File without changes
|
|
File without changes
|