mirror of
https://github.com/hoshikawa2/OCI_API_Gateway_Automation2.git
synced 2026-03-06 02:10:36 +00:00
Correção dos casos:
- Setando como path_prefix o titulo da API ocasiona erro pois o titulo contem espacos em branco
This commit is contained in:
Binary file not shown.
@@ -48,6 +48,51 @@ def find_base_path(strPath):
|
|||||||
base_path = "/" + base_path
|
base_path = "/" + base_path
|
||||||
return base_path
|
return base_path
|
||||||
|
|
||||||
|
def has_path_endpoint(endPoint):
|
||||||
|
endPointAux = endPoint.replace("//", "#")
|
||||||
|
endPointSplited = endPointAux.split('/')
|
||||||
|
if (len(endPointSplited) > 1):
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
def find_base_pathendpoint(endPoint, strPath):
|
||||||
|
base_path = strPath.split('/')[1]
|
||||||
|
if (len(base_path) == 0 and has_path_endpoint(endPoint)):
|
||||||
|
endPointAux = endPoint.replace("//", "#")
|
||||||
|
endPointSplited = endPointAux.split('/')
|
||||||
|
if (len(endPointSplited) > 1):
|
||||||
|
endPointSplitedStr = endPointSplited[1]
|
||||||
|
if (endPointSplitedStr != None):
|
||||||
|
base_path = "/" + endPointSplitedStr
|
||||||
|
else:
|
||||||
|
base_path = strPath
|
||||||
|
else:
|
||||||
|
base_path = strPath
|
||||||
|
else:
|
||||||
|
endPointAux = endPoint.replace("//", "#")
|
||||||
|
endPointSplited = endPointAux.split('/')
|
||||||
|
if (len(endPointSplited) > 1):
|
||||||
|
endPointSplitedStr = endPointSplited[1]
|
||||||
|
if (endPointSplitedStr != None):
|
||||||
|
base_path = "/" + endPointSplitedStr
|
||||||
|
endPoint = endPointSplited[0].replace("#", "//")
|
||||||
|
else:
|
||||||
|
base_path = "/" + base_path
|
||||||
|
else:
|
||||||
|
base_path = "/" + base_path
|
||||||
|
return base_path
|
||||||
|
|
||||||
|
|
||||||
|
def find_base_endpoint(endPoint):
|
||||||
|
endPointAux = endPoint.replace("//", "#")
|
||||||
|
endPointSplited = endPointAux.split('/')
|
||||||
|
if (len(endPointSplited) > 1):
|
||||||
|
endPointSplitedStr = endPointSplited[1]
|
||||||
|
if (endPointSplitedStr != None):
|
||||||
|
endPoint = endPointSplited[0].replace("#", "//")
|
||||||
|
return endPoint
|
||||||
|
|
||||||
def find_path(strPath):
|
def find_path(strPath):
|
||||||
base_path = strPath.split('/')
|
base_path = strPath.split('/')
|
||||||
if (len(base_path) == 0):
|
if (len(base_path) == 0):
|
||||||
@@ -358,7 +403,7 @@ def verify_path(json_data_list):
|
|||||||
'TYPE': item2["TYPE"],
|
'TYPE': item2["TYPE"],
|
||||||
'ENVIRONMENT': item2["ENVIRONMENT"],
|
'ENVIRONMENT': item2["ENVIRONMENT"],
|
||||||
'METHOD': item2["METHOD"],
|
'METHOD': item2["METHOD"],
|
||||||
'PATH_PREFIX': "/" + item2["API_NAME"],
|
'PATH_PREFIX': "/",
|
||||||
'PATH': item2["PATH_PREFIX"],
|
'PATH': item2["PATH_PREFIX"],
|
||||||
'ENDPOINT': item2["ENDPOINT"],
|
'ENDPOINT': item2["ENDPOINT"],
|
||||||
'SCHEMA_BODY_VALIDATION': item2["SCHEMA_BODY_VALIDATION"],
|
'SCHEMA_BODY_VALIDATION': item2["SCHEMA_BODY_VALIDATION"],
|
||||||
@@ -409,15 +454,21 @@ def process_api_spec(api_id, compartmentId, environment, swagger, functionId, ho
|
|||||||
|
|
||||||
json_data_list = []
|
json_data_list = []
|
||||||
|
|
||||||
|
endPointOrigin = endPoint
|
||||||
for spec in api_spec["routes"]:
|
for spec in api_spec["routes"]:
|
||||||
status = spec["backend"]["status"]
|
status = spec["backend"]["status"]
|
||||||
|
specPath = spec["path"]
|
||||||
|
if (has_path_endpoint(endPointOrigin)):
|
||||||
|
endPoint = find_base_endpoint(endPointOrigin)
|
||||||
|
specPath = (find_base_pathendpoint(endPointOrigin, specPath) + spec["path"]).replace("//", "/")
|
||||||
|
|
||||||
if (version == "3"):
|
if (version == "3"):
|
||||||
fullEndpoint = (endPoint + find_base_path(spec["path"]) + find_path(spec["path"])).replace("{", "${request.path[").replace("}", "]}")
|
fullEndpoint = (endPoint + find_base_path(specPath) + find_path(specPath)).replace("{", "${request.path[").replace("}", "]}")
|
||||||
FULL_PATH = spec["path"]
|
FULL_PATH = specPath
|
||||||
ENDPOINT = fullEndpoint
|
ENDPOINT = fullEndpoint
|
||||||
PATH = find_path(spec["path"])
|
PATH = find_path(specPath)
|
||||||
PATH_PREFIX = find_base_path(spec["path"])
|
PATH_PREFIX = find_base_path(specPath)
|
||||||
METHOD = accMethods(api_spec["routes"], PATH, status)
|
METHOD = accMethods(api_spec["routes"], find_path(spec["path"]), status)
|
||||||
else:
|
else:
|
||||||
schemes = ""
|
schemes = ""
|
||||||
try:
|
try:
|
||||||
@@ -649,5 +700,4 @@ def handler(ctx, data: io.BytesIO = None):
|
|||||||
ctx,
|
ctx,
|
||||||
status_code=401,
|
status_code=401,
|
||||||
response_data=json.dumps({"active": False, "wwwAuthenticate": jsonData})
|
response_data=json.dumps({"active": False, "wwwAuthenticate": jsonData})
|
||||||
)
|
)
|
||||||
|
|
||||||
Reference in New Issue
Block a user