Skip to content

Commit

Permalink
hotfix: codegen issue
Browse files Browse the repository at this point in the history
  • Loading branch information
0x0elliot committed Jun 11, 2024
1 parent 6d4c63c commit e8784fe
Showing 1 changed file with 21 additions and 22 deletions.
43 changes: 21 additions & 22 deletions codegen.go
Original file line number Diff line number Diff line change
Expand Up @@ -981,25 +981,25 @@ func GetCustomActionCode(swagger *openapi3.Swagger, api WorkflowApp) string{
return parsed_queries
def prepare_response(self, request):
try:
parsedheaders = {}
for key, value in request.headers.items():
parsedheaders[key] = value
def prepare_response(self, request):
try:
parsedheaders = {}
for key, value in request.headers.items():
parsedheaders[key] = value
cookies = {}
if request.cookies:
for key, value in request.cookies.items():
cookies[key] = value
cookies = {}
if request.cookies:
for key, value in request.cookies.items():
cookies[key] = value
jsondata = request.text
try:
jsondata = json.loads(jsondata)
except:
pass
jsondata = request.text
try:
jsondata = json.loads(jsondata)
except:
pass
parseddata = {
parseddata = {
"status": request.status_code,
"body": jsondata,
"url": request.url,
Expand All @@ -1008,10 +1008,10 @@ func GetCustomActionCode(swagger *openapi3.Swagger, api WorkflowApp) string{
"success": True,
}
return json.dumps(parseddata)
except Exception as e:
print(f"[WARNING] Failed in request: {e}")
return request.text
return json.dumps(parseddata)
except Exception as e:
print(f"[WARNING] Failed in request: {e}")
return request.text
def custom_action(self%s, method="", url="", headers="", queries="", path="", ssl_verify=False, body=""):
url = self.fix_url(url)
Expand Down Expand Up @@ -1042,10 +1042,9 @@ func GetCustomActionCode(swagger *openapi3.Swagger, api WorkflowApp) string{
return {"error: Invalid JSON format for request body"}
try:
response = requests.request(method, url, headers=parsed_headers, params=parsed_queries, data=body, verify=ssl_verify%s)
#response.raise_for_status()
response = requests.request(method, url, headers=parsed_headers, params=parsed_queries, data=body, verify=ssl_verify%s) #response.raise_for_status()
return self.prepare_response(response)
return self.prepare_response(response)
except requests.RequestException as e:
self.logger.error(f"Request failed: {e}")
Expand Down

0 comments on commit e8784fe

Please sign in to comment.