mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-05-12 20:50:55 +00:00
[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|
|
||||
|useInheritance|use JavaScript prototype chains & delegation for inheritance| |true|
|
||||
|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
|
||||
|
||||
|
@ -81,7 +81,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
protected boolean useES6 = true; // default is ES6
|
||||
@Setter protected String npmRepository = null;
|
||||
@Getter private String modelPropertyNaming = "camelCase";
|
||||
@Setter protected boolean useURLSearchParams = false;
|
||||
@Setter protected boolean useURLSearchParams = true;
|
||||
|
||||
public JavascriptClientCodegen() {
|
||||
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(USE_URL_SEARCH_PARAMS,
|
||||
"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");
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
|
||||
import superagent from "superagent";
|
||||
import querystring from "querystring";
|
||||
|
||||
/**
|
||||
* @module ApiClient
|
||||
@ -443,7 +442,10 @@ class ApiClient {
|
||||
}
|
||||
|
||||
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') {
|
||||
var _formParams = this.normalizeParams(formParams);
|
||||
for (var key in _formParams) {
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
|
||||
import superagent from "superagent";
|
||||
import querystring from "querystring";
|
||||
|
||||
/**
|
||||
* @module ApiClient
|
||||
@ -435,7 +434,10 @@ class ApiClient {
|
||||
}
|
||||
|
||||
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') {
|
||||
var _formParams = this.normalizeParams(formParams);
|
||||
for (var key in _formParams) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user