fix: missing '?' in query parameter string for code generators
This commit is contained in:
@@ -24,7 +24,7 @@ export const CLibcurlCodegen = {
|
||||
`curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "${method}");`
|
||||
)
|
||||
requestString.push(
|
||||
`curl_easy_setopt(hnd, CURLOPT_URL, "${url}${pathName}${queryString}");`
|
||||
`curl_easy_setopt(hnd, CURLOPT_URL, "${url}${pathName}?${queryString}");`
|
||||
)
|
||||
requestString.push(`struct curl_slist *headers = NULL;`)
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ export const CsRestsharpCodegen = {
|
||||
// create client and request
|
||||
requestString.push(`var client = new RestClient("${url}");\n\n`)
|
||||
requestString.push(
|
||||
`var request = new RestRequest("${pathName}${queryString}", ${requestDataFormat});\n\n`
|
||||
`var request = new RestRequest("${pathName}?${queryString}", ${requestDataFormat});\n\n`
|
||||
)
|
||||
|
||||
// authentification
|
||||
|
||||
@@ -19,7 +19,7 @@ export const CurlCodegen = {
|
||||
}) => {
|
||||
const requestString = []
|
||||
requestString.push(`curl -X ${method}`)
|
||||
requestString.push(` '${url}${pathName}${queryString}'`)
|
||||
requestString.push(` '${url}${pathName}?${queryString}'`)
|
||||
if (auth === "Basic Auth") {
|
||||
const basic = `${httpUser}:${httpPassword}`
|
||||
requestString.push(
|
||||
|
||||
@@ -25,7 +25,7 @@ export const GoNativeCodegen = {
|
||||
const requestBody = rawInput ? rawParams : rawRequestBody
|
||||
if (method === "GET") {
|
||||
requestString.push(
|
||||
`req, err := http.NewRequest("${method}", "${url}${pathName}${queryString}")\n`
|
||||
`req, err := http.NewRequest("${method}", "${url}${pathName}?${queryString}")\n`
|
||||
)
|
||||
}
|
||||
if (["POST", "PUT", "PATCH", "DELETE"].includes(method)) {
|
||||
@@ -33,11 +33,11 @@ export const GoNativeCodegen = {
|
||||
if (isJSONContentType(contentType)) {
|
||||
requestString.push(`var reqBody = []byte(\`${requestBody}\`)\n\n`)
|
||||
requestString.push(
|
||||
`req, err := http.NewRequest("${method}", "${url}${pathName}${queryString}", bytes.NewBuffer(reqBody))\n`
|
||||
`req, err := http.NewRequest("${method}", "${url}${pathName}?${queryString}", bytes.NewBuffer(reqBody))\n`
|
||||
)
|
||||
} else if (contentType.includes("x-www-form-urlencoded")) {
|
||||
requestString.push(
|
||||
`req, err := http.NewRequest("${method}", "${url}${pathName}${queryString}", strings.NewReader("${requestBody}"))\n`
|
||||
`req, err := http.NewRequest("${method}", "${url}${pathName}?${queryString}", strings.NewReader("${requestBody}"))\n`
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ export const JavaOkhttpCodegen = {
|
||||
}
|
||||
|
||||
requestString.push("Request request = new Request.Builder()")
|
||||
requestString.push(`.url("${url}${pathName}${queryString}")`)
|
||||
requestString.push(`.url("${url}${pathName}?${queryString}")`)
|
||||
|
||||
if (["POST", "PUT", "PATCH", "DELETE"].includes(method)) {
|
||||
requestString.push(`.method("${method}", body)`)
|
||||
|
||||
@@ -32,7 +32,7 @@ export const JavaUnirestCodegen = {
|
||||
// create client and request
|
||||
const verb = verbs.find((v) => v.verb === method)
|
||||
requestString.push(
|
||||
`HttpResponse<String> response = Unirest.${verb.unirestMethod}("${url}${pathName}${queryString}")\n`
|
||||
`HttpResponse<String> response = Unirest.${verb.unirestMethod}("${url}${pathName}?${queryString}")\n`
|
||||
)
|
||||
if (auth === "Basic Auth") {
|
||||
const basic = `${httpUser}:${httpPassword}`
|
||||
|
||||
@@ -21,7 +21,7 @@ export const JavascriptFetchCodegen = {
|
||||
}) => {
|
||||
const requestString = []
|
||||
let genHeaders = []
|
||||
requestString.push(`fetch("${url}${pathName}${queryString}", {\n`)
|
||||
requestString.push(`fetch("${url}${pathName}?${queryString}", {\n`)
|
||||
requestString.push(` method: "${method}",\n`)
|
||||
if (auth === "Basic Auth") {
|
||||
const basic = `${httpUser}:${httpPassword}`
|
||||
|
||||
@@ -21,7 +21,7 @@ export const JavascriptJqueryCodegen = {
|
||||
const genHeaders = []
|
||||
|
||||
requestString.push(
|
||||
`jQuery.ajax({\n url: "${url}${pathName}${queryString}"`
|
||||
`jQuery.ajax({\n url: "${url}${pathName}?${queryString}"`
|
||||
)
|
||||
requestString.push(`,\n method: "${method.toUpperCase()}"`)
|
||||
const requestBody = rawInput ? rawParams : rawRequestBody
|
||||
|
||||
@@ -25,7 +25,7 @@ export const JavascriptXhrCodegen = {
|
||||
const user = auth === "Basic Auth" ? `'${httpUser}'` : null
|
||||
const password = auth === "Basic Auth" ? `'${httpPassword}'` : null
|
||||
requestString.push(
|
||||
`xhr.open('${method}', '${url}${pathName}${queryString}', true, ${user}, ${password})`
|
||||
`xhr.open('${method}', '${url}${pathName}?${queryString}', true, ${user}, ${password})`
|
||||
)
|
||||
if (auth === "Bearer Token" || auth === "OAuth 2.0") {
|
||||
requestString.push(
|
||||
|
||||
@@ -22,7 +22,7 @@ export const NodejsAxiosCodegen = {
|
||||
const requestBody = rawInput ? rawParams : rawRequestBody
|
||||
|
||||
requestString.push(
|
||||
`axios.${method.toLowerCase()}('${url}${pathName}${queryString}'`
|
||||
`axios.${method.toLowerCase()}('${url}${pathName}?${queryString}'`
|
||||
)
|
||||
if (requestBody.length !== 0) {
|
||||
requestString.push(", ")
|
||||
|
||||
@@ -24,7 +24,7 @@ export const NodejsNativeCodegen = {
|
||||
|
||||
requestString.push(`const http = require('http');\n\n`)
|
||||
|
||||
requestString.push(`const url = '${url}${pathName}${queryString}';\n`)
|
||||
requestString.push(`const url = '${url}${pathName}?${queryString}';\n`)
|
||||
|
||||
requestString.push(`const options = {\n`)
|
||||
requestString.push(` method: '${method}',\n`)
|
||||
|
||||
@@ -25,7 +25,7 @@ export const NodejsRequestCodegen = {
|
||||
requestString.push(`const request = require('request');\n`)
|
||||
requestString.push(`const options = {\n`)
|
||||
requestString.push(` method: '${method.toLowerCase()}',\n`)
|
||||
requestString.push(` url: '${url}${pathName}${queryString}'`)
|
||||
requestString.push(` url: '${url}${pathName}?${queryString}'`)
|
||||
|
||||
if (auth === "Basic Auth") {
|
||||
const basic = `${httpUser}:${httpPassword}`
|
||||
|
||||
@@ -25,7 +25,7 @@ export const NodejsUnirestCodegen = {
|
||||
requestString.push(`const unirest = require('unirest');\n`)
|
||||
requestString.push(`const req = unirest(\n`)
|
||||
requestString.push(
|
||||
`'${method.toLowerCase()}', '${url}${pathName}${queryString}')\n`
|
||||
`'${method.toLowerCase()}', '${url}${pathName}?${queryString}')\n`
|
||||
)
|
||||
|
||||
if (auth === "Basic Auth") {
|
||||
|
||||
@@ -25,7 +25,7 @@ export const PhpCurlCodegen = {
|
||||
requestString.push(`<?php\n`)
|
||||
requestString.push(`$curl = curl_init();\n`)
|
||||
requestString.push(`curl_setopt_array($curl, array(\n`)
|
||||
requestString.push(` CURLOPT_URL => "${url}${pathName}${queryString}",\n`)
|
||||
requestString.push(` CURLOPT_URL => "${url}${pathName}?${queryString}",\n`)
|
||||
requestString.push(` CURLOPT_RETURNTRANSFER => true,\n`)
|
||||
requestString.push(` CURLOPT_ENCODING => "",\n`)
|
||||
requestString.push(` CURLOPT_MAXREDIRS => 10,\n`)
|
||||
|
||||
@@ -26,7 +26,7 @@ export const PowershellRestmethodCodegen = {
|
||||
let variables = ""
|
||||
|
||||
requestString.push(
|
||||
`Invoke-RestMethod -Method '${formattedMethod}' -Uri '${url}${pathName}${queryString}'`
|
||||
`Invoke-RestMethod -Method '${formattedMethod}' -Uri '${url}${pathName}?${queryString}'`
|
||||
)
|
||||
const requestBody = rawInput ? rawParams : rawRequestBody
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ export const PythonHttpClientCodegen = {
|
||||
}
|
||||
}
|
||||
requestString.push(
|
||||
`conn.request("${method}", "${pathName}${queryString}", payload, headers)\n`
|
||||
`conn.request("${method}", "${pathName}?${queryString}", payload, headers)\n`
|
||||
)
|
||||
requestString.push(`res = conn.getresponse()\n`)
|
||||
requestString.push(`data = res.read()\n`)
|
||||
|
||||
@@ -31,7 +31,7 @@ export const PythonRequestsCodegen = {
|
||||
const genHeaders = []
|
||||
|
||||
requestString.push(`import requests\n\n`)
|
||||
requestString.push(`url = '${url}${pathName}${queryString}'\n`)
|
||||
requestString.push(`url = '${url}${pathName}?${queryString}'\n`)
|
||||
|
||||
// auth headers
|
||||
if (auth === "Basic Auth") {
|
||||
@@ -58,7 +58,7 @@ export const PythonRequestsCodegen = {
|
||||
requestString.push(...printHeaders(genHeaders))
|
||||
requestString.push(`response = requests.request(\n`)
|
||||
requestString.push(` '${method}',\n`)
|
||||
requestString.push(` '${url}${pathName}${queryString}',\n`)
|
||||
requestString.push(` '${url}${pathName}?${queryString}',\n`)
|
||||
}
|
||||
if (["POST", "PUT", "PATCH", "DELETE"].includes(method)) {
|
||||
genHeaders.push(`'Content-Type': '${contentType}'`)
|
||||
@@ -83,7 +83,7 @@ export const PythonRequestsCodegen = {
|
||||
}
|
||||
requestString.push(`response = requests.request(\n`)
|
||||
requestString.push(` '${method}',\n`)
|
||||
requestString.push(` '${url}${pathName}${queryString}',\n`)
|
||||
requestString.push(` '${url}${pathName}?${queryString}',\n`)
|
||||
requestString.push(` data=data,\n`)
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ export const RubyNetHttpCodeGen = {
|
||||
|
||||
// create URI and request
|
||||
const verb = verbs.find((v) => v.verb === method)
|
||||
requestString.push(`uri = URI.parse('${url}${pathName}${queryString}')\n`)
|
||||
requestString.push(`uri = URI.parse('${url}${pathName}?${queryString}')\n`)
|
||||
requestString.push(`request = Net::HTTP::${verb.rbMethod}.new(uri)`)
|
||||
|
||||
// content type
|
||||
|
||||
@@ -30,7 +30,7 @@ export const SalesforceApexCodegen = {
|
||||
requestString.push(`HttpRequest request = new HttpRequest();\n`)
|
||||
requestString.push(`request.setMethod('${method}');\n`)
|
||||
requestString.push(
|
||||
`request.setEndpoint('${url}${pathName}${queryString}');\n\n`
|
||||
`request.setEndpoint('${url}${pathName}?${queryString}');\n\n`
|
||||
)
|
||||
|
||||
// authentification
|
||||
|
||||
@@ -37,7 +37,7 @@ export const ShellHttpieCodegen = {
|
||||
}
|
||||
|
||||
// URL
|
||||
let escapedUrl = `${url}${pathName}${queryString}`
|
||||
let escapedUrl = `${url}${pathName}?${queryString}`
|
||||
escapedUrl = escapedUrl.replace(/'/g, "\\'")
|
||||
requestString.push(` ${method} $'${escapedUrl}'`)
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ export const ShellWgetCodegen = {
|
||||
}) => {
|
||||
const requestString = []
|
||||
requestString.push(`wget -O - --method=${method}`)
|
||||
requestString.push(` '${url}${pathName}${queryString}'`)
|
||||
requestString.push(` '${url}${pathName}?${queryString}'`)
|
||||
if (auth === "Basic Auth") {
|
||||
const basic = `${httpUser}:${httpPassword}`
|
||||
requestString.push(
|
||||
|
||||
Reference in New Issue
Block a user