forked from loafle/openapi-generator-original
[JS] set option to true by default, update samples (#20003)
* set option to true by default, update samples * update doc
This commit is contained in:
parent
ae4e2515dc
commit
b66b7af5d0
@ -43,7 +43,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
|||||||
|sourceFolder|source folder for generated code| |src|
|
|sourceFolder|source folder for generated code| |src|
|
||||||
|useInheritance|use JavaScript prototype chains & delegation for inheritance| |true|
|
|useInheritance|use JavaScript prototype chains & delegation for inheritance| |true|
|
||||||
|usePromises|use Promises as return values from the client API, instead of superagent callbacks| |false|
|
|usePromises|use Promises as return values from the client API, instead of superagent callbacks| |false|
|
||||||
|useURLSearchParams|use JS build-in UrlSearchParams, instead of deprecated npm lib 'querystring'| |false|
|
|useURLSearchParams|use JS build-in UrlSearchParams, instead of deprecated npm lib 'querystring'| |true|
|
||||||
|
|
||||||
## IMPORT MAPPING
|
## IMPORT MAPPING
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
protected boolean useES6 = true; // default is ES6
|
protected boolean useES6 = true; // default is ES6
|
||||||
@Setter protected String npmRepository = null;
|
@Setter protected String npmRepository = null;
|
||||||
@Getter private String modelPropertyNaming = "camelCase";
|
@Getter private String modelPropertyNaming = "camelCase";
|
||||||
@Setter protected boolean useURLSearchParams = false;
|
@Setter protected boolean useURLSearchParams = true;
|
||||||
|
|
||||||
public JavascriptClientCodegen() {
|
public JavascriptClientCodegen() {
|
||||||
super();
|
super();
|
||||||
@ -194,7 +194,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
cliOptions.add(new CliOption(NPM_REPOSITORY, "Use this property to set an url your private npmRepo in the package.json"));
|
cliOptions.add(new CliOption(NPM_REPOSITORY, "Use this property to set an url your private npmRepo in the package.json"));
|
||||||
cliOptions.add(new CliOption(USE_URL_SEARCH_PARAMS,
|
cliOptions.add(new CliOption(USE_URL_SEARCH_PARAMS,
|
||||||
"use JS build-in UrlSearchParams, instead of deprecated npm lib 'querystring'")
|
"use JS build-in UrlSearchParams, instead of deprecated npm lib 'querystring'")
|
||||||
.defaultValue(Boolean.FALSE.toString())
|
.defaultValue(Boolean.TRUE.toString())
|
||||||
);
|
);
|
||||||
|
|
||||||
supportedLibraries.put(LIBRARY_JAVASCRIPT, "JavaScript client library");
|
supportedLibraries.put(LIBRARY_JAVASCRIPT, "JavaScript client library");
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
|
|
||||||
import superagent from "superagent";
|
import superagent from "superagent";
|
||||||
import querystring from "querystring";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @module ApiClient
|
* @module ApiClient
|
||||||
@ -443,7 +442,10 @@ class ApiClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (contentType === 'application/x-www-form-urlencoded') {
|
if (contentType === 'application/x-www-form-urlencoded') {
|
||||||
request.send(querystring.stringify(this.normalizeParams(formParams)));
|
let normalizedParams = this.normalizeParams(formParams)
|
||||||
|
let urlSearchParams = new URLSearchParams(normalizedParams);
|
||||||
|
let queryString = urlSearchParams.toString();
|
||||||
|
request.send(queryString);
|
||||||
} else if (contentType == 'multipart/form-data') {
|
} else if (contentType == 'multipart/form-data') {
|
||||||
var _formParams = this.normalizeParams(formParams);
|
var _formParams = this.normalizeParams(formParams);
|
||||||
for (var key in _formParams) {
|
for (var key in _formParams) {
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
|
|
||||||
import superagent from "superagent";
|
import superagent from "superagent";
|
||||||
import querystring from "querystring";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @module ApiClient
|
* @module ApiClient
|
||||||
@ -435,7 +434,10 @@ class ApiClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (contentType === 'application/x-www-form-urlencoded') {
|
if (contentType === 'application/x-www-form-urlencoded') {
|
||||||
request.send(querystring.stringify(this.normalizeParams(formParams)));
|
let normalizedParams = this.normalizeParams(formParams)
|
||||||
|
let urlSearchParams = new URLSearchParams(normalizedParams);
|
||||||
|
let queryString = urlSearchParams.toString();
|
||||||
|
request.send(queryString);
|
||||||
} else if (contentType == 'multipart/form-data') {
|
} else if (contentType == 'multipart/form-data') {
|
||||||
var _formParams = this.normalizeParams(formParams);
|
var _formParams = this.normalizeParams(formParams);
|
||||||
for (var key in _formParams) {
|
for (var key in _formParams) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user