Added tests and updated openapi3_parser.py

This commit is contained in:
Exterminator11
2023-10-15 17:00:54 +05:30
parent ddd938fd64
commit bd70e00f08
3 changed files with 159 additions and 6 deletions

View File

@@ -2,7 +2,10 @@ from urllib.parse import urlparse
from openapi_parser import parse
from base_parser import BaseParser
try:
from scripts.parser.file.base_parser import BaseParser
except:
from base_parser import BaseParser
class OpenAPI3Parser(BaseParser):
@@ -20,11 +23,12 @@ class OpenAPI3Parser(BaseParser):
def get_info_from_paths(self, path):
info = ""
for operation in path.operations:
info += (
f"\n{operation.method.value}="
f"{operation.responses[0].description}"
)
if(path.operations):
for operation in path.operations:
info += (
f"\n{operation.method.value}="
f"{operation.responses[0].description}"
)
return info
def parse_file(self, file_path):
@@ -42,5 +46,9 @@ class OpenAPI3Parser(BaseParser):
f"parameters: {path.parameters}\nmethods: {info}\n"
)
i += 1
if(i==2):
with open("reff.txt", "w") as f:
f.write(str(path))
with open("results.txt", "w") as f:
f.write(results)
return results