@@ -57,6 +57,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
5757 public static final String EMIT_JS_DOC = "emitJSDoc" ;
5858 public static final String USE_ES6 = "useES6" ;
5959 public static final String NPM_REPOSITORY = "npmRepository" ;
60+ public static final String USE_URL_SEARCH_PARAMS = "useURLSearchParams" ;
6061
6162 public static final String LIBRARY_JAVASCRIPT = "javascript" ;
6263 public static final String LIBRARY_APOLLO = "apollo" ;
@@ -80,6 +81,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
8081 protected boolean useES6 = true ; // default is ES6
8182 @ Setter protected String npmRepository = null ;
8283 @ Getter private String modelPropertyNaming = "camelCase" ;
84+ @ Setter protected boolean useURLSearchParams = false ;
8385
8486 public JavascriptClientCodegen () {
8587 super ();
@@ -190,6 +192,10 @@ public JavascriptClientCodegen() {
190192 .defaultValue (Boolean .TRUE .toString ()));
191193 cliOptions .add (new CliOption (CodegenConstants .MODEL_PROPERTY_NAMING , CodegenConstants .MODEL_PROPERTY_NAMING_DESC ).defaultValue ("camelCase" ));
192194 cliOptions .add (new CliOption (NPM_REPOSITORY , "Use this property to set an url your private npmRepo in the package.json" ));
195+ cliOptions .add (new CliOption (USE_URL_SEARCH_PARAMS ,
196+ "use JS build-in UrlSearchParams, instead of deprecated npm lib 'querystring'" )
197+ .defaultValue (Boolean .FALSE .toString ())
198+ );
193199
194200 supportedLibraries .put (LIBRARY_JAVASCRIPT , "JavaScript client library" );
195201 supportedLibraries .put (LIBRARY_APOLLO , "Apollo REST DataSource" );
@@ -267,6 +273,9 @@ public void processOpts() {
267273 if (additionalProperties .containsKey (NPM_REPOSITORY )) {
268274 setNpmRepository (((String ) additionalProperties .get (NPM_REPOSITORY )));
269275 }
276+ if (additionalProperties .containsKey (USE_URL_SEARCH_PARAMS )) {
277+ setUseURLSearchParams (convertPropertyToBooleanAndWriteBack (USE_URL_SEARCH_PARAMS ));
278+ }
270279 if (additionalProperties .containsKey (CodegenConstants .LIBRARY )) {
271280 setLibrary ((String ) additionalProperties .get (CodegenConstants .LIBRARY ));
272281 }
@@ -334,6 +343,7 @@ public void preprocessOpenAPI(OpenAPI openAPI) {
334343 additionalProperties .put (EMIT_JS_DOC , emitJSDoc );
335344 additionalProperties .put (USE_ES6 , useES6 );
336345 additionalProperties .put (NPM_REPOSITORY , npmRepository );
346+ additionalProperties .put (USE_URL_SEARCH_PARAMS , useURLSearchParams );
337347
338348 // make api and model doc path available in mustache template
339349 additionalProperties .put ("apiDocPath" , apiDocPath );
0 commit comments