Fixed app creation, RE: json issue

This commit is contained in:
frikky
2020-06-16 17:50:28 +02:00
parent 8ea19ea530
commit d087a53bd6
6 changed files with 49 additions and 18 deletions
+3 -9
View File
@@ -339,14 +339,7 @@ func makePythoncode(swagger *openapi3.Swagger, name, url, method string, paramet
bodyAddin = ", data=body"
// FIXME: Does JSON data work?
bodyFormatter = `
if (body.startswith("{") and body.endswith("}")) or (body.startswith("[") and body.endswith("]")):
try:
body = json.dumps(body)
except:
pass
`
break
bodyFormatter = `body = " ".join(body.strip().split())`
}
}
@@ -375,13 +368,14 @@ func makePythoncode(swagger *openapi3.Swagger, name, url, method string, paramet
// Extra param for url if it's changeable
// Extra param for authentication scheme(s)
// The last weird one is the body.. Tabs & spaces sucks.
data := fmt.Sprintf(` async def %s(self%s%s%s%s%s%s):
%s
url=f"%s%s"
%s
%s
%s
%s
%s
return requests.%s(url, headers=headers%s%s%s).text
`,
functionname,