Started fixing requestbody in openapi3

This commit is contained in:
frikky
2020-05-30 14:06:13 +02:00
parent 34db3d9588
commit 611dcae8b3
3 changed files with 23 additions and 12 deletions
+19 -9
View File
@@ -272,7 +272,7 @@ const AppCreator = (props) => {
return response.json()
})
.then((responseJson) => {
setIsAppLoaded(true)
setIsAppLoaded(true)
if (!responseJson.success) {
alert.error("Failed to get the app")
} else {
@@ -346,10 +346,8 @@ const AppCreator = (props) => {
setDescription(data.info.description)
document.title = "Apps - "+data.info.title
console.log(data.info["x-logo"])
if (data.info !== null && data.info !== undefined && data.info["x-logo"] !== undefined) {
setFileBase64(data.info["x-logo"])
console.log("IMG: ", data.inf0["x-logo"])
}
if (data.info.contact != undefined) {
@@ -360,8 +358,6 @@ const AppCreator = (props) => {
setBaseUrl(data.servers[0].url)
}
// This is annoying (:
var securitySchemes = data.components.securityDefinitions
if (securitySchemes === undefined) {
@@ -396,6 +392,8 @@ const AppCreator = (props) => {
}
}
console.log(data)
// FIXME - headers?
var newActions = []
for (let [path, pathvalue] of Object.entries(data.paths)) {
@@ -412,6 +410,7 @@ const AppCreator = (props) => {
"errors": [],
}
for (var key in methodvalue.parameters) {
const parameter = methodvalue.parameters[key]
if (parameter.in === "query") {
@@ -450,7 +449,6 @@ const AppCreator = (props) => {
const host = splitBase[2]
const schemes = [splitBase[0]]
const basePath = "/"+(splitBase.slice(3, )).join("/")
console.log("IMAGE: ", fileBase64)
const data = {
"swagger": "3.0",
@@ -557,19 +555,32 @@ const AppCreator = (props) => {
}
if (item.body.length > 0) {
console.log("HANDLE BODY!")
const required = false
newitem = {
"in": "body",
"name": "body",
"multiline": true,
"description": "Generated by shuffler.io OpenAPI",
"required": false,
"required": required,
"example": item.body,
"schema": {
"type": "string",
},
}
// FIXME - add application/json if JSON example?
data.paths[item.url][item.method.toLowerCase()]["requestBody"] = {
"description": "Generated by Shuffler.io",
"required": required,
"content": {
"example": {
"example": "test",
},
},
}
console.log(data.paths[item.url][item.method.toLowerCase()])
data.paths[item.url][item.method.toLowerCase()].parameters.push(newitem)
}
}
@@ -615,7 +626,6 @@ const AppCreator = (props) => {
setErrorCode(responseJson.reason)
alert.error("Failed to verify: ")
} else {
// Return?
alert.success("Successfully uploaded openapi")
//window.location = "/apps"
}