Skip to content

Commit dc8866f

Browse files
committed
use URLSearchParams native node function
1 parent 1a10f49 commit dc8866f

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

modules/swagger-codegen/src/main/resources/Javascript/ApiClient.mustache

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
(function(root, factory) {
33
if (typeof define === 'function' && define.amd) {
44
// AMD. Register as an anonymous module.
5-
define(['superagent', 'querystring'], factory);
5+
define(['superagent'], factory);
66
} else if (typeof module === 'object' && module.exports) {
77
// CommonJS-like environments that support module.exports, like Node.
8-
module.exports = factory(require('superagent'), require('querystring'));
8+
module.exports = factory(require('superagent'));
99
} else {
1010
// Browser globals (root is window)
1111
if (!root.{{moduleName}}) {
1212
root.{{moduleName}} = {};
1313
}
14-
root.{{moduleName}}.ApiClient = factory(root.superagent, root.querystring);
14+
root.{{moduleName}}.ApiClient = factory(root.superagent);
1515
}
16-
}(this, function(superagent, querystring) {
16+
}(this, function(superagent) {
1717
'use strict';
1818
1919
{{#emitJSDoc}} /**
@@ -432,7 +432,8 @@
432432
}
433433

434434
if (contentType === 'application/x-www-form-urlencoded') {
435-
request.send(querystring.stringify(this.normalizeParams(formParams)));
435+
const searchParams = new URLSearchParams(this.normalizeParams(formParams));
436+
request.send(searchParams.toString());
436437
} else if (contentType == 'multipart/form-data') {
437438
var _formParams = this.normalizeParams(formParams);
438439
for (var key in _formParams) {

modules/swagger-codegen/src/main/resources/Javascript/es6/ApiClient.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{{>licenseInfo}}
22
import superagent from "superagent";
3-
import querystring from "querystring";
43

54
{{#emitJSDoc}}/**
65
* @module {{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}ApiClient
@@ -420,7 +419,8 @@ export class ApiClient {
420419
}
421420

422421
if (contentType === 'application/x-www-form-urlencoded') {
423-
request.send(querystring.stringify(this.normalizeParams(formParams)));
422+
const searchParams = new URLSearchParams(this.normalizeParams(formParams));
423+
request.send(searchParams.toString());
424424
} else if (contentType == 'multipart/form-data') {
425425
var _formParams = this.normalizeParams(formParams);
426426
for (var key in _formParams) {

modules/swagger-codegen/src/main/resources/Javascript/package.mustache

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
"fs": false
1212
},
1313
"dependencies": {
14-
"superagent": "3.7.0",
15-
"querystring": "0.2.0"
14+
"superagent": "3.7.0"
1615
},
1716
"devDependencies": {
1817
"mocha": "~2.3.4",

0 commit comments

Comments
 (0)