forked from loafle/openapi-generator-original
Merge pull request #2371 from wing328/csharp_user_agent
[C#] add httpUserAgent option, add configurable user-agent support to C#
This commit is contained in:
@@ -184,4 +184,8 @@ public interface CodegenConfig {
|
||||
|
||||
String getReleaseVersion();
|
||||
|
||||
void setHttpUserAgent(String httpUserAgent);
|
||||
|
||||
String getHttpUserAgent();
|
||||
|
||||
}
|
||||
|
||||
@@ -103,4 +103,7 @@ public class CodegenConstants {
|
||||
public static final String RELEASE_VERSION = "releaseVersion";
|
||||
public static final String RELEASE_VERSION_DESC= "Release version, e.g. 1.2.5, default to 0.1.0.";
|
||||
|
||||
public static final String HTTP_USER_AGENT = "httpUserAgent";
|
||||
public static final String HTTP_USER_AGENT_DESC = "HTTP user agent, e.g. codegen_csharp_api_client, default to 'Swagger-Codegen/{releaseVersion}}/{language}'";
|
||||
|
||||
}
|
||||
|
||||
@@ -84,6 +84,7 @@ public class DefaultCodegen {
|
||||
protected Boolean sortParamsByRequiredFlag = true;
|
||||
protected Boolean ensureUniqueParams = true;
|
||||
protected String gitUserId, gitRepoId, releaseNote, releaseVersion;
|
||||
protected String httpUserAgent;
|
||||
|
||||
public List<CliOption> cliOptions() {
|
||||
return cliOptions;
|
||||
@@ -2431,6 +2432,24 @@ public class DefaultCodegen {
|
||||
return releaseVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set HTTP user agent.
|
||||
*
|
||||
* @param httpUserAgent HTTP user agent
|
||||
*/
|
||||
public void setHttpUserAgent(String httpUserAgent) {
|
||||
this.httpUserAgent = httpUserAgent;
|
||||
}
|
||||
|
||||
/**
|
||||
* HTTP user agent
|
||||
*
|
||||
* @return HTTP user agent
|
||||
*/
|
||||
public String getHttpUserAgent() {
|
||||
return httpUserAgent;
|
||||
}
|
||||
|
||||
@SuppressWarnings("static-method")
|
||||
protected CliOption buildLibraryCliOption(Map<String, String> supportedLibraries) {
|
||||
StringBuilder sb = new StringBuilder("library template (sub-template) to use:");
|
||||
|
||||
@@ -64,6 +64,7 @@ public class CodegenConfigurator {
|
||||
private String gitRepoId="YOUR_GIT_REPO_ID";
|
||||
private String releaseNote="Minor update";
|
||||
private String releaseVersion="0.1.0";
|
||||
private String httpUserAgent;
|
||||
|
||||
private final Map<String, String> dynamicProperties = new HashMap<String, String>(); //the map that holds the JsonAnySetter/JsonAnyGetter values
|
||||
|
||||
@@ -334,6 +335,15 @@ public class CodegenConfigurator {
|
||||
this.releaseVersion = releaseVersion;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getHttpUserAgent() {
|
||||
return httpUserAgent;
|
||||
}
|
||||
|
||||
public CodegenConfigurator setHttpUserAgent(String httpUserAgent) {
|
||||
this.httpUserAgent= httpUserAgent;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ClientOptInput toClientOptInput() {
|
||||
|
||||
@@ -366,6 +376,7 @@ public class CodegenConfigurator {
|
||||
checkAndSetAdditionalProperty(gitRepoId, CodegenConstants.GIT_REPO_ID);
|
||||
checkAndSetAdditionalProperty(releaseVersion, CodegenConstants.RELEASE_VERSION);
|
||||
checkAndSetAdditionalProperty(releaseNote, CodegenConstants.RELEASE_NOTE);
|
||||
checkAndSetAdditionalProperty(httpUserAgent, CodegenConstants.HTTP_USER_AGENT);
|
||||
|
||||
handleDynamicProperties(config);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user