http-content-parser 0.0.14__tar.gz → 0.0.16__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.14 → http_content_parser-0.0.16}/PKG-INFO +2 -2
- {http_content_parser-0.0.14 → http_content_parser-0.0.16}/pyproject.toml +1 -1
- {http_content_parser-0.0.14 → http_content_parser-0.0.16}/src/http_content_parser/generate_api_file.py +16 -3
- {http_content_parser-0.0.14 → http_content_parser-0.0.16}/tests/test_curl.py +5 -9
- {http_content_parser-0.0.14 → http_content_parser-0.0.16}/.gitignore +0 -0
- {http_content_parser-0.0.14 → http_content_parser-0.0.16}/LICENSE +0 -0
- {http_content_parser-0.0.14 → http_content_parser-0.0.16}/README.md +0 -0
- {http_content_parser-0.0.14 → http_content_parser-0.0.16}/requirements.txt +0 -0
- {http_content_parser-0.0.14 → http_content_parser-0.0.16}/src/http_content_parser/__init__.py +0 -0
- {http_content_parser-0.0.14 → http_content_parser-0.0.16}/src/http_content_parser/curl_parser.py +0 -0
- {http_content_parser-0.0.14 → http_content_parser-0.0.16}/src/http_content_parser/openapi_parser.py +0 -0
- {http_content_parser-0.0.14 → http_content_parser-0.0.16}/src/http_content_parser/param_util.py +0 -0
- {http_content_parser-0.0.14 → http_content_parser-0.0.16}/src/http_content_parser/postman_parser.py +0 -0
- {http_content_parser-0.0.14 → http_content_parser-0.0.16}/src/http_content_parser/req_data.py +0 -0
- {http_content_parser-0.0.14 → http_content_parser-0.0.16}/src/http_content_parser/swagger2_parser.py +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# -*- coding: UTF-8 -*-
|
|
2
|
+
import copy
|
|
2
3
|
import json
|
|
3
4
|
import re
|
|
4
5
|
|
|
@@ -40,11 +41,23 @@ class GenerateApiFile:
|
|
|
40
41
|
payload_list = self.convert_curl_data_to_model(
|
|
41
42
|
curl_file_path=curl_file, curl_filter=curl_filter
|
|
42
43
|
)
|
|
44
|
+
# handle duplicate key
|
|
45
|
+
new_payload_list = self.handle_duplicate_yaml_key(payload_list)
|
|
43
46
|
# write to yaml
|
|
44
|
-
for payload in
|
|
47
|
+
for payload in new_payload_list:
|
|
45
48
|
self.write_api_content_to_yaml(yaml_file, payload)
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
|
|
50
|
+
def handle_duplicate_yaml_key(self, payload_list: list[ReqData]) -> list[ReqData]:
|
|
51
|
+
key_filter = {}
|
|
52
|
+
new_payload_list = copy.deepcopy(payload_list)
|
|
53
|
+
for payload, p_copy in zip(payload_list, new_payload_list):
|
|
54
|
+
k = payload.temp_api_label
|
|
55
|
+
if k in key_filter.keys():
|
|
56
|
+
p_copy.temp_api_label = k + "_" + str(key_filter[k])
|
|
57
|
+
key_filter[k] += 1
|
|
58
|
+
else:
|
|
59
|
+
key_filter[k] = 1
|
|
60
|
+
return new_payload_list
|
|
48
61
|
|
|
49
62
|
def convert_curl_data_to_model(
|
|
50
63
|
self, curl_file_path, curl_filter=None
|
|
@@ -13,14 +13,10 @@ class TestCases:
|
|
|
13
13
|
# with open("./postman.json", "r") as f:
|
|
14
14
|
# json_dict = json.load(f)
|
|
15
15
|
# gaf.produce_api_yaml_for_postman(json_dict, "./test.yaml")
|
|
16
|
-
curl_file =
|
|
17
|
-
res = gaf.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
print(r.body)
|
|
21
|
-
print('header is: \n')
|
|
22
|
-
print(r.header)
|
|
23
|
-
|
|
16
|
+
curl_file = ""
|
|
17
|
+
res = gaf.produce_api_yaml_for_curl(
|
|
18
|
+
curl_file=curl_file, yaml_file="api.yaml"
|
|
19
|
+
)
|
|
24
20
|
|
|
25
21
|
def test_for(self):
|
|
26
22
|
# c = 1
|
|
@@ -34,4 +30,4 @@ class TestCases:
|
|
|
34
30
|
temp = '{ "job_id":{{job_id}}, "product_id": 4, "local_user_id": 0}'
|
|
35
31
|
temp = json.dumps(data)
|
|
36
32
|
temp = json.loads(temp)
|
|
37
|
-
print(temp)
|
|
33
|
+
print(temp)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{http_content_parser-0.0.14 → http_content_parser-0.0.16}/src/http_content_parser/__init__.py
RENAMED
|
File without changes
|
{http_content_parser-0.0.14 → http_content_parser-0.0.16}/src/http_content_parser/curl_parser.py
RENAMED
|
File without changes
|
{http_content_parser-0.0.14 → http_content_parser-0.0.16}/src/http_content_parser/openapi_parser.py
RENAMED
|
File without changes
|
{http_content_parser-0.0.14 → http_content_parser-0.0.16}/src/http_content_parser/param_util.py
RENAMED
|
File without changes
|
{http_content_parser-0.0.14 → http_content_parser-0.0.16}/src/http_content_parser/postman_parser.py
RENAMED
|
File without changes
|
{http_content_parser-0.0.14 → http_content_parser-0.0.16}/src/http_content_parser/req_data.py
RENAMED
|
File without changes
|
{http_content_parser-0.0.14 → http_content_parser-0.0.16}/src/http_content_parser/swagger2_parser.py
RENAMED
|
File without changes
|