fix: code generators (#1985)
Co-authored-by: liyasthomas <liyascthomas@gmail.com>
This commit is contained in:
@@ -43,16 +43,11 @@ export const NodejsNativeCodegen = {
|
||||
let requestBody
|
||||
if (["POST", "PUT", "PATCH", "DELETE"].includes(method)) {
|
||||
requestBody = rawInput ? rawParams : rawRequestBody
|
||||
if (isJSONContentType(contentType)) {
|
||||
if (isJSONContentType(contentType) && requestBody) {
|
||||
requestBody = `JSON.stringify(${requestBody})`
|
||||
} else {
|
||||
} else if (requestBody) {
|
||||
requestBody = `\`${requestBody}\``
|
||||
}
|
||||
if (contentType) {
|
||||
genHeaders.push(
|
||||
` "Content-Type": "${contentType}; charset=utf-8",\n`
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (headers) {
|
||||
@@ -62,7 +57,7 @@ export const NodejsNativeCodegen = {
|
||||
}
|
||||
if (genHeaders.length > 0 || headers.length > 0) {
|
||||
requestString.push(
|
||||
` headers: {\n${genHeaders.join("").slice(0, -2)}\n }`
|
||||
` headers: {\n${genHeaders.join("").slice(0, -2)}\n }\n`
|
||||
)
|
||||
}
|
||||
requestString.push(`};\n\n`)
|
||||
|
||||
Reference in New Issue
Block a user