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