mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-05-12 20:50:55 +00:00
add option to skip setting user agent in js client (#20367)
This commit is contained in:
parent
5ba608ff8a
commit
ab8d359dc3
@ -5,6 +5,7 @@ inputSpec: modules/openapi-generator/src/test/resources/3_0/javascript/petstore-
|
|||||||
templateDir: modules/openapi-generator/src/main/resources/Javascript
|
templateDir: modules/openapi-generator/src/main/resources/Javascript
|
||||||
additionalProperties:
|
additionalProperties:
|
||||||
appName: PetstoreClient
|
appName: PetstoreClient
|
||||||
|
skipDefaultUserAgent: true
|
||||||
modelNameMappings:
|
modelNameMappings:
|
||||||
HealthCheckResult: HealthCheckStatus
|
HealthCheckResult: HealthCheckStatus
|
||||||
parameterNameMappings:
|
parameterNameMappings:
|
||||||
|
@ -38,6 +38,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
|||||||
|projectDescription|description of the project (Default: using info.description or "Client library of <projectName>")| |null|
|
|projectDescription|description of the project (Default: using info.description or "Client library of <projectName>")| |null|
|
||||||
|projectName|name of the project (Default: generated from info.title or "openapi-js-client")| |null|
|
|projectName|name of the project (Default: generated from info.title or "openapi-js-client")| |null|
|
||||||
|projectVersion|version of the project (Default: using info.version or "1.0.0")| |null|
|
|projectVersion|version of the project (Default: using info.version or "1.0.0")| |null|
|
||||||
|
|skipDefaultUserAgent|Skip setting default user-agent in ApiClient.js| |false|
|
||||||
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|
||||||
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
||||||
|sourceFolder|source folder for generated code| |src|
|
|sourceFolder|source folder for generated code| |src|
|
||||||
|
@ -58,30 +58,44 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
public static final String USE_ES6 = "useES6";
|
public static final String USE_ES6 = "useES6";
|
||||||
public static final String NPM_REPOSITORY = "npmRepository";
|
public static final String NPM_REPOSITORY = "npmRepository";
|
||||||
public static final String USE_URL_SEARCH_PARAMS = "useURLSearchParams";
|
public static final String USE_URL_SEARCH_PARAMS = "useURLSearchParams";
|
||||||
|
public static final String SKIP_DEFAULT_USER_AGENT = "skipDefaultUserAgent";
|
||||||
|
|
||||||
public static final String LIBRARY_JAVASCRIPT = "javascript";
|
public static final String LIBRARY_JAVASCRIPT = "javascript";
|
||||||
public static final String LIBRARY_APOLLO = "apollo";
|
public static final String LIBRARY_APOLLO = "apollo";
|
||||||
|
|
||||||
@Setter protected String projectName;
|
@Setter
|
||||||
@Setter protected String moduleName;
|
protected String projectName;
|
||||||
@Setter protected String projectDescription;
|
@Setter
|
||||||
@Setter protected String projectVersion;
|
protected String moduleName;
|
||||||
@Setter protected String licenseName;
|
@Setter
|
||||||
|
protected String projectDescription;
|
||||||
|
@Setter
|
||||||
|
protected String projectVersion;
|
||||||
|
@Setter
|
||||||
|
protected String licenseName;
|
||||||
|
|
||||||
@Getter @Setter
|
@Getter
|
||||||
|
@Setter
|
||||||
protected String invokerPackage;
|
protected String invokerPackage;
|
||||||
@Setter protected String sourceFolder = "src";
|
@Setter
|
||||||
@Setter protected boolean usePromises;
|
protected String sourceFolder = "src";
|
||||||
@Setter protected boolean emitModelMethods;
|
@Setter
|
||||||
@Setter protected boolean emitJSDoc = true;
|
protected boolean usePromises;
|
||||||
|
@Setter
|
||||||
|
protected boolean emitModelMethods;
|
||||||
|
@Setter
|
||||||
|
protected boolean emitJSDoc = true;
|
||||||
protected String apiDocPath = "docs/";
|
protected String apiDocPath = "docs/";
|
||||||
protected String modelDocPath = "docs/";
|
protected String modelDocPath = "docs/";
|
||||||
protected String apiTestPath = "api/";
|
protected String apiTestPath = "api/";
|
||||||
protected String modelTestPath = "model/";
|
protected String modelTestPath = "model/";
|
||||||
protected boolean useES6 = true; // default is ES6
|
protected boolean useES6 = true; // default is ES6
|
||||||
@Setter protected String npmRepository = null;
|
@Setter
|
||||||
@Getter private String modelPropertyNaming = "camelCase";
|
protected String npmRepository = null;
|
||||||
@Setter protected boolean useURLSearchParams = true;
|
@Getter
|
||||||
|
private String modelPropertyNaming = "camelCase";
|
||||||
|
@Setter
|
||||||
|
protected boolean useURLSearchParams = true;
|
||||||
|
|
||||||
public JavascriptClientCodegen() {
|
public JavascriptClientCodegen() {
|
||||||
super();
|
super();
|
||||||
@ -196,6 +210,9 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
"use JS build-in UrlSearchParams, instead of deprecated npm lib 'querystring'")
|
"use JS build-in UrlSearchParams, instead of deprecated npm lib 'querystring'")
|
||||||
.defaultValue(Boolean.TRUE.toString())
|
.defaultValue(Boolean.TRUE.toString())
|
||||||
);
|
);
|
||||||
|
cliOptions.add(new CliOption(SKIP_DEFAULT_USER_AGENT,
|
||||||
|
"Skip setting default user-agent in ApiClient.js")
|
||||||
|
.defaultValue(Boolean.FALSE.toString()));
|
||||||
|
|
||||||
supportedLibraries.put(LIBRARY_JAVASCRIPT, "JavaScript client library");
|
supportedLibraries.put(LIBRARY_JAVASCRIPT, "JavaScript client library");
|
||||||
supportedLibraries.put(LIBRARY_APOLLO, "Apollo REST DataSource");
|
supportedLibraries.put(LIBRARY_APOLLO, "Apollo REST DataSource");
|
||||||
@ -1186,7 +1203,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
|
|
||||||
// only process files with js extension
|
// only process files with js extension
|
||||||
if ("js".equals(FilenameUtils.getExtension(file.toString()))) {
|
if ("js".equals(FilenameUtils.getExtension(file.toString()))) {
|
||||||
this.executePostProcessor(new String[] {jsPostProcessFile, file.toString()});
|
this.executePostProcessor(new String[]{jsPostProcessFile, file.toString()});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,15 +55,20 @@ class ApiClient {
|
|||||||
</authMethods>
|
</authMethods>
|
||||||
}
|
}
|
||||||
|
|
||||||
<={{ }}=>{{#emitJSDoc}}/**
|
<={{ }}=>
|
||||||
|
{{^skipDefaultUserAgent}}
|
||||||
|
{{#emitJSDoc}}
|
||||||
|
/**
|
||||||
* The default HTTP headers to be included for all API calls.
|
* The default HTTP headers to be included for all API calls.
|
||||||
* @type {Array.<String>}
|
* @type {Array.<String>}
|
||||||
* @default {}
|
* @default {}
|
||||||
*/{{/emitJSDoc}}
|
*/
|
||||||
|
{{/emitJSDoc}}
|
||||||
this.defaultHeaders = {
|
this.defaultHeaders = {
|
||||||
'User-Agent': '{{{httpUserAgent}}}{{^httpUserAgent}}OpenAPI-Generator/{{projectVersion}}/Javascript{{/httpUserAgent}}'
|
'User-Agent': '{{{httpUserAgent}}}{{^httpUserAgent}}OpenAPI-Generator/{{projectVersion}}/Javascript{{/httpUserAgent}}'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
{{/skipDefaultUserAgent}}
|
||||||
/**
|
/**
|
||||||
* The default HTTP timeout for all API calls.
|
* The default HTTP timeout for all API calls.
|
||||||
* @type {Number}
|
* @type {Number}
|
||||||
@ -79,11 +84,13 @@ class ApiClient {
|
|||||||
*/
|
*/
|
||||||
this.cache = true;
|
this.cache = true;
|
||||||
|
|
||||||
{{#emitJSDoc}}/**
|
{{#emitJSDoc}}
|
||||||
|
/**
|
||||||
* If set to true, the client will save the cookies from each server
|
* If set to true, the client will save the cookies from each server
|
||||||
* response, and return them in the next request.
|
* response, and return them in the next request.
|
||||||
* @default false
|
* @default false
|
||||||
*/{{/emitJSDoc}}
|
*/
|
||||||
|
{{/emitJSDoc}}
|
||||||
this.enableCookies = false;
|
this.enableCookies = false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -52,15 +52,6 @@ class ApiClient {
|
|||||||
'bearer_test': {type: 'bearer'}, // JWT
|
'bearer_test': {type: 'bearer'}, // JWT
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The default HTTP headers to be included for all API calls.
|
|
||||||
* @type {Array.<String>}
|
|
||||||
* @default {}
|
|
||||||
*/
|
|
||||||
this.defaultHeaders = {
|
|
||||||
'User-Agent': 'OpenAPI-Generator/1.0.0/Javascript'
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default HTTP timeout for all API calls.
|
* The default HTTP timeout for all API calls.
|
||||||
* @type {Number}
|
* @type {Number}
|
||||||
@ -76,7 +67,7 @@ class ApiClient {
|
|||||||
*/
|
*/
|
||||||
this.cache = true;
|
this.cache = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If set to true, the client will save the cookies from each server
|
* If set to true, the client will save the cookies from each server
|
||||||
* response, and return them in the next request.
|
* response, and return them in the next request.
|
||||||
* @default false
|
* @default false
|
||||||
|
@ -52,7 +52,7 @@ class ApiClient {
|
|||||||
'bearer_test': {type: 'bearer'}, // JWT
|
'bearer_test': {type: 'bearer'}, // JWT
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default HTTP headers to be included for all API calls.
|
* The default HTTP headers to be included for all API calls.
|
||||||
* @type {Array.<String>}
|
* @type {Array.<String>}
|
||||||
* @default {}
|
* @default {}
|
||||||
@ -76,7 +76,7 @@ class ApiClient {
|
|||||||
*/
|
*/
|
||||||
this.cache = true;
|
this.cache = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If set to true, the client will save the cookies from each server
|
* If set to true, the client will save the cookies from each server
|
||||||
* response, and return them in the next request.
|
* response, and return them in the next request.
|
||||||
* @default false
|
* @default false
|
||||||
|
Loading…
x
Reference in New Issue
Block a user