Skip to content

Commit a6a95ea

Browse files
committed
Adding a line breaker after each snippet part, remove a slash in graphQl body parsing
1 parent ed71946 commit a6a95ea

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

codegens/r-httr/lib/rHttr.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const getOptions = require('./options').getOptions,
1111
* @returns {string} the snippet headers (uses)
1212
*/
1313
function getSnippetHeader () {
14-
return 'library(httr)\n';
14+
return 'library(httr)\n\n';
1515
}
1616

1717
/**
@@ -133,7 +133,7 @@ function getSnippetHeaders (headers, indentation) {
133133
if (headers.length > 0) {
134134
headers = headers.filter((header) => { return !header.disabled; });
135135
headers = groupHeadersSameKey(headers);
136-
return `headers = ${getSnippetArray(headers, indentation, true)}\n`;
136+
return `headers = ${getSnippetArray(headers, indentation, true)}\n\n`;
137137
}
138138
return '';
139139
}
@@ -178,7 +178,7 @@ function getSnippetFromMethod (url, hasParams, hasHeaders, methodUC, mode, reque
178178
timeoutSnippet = requestTimeout ? `, timeout(${requestTimeout})` : '';
179179

180180
return `res <- VERB("${methodUC}", url = "${url}"` +
181-
`${paramsSnippet}${headersSnippet}${encodeSnippet}${timeoutSnippet})\n`;
181+
`${paramsSnippet}${headersSnippet}${encodeSnippet}${timeoutSnippet})\n\n`;
182182
}
183183

184184
/**

codegens/r-httr/lib/util/parseBody.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,10 @@ function parseGraphQL (body, bodyTrim) {
218218
catch (e) {
219219
graphqlVariables = {};
220220
}
221-
bodySnippet = `'${sanitizeString(JSON.stringify({
222-
query: query,
223-
variables: graphqlVariables
224-
}), bodyTrim)}'`;
221+
bodySnippet = `'${sanitizeString(`{
222+
query: ${query},
223+
variables: ${graphqlVariables}
224+
}`, bodyTrim)}'`;
225225
return bodySnippet;
226226
}
227227

@@ -238,27 +238,27 @@ function processBodyModes (body, indentation, bodyTrim, contentType) {
238238
switch (body.mode) {
239239
case 'urlencoded': {
240240
bodySnippet = parseURLEncodedBody(body.urlencoded, indentation, bodyTrim);
241-
return bodySnippet === '' ? '' : `body = ${bodySnippet}\n`;
241+
return bodySnippet === '' ? '' : `body = ${bodySnippet}\n\n`;
242242
}
243243
case 'raw': {
244244
bodySnippet = parseRawBody(body.raw, indentation, bodyTrim, contentType);
245-
return bodySnippet === '' ? '' : `body = ${bodySnippet}\n`;
245+
return bodySnippet === '' ? '' : `body = ${bodySnippet}\n\n`;
246246
}
247247
case 'graphql': {
248248
bodySnippet = parseGraphQL(body.graphql, bodyTrim);
249-
return bodySnippet === '' ? '' : `body = ${bodySnippet}\n`;
249+
return bodySnippet === '' ? '' : `body = ${bodySnippet}\n\n`;
250250
}
251251
case 'formdata': {
252252
bodySnippet = parseFormData(body.formdata, indentation, bodyTrim);
253-
return bodySnippet === '' ? '' : `body = ${bodySnippet}\n`;
253+
return bodySnippet === '' ? '' : `body = ${bodySnippet}\n\n`;
254254
}
255255
case 'file': {
256256
bodySnippet = parseFromFile();
257-
return bodySnippet === '' ? '' : `body = upload_file(${bodySnippet})\n`;
257+
return bodySnippet === '' ? '' : `body = upload_file(${bodySnippet})\n\n`;
258258
}
259259
default: {
260260
bodySnippet = parseRawBody(body.raw, indentation, bodyTrim, contentType);
261-
return bodySnippet === '' ? '' : `body = ${bodySnippet}\n`;
261+
return bodySnippet === '' ? '' : `body = ${bodySnippet}\n\n`;
262262
}
263263
}
264264
}

0 commit comments

Comments
 (0)