#120: Fixed double query parsing
This commit is contained in:
@@ -245,8 +245,6 @@ func buildStructure(swagger *openapi3.Swagger, curHash string) (string, error) {
|
|||||||
// This function generates the python code that's being used.
|
// This function generates the python code that's being used.
|
||||||
// This is really meta when you program it. Handling parameters is hard here.
|
// This is really meta when you program it. Handling parameters is hard here.
|
||||||
func makePythoncode(swagger *openapi3.Swagger, name, url, method string, parameters, optionalQueries, headers []string) (string, string) {
|
func makePythoncode(swagger *openapi3.Swagger, name, url, method string, parameters, optionalQueries, headers []string) (string, string) {
|
||||||
log.Printf("makePythoncode URL: %s", url)
|
|
||||||
|
|
||||||
method = strings.ToLower(method)
|
method = strings.ToLower(method)
|
||||||
queryString := ""
|
queryString := ""
|
||||||
queryData := ""
|
queryData := ""
|
||||||
@@ -256,11 +254,14 @@ func makePythoncode(swagger *openapi3.Swagger, name, url, method string, paramet
|
|||||||
if len(optionalQueries) > 0 {
|
if len(optionalQueries) > 0 {
|
||||||
queryString += ", "
|
queryString += ", "
|
||||||
for _, query := range optionalQueries {
|
for _, query := range optionalQueries {
|
||||||
|
// Check if it's a part of the URL already
|
||||||
queryString += fmt.Sprintf("%s=\"\", ", query)
|
queryString += fmt.Sprintf("%s=\"\", ", query)
|
||||||
queryData += fmt.Sprintf(`
|
queryData += fmt.Sprintf(`
|
||||||
if %s:
|
if %s:
|
||||||
url += f"&%s={%s}"`, query, query, query)
|
url += f"&%s={%s}"`, query, query, query)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
log.Printf("No optional queries?")
|
||||||
}
|
}
|
||||||
|
|
||||||
// api.Authentication.Parameters[0].Value = "BearerAuth"
|
// api.Authentication.Parameters[0].Value = "BearerAuth"
|
||||||
@@ -942,6 +943,10 @@ func handleConnect(swagger *openapi3.Swagger, api WorkflowApp, extraParameters [
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if strings.Contains(baseUrl, fmt.Sprintf("{%s}", param.Value.Name)) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if firstQuery {
|
if firstQuery {
|
||||||
baseUrl = fmt.Sprintf("%s?%s={%s}", baseUrl, param.Value.Name, param.Value.Name)
|
baseUrl = fmt.Sprintf("%s?%s={%s}", baseUrl, param.Value.Name, param.Value.Name)
|
||||||
} else {
|
} else {
|
||||||
@@ -1087,6 +1092,10 @@ func handleGet(swagger *openapi3.Swagger, api WorkflowApp, extraParameters []Wor
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if strings.Contains(baseUrl, fmt.Sprintf("{%s}", param.Value.Name)) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if firstQuery {
|
if firstQuery {
|
||||||
baseUrl = fmt.Sprintf("%s?%s={%s}", baseUrl, param.Value.Name, param.Value.Name)
|
baseUrl = fmt.Sprintf("%s?%s={%s}", baseUrl, param.Value.Name, param.Value.Name)
|
||||||
} else {
|
} else {
|
||||||
@@ -1230,6 +1239,10 @@ func handleHead(swagger *openapi3.Swagger, api WorkflowApp, extraParameters []Wo
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if strings.Contains(baseUrl, fmt.Sprintf("{%s}", param.Value.Name)) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if firstQuery {
|
if firstQuery {
|
||||||
baseUrl = fmt.Sprintf("%s?%s={%s}", baseUrl, param.Value.Name, param.Value.Name)
|
baseUrl = fmt.Sprintf("%s?%s={%s}", baseUrl, param.Value.Name, param.Value.Name)
|
||||||
} else {
|
} else {
|
||||||
@@ -1374,6 +1387,10 @@ func handleDelete(swagger *openapi3.Swagger, api WorkflowApp, extraParameters []
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if strings.Contains(baseUrl, fmt.Sprintf("{%s}", param.Value.Name)) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if firstQuery {
|
if firstQuery {
|
||||||
baseUrl = fmt.Sprintf("%s?%s={%s}", baseUrl, param.Value.Name, param.Value.Name)
|
baseUrl = fmt.Sprintf("%s?%s={%s}", baseUrl, param.Value.Name, param.Value.Name)
|
||||||
} else {
|
} else {
|
||||||
@@ -1517,6 +1534,10 @@ func handlePost(swagger *openapi3.Swagger, api WorkflowApp, extraParameters []Wo
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if strings.Contains(baseUrl, fmt.Sprintf("{%s}", param.Value.Name)) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if firstQuery {
|
if firstQuery {
|
||||||
baseUrl = fmt.Sprintf("%s?%s={%s}", baseUrl, param.Value.Name, param.Value.Name)
|
baseUrl = fmt.Sprintf("%s?%s={%s}", baseUrl, param.Value.Name, param.Value.Name)
|
||||||
} else {
|
} else {
|
||||||
@@ -1660,6 +1681,10 @@ func handlePatch(swagger *openapi3.Swagger, api WorkflowApp, extraParameters []W
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if strings.Contains(baseUrl, fmt.Sprintf("{%s}", param.Value.Name)) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if firstQuery {
|
if firstQuery {
|
||||||
baseUrl = fmt.Sprintf("%s?%s={%s}", baseUrl, param.Value.Name, param.Value.Name)
|
baseUrl = fmt.Sprintf("%s?%s={%s}", baseUrl, param.Value.Name, param.Value.Name)
|
||||||
} else {
|
} else {
|
||||||
@@ -1803,6 +1828,10 @@ func handlePut(swagger *openapi3.Swagger, api WorkflowApp, extraParameters []Wor
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if strings.Contains(baseUrl, fmt.Sprintf("{%s}", param.Value.Name)) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if firstQuery {
|
if firstQuery {
|
||||||
baseUrl = fmt.Sprintf("%s?%s={%s}", baseUrl, param.Value.Name, param.Value.Name)
|
baseUrl = fmt.Sprintf("%s?%s={%s}", baseUrl, param.Value.Name, param.Value.Name)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import Tooltip from '@material-ui/core/Tooltip';
|
|||||||
import CheckCircleIcon from '@material-ui/icons/CheckCircle';
|
import CheckCircleIcon from '@material-ui/icons/CheckCircle';
|
||||||
import Breadcrumbs from '@material-ui/core/Breadcrumbs';
|
import Breadcrumbs from '@material-ui/core/Breadcrumbs';
|
||||||
import AppsIcon from '@material-ui/icons/Apps';
|
import AppsIcon from '@material-ui/icons/Apps';
|
||||||
|
import CircularProgress from '@material-ui/core/CircularProgress';
|
||||||
|
|
||||||
import ErrorOutline from '@material-ui/icons/ErrorOutline';
|
import ErrorOutline from '@material-ui/icons/ErrorOutline';
|
||||||
import { useAlert } from "react-alert";
|
import { useAlert } from "react-alert";
|
||||||
@@ -210,6 +211,7 @@ const AppCreator = (props) => {
|
|||||||
const [, setBasedata] = React.useState({})
|
const [, setBasedata] = React.useState({})
|
||||||
const [actions, setActions] = useState([])
|
const [actions, setActions] = useState([])
|
||||||
const [errorCode, setErrorCode] = useState("")
|
const [errorCode, setErrorCode] = useState("")
|
||||||
|
const [appBuilding, setAppBuilding] = useState(false)
|
||||||
|
|
||||||
//const [actions, setActions] = useState([{
|
//const [actions, setActions] = useState([{
|
||||||
// "name": "Get workflows",
|
// "name": "Get workflows",
|
||||||
@@ -524,6 +526,7 @@ const AppCreator = (props) => {
|
|||||||
// Saving the app that's been configured.
|
// Saving the app that's been configured.
|
||||||
const submitApp = () => {
|
const submitApp = () => {
|
||||||
alert.info("Uploading and building app " + name)
|
alert.info("Uploading and building app " + name)
|
||||||
|
setAppBuilding(true)
|
||||||
setErrorCode("")
|
setErrorCode("")
|
||||||
|
|
||||||
// Format the information
|
// Format the information
|
||||||
@@ -717,6 +720,7 @@ const AppCreator = (props) => {
|
|||||||
if (authenticationOption === "API key") {
|
if (authenticationOption === "API key") {
|
||||||
if (parameterName.length === 0) {
|
if (parameterName.length === 0) {
|
||||||
alert.error("A field name for the APIkey must be defined")
|
alert.error("A field name for the APIkey must be defined")
|
||||||
|
setAppBuilding(false)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -756,6 +760,7 @@ const AppCreator = (props) => {
|
|||||||
// throw new Error("NOT 200 :O")
|
// throw new Error("NOT 200 :O")
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
setAppBuilding(false)
|
||||||
return response.json()
|
return response.json()
|
||||||
})
|
})
|
||||||
.then((responseJson) => {
|
.then((responseJson) => {
|
||||||
@@ -1705,10 +1710,10 @@ const AppCreator = (props) => {
|
|||||||
{testView}
|
{testView}
|
||||||
*/}
|
*/}
|
||||||
|
|
||||||
<Button color="primary" variant="contained" style={{borderRadius: "0px", marginTop: "30px", height: "50px",}} onClick={() => {
|
<Button disabled={appBuilding} color="primary" variant="contained" style={{borderRadius: "0px", marginTop: "30px", height: "50px",}} onClick={() => {
|
||||||
submitApp()
|
submitApp()
|
||||||
}}>
|
}}>
|
||||||
Save
|
{appBuilding ? <CircularProgress /> : "Save"}
|
||||||
</Button>
|
</Button>
|
||||||
{errorCode.length > 0 ? `Error: ${errorCode}` : null}
|
{errorCode.length > 0 ? `Error: ${errorCode}` : null}
|
||||||
</Paper>
|
</Paper>
|
||||||
|
|||||||
Reference in New Issue
Block a user