Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,7 @@ public class Generate implements Runnable {
@Option(name = {"--release-note"}, title = "release note", description = CodegenConstants.RELEASE_NOTE_DESC)
private String releaseNote;

@Option(name = {"--release-version"}, title = "release version", description = CodegenConstants.RELEASE_VERSION_DESC)
private String releaseVersion;

@Option(name = {"--http-user-agent"}, title = "http user agent", description = CodegenConstants.HTTP_USER_AGENT)
@Option(name = {"--http-user-agent"}, title = "http user agent", description = CodegenConstants.HTTP_USER_AGENT_DESC)
private String httpUserAgent;

@Override
Expand Down Expand Up @@ -210,10 +207,6 @@ public void run() {
configurator.setReleaseNote(releaseNote);
}

if (isNotEmpty(releaseVersion)) {
configurator.setReleaseVersion(releaseVersion);
}

if (isNotEmpty(httpUserAgent)) {
configurator.setHttpUserAgent(httpUserAgent);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,6 @@ public interface CodegenConfig {

String getReleaseNote();

void setReleaseVersion(String releaseVersion);

String getReleaseVersion();

void setHttpUserAgent(String httpUserAgent);

String getHttpUserAgent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,7 @@ public static enum MODEL_PROPERTY_NAMING_TYPE {camelCase, PascalCase, snake_case
public static final String RELEASE_NOTE = "releaseNote";
public static final String RELEASE_NOTE_DESC = "Release note, default to 'Minor update'.";

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}'";
public static final String HTTP_USER_AGENT_DESC = "HTTP user agent, e.g. codegen_csharp_api_client, default to 'Swagger-Codegen/{packageVersion}}/{language}'";

}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public class DefaultCodegen {
protected String library;
protected Boolean sortParamsByRequiredFlag = true;
protected Boolean ensureUniqueParams = true;
protected String gitUserId, gitRepoId, releaseNote, releaseVersion;
protected String gitUserId, gitRepoId, releaseNote;
protected String httpUserAgent;

public List<CliOption> cliOptions() {
Expand Down Expand Up @@ -2414,24 +2414,6 @@ public String getReleaseNote() {
return releaseNote;
}

/**
* Set release version.
*
* @param releaseVersion Release version
*/
public void setReleaseVersion(String releaseVersion) {
this.releaseVersion = releaseVersion;
}

/**
* Release version
*
* @return Release version
*/
public String getReleaseVersion() {
return releaseVersion;
}

/**
* Set HTTP user agent.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public class CodegenConfigurator {
private String gitUserId="YOUR_GIT_USR_ID";
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
Expand Down Expand Up @@ -327,15 +326,6 @@ public CodegenConfigurator setReleaseNote(String releaseNote) {
return this;
}

public String getReleaseVersion() {
return releaseVersion;
}

public CodegenConfigurator setReleaseVersion(String releaseVersion) {
this.releaseVersion = releaseVersion;
return this;
}

public String getHttpUserAgent() {
return httpUserAgent;
}
Expand Down Expand Up @@ -374,7 +364,6 @@ public ClientOptInput toClientOptInput() {
checkAndSetAdditionalProperty(modelNameSuffix, CodegenConstants.MODEL_NAME_SUFFIX);
checkAndSetAdditionalProperty(gitUserId, CodegenConstants.GIT_USER_ID);
checkAndSetAdditionalProperty(gitRepoId, CodegenConstants.GIT_REPO_ID);
checkAndSetAdditionalProperty(releaseVersion, CodegenConstants.RELEASE_VERSION);
checkAndSetAdditionalProperty(releaseNote, CodegenConstants.RELEASE_NOTE);
checkAndSetAdditionalProperty(httpUserAgent, CodegenConstants.HTTP_USER_AGENT);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public class ApiClient {
dateFormat = ApiClient.buildDefaultDateFormat();

// Set default User-Agent.
setUserAgent("Java-Swagger");
setUserAgent("{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/{{{artifactVersion}}}/java{{/httpUserAgent}}");

// Setup authentications (key: authentication name, value: authentication).
authentications = new HashMap<String, Authentication>();{{#authMethods}}{{#isBasic}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public class ApiClient {
this.json.setDateFormat((DateFormat) dateFormat.clone());

// Set default User-Agent.
setUserAgent("Java-Swagger");
setUserAgent("{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/{{{artifactVersion}}}/java{{/httpUserAgent}}");

// Setup authentications (key: authentication name, value: authentication).
authentications = new HashMap<String, Authentication>();{{#authMethods}}{{#isBasic}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public class ApiClient {
this.lenientDatetimeFormat = true;

// Set default User-Agent.
setUserAgent("Java-Swagger");
setUserAgent("{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/{{{artifactVersion}}}/java{{/httpUserAgent}}");

// Setup authentications (key: authentication name, value: authentication).
authentications = new HashMap<String, Authentication>();{{#authMethods}}{{#isBasic}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public class ApiInvoker {
DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));

// Set default User-Agent.
setUserAgent("Android-Java-Swagger");
setUserAgent("{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/{{{artifactVersion}}}/android{{/httpUserAgent}}");
}

public static void setUserAgent(String userAgent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public class ApiInvoker {

public static void initializeInstance(Cache cache, Network network, int threadPoolSize, ResponseDelivery delivery, int connectionTimeout) {
INSTANCE = new ApiInvoker(cache, network, threadPoolSize, delivery, connectionTimeout);
setUserAgent("Android-Volley-Swagger");
setUserAgent("{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/{{{artifactVersion}}}/android{{/httpUserAgent}}");

// Setup authentications (key: authentication name, value: authentication).
INSTANCE.authentications = new HashMap<String, Authentication>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ namespace {{packageName}}.Client
{
var request = new RestRequest(path, method);

// add user agent header
request.AddHeader("User-Agent", Configuration.HttpUserAgent);

// add path parameter, if any
foreach(var param in pathParams)
request.AddParameter(param.Key, param.Value, ParameterType.UrlSegment);
Expand Down Expand Up @@ -146,6 +143,11 @@ namespace {{packageName}}.Client
path, method, queryParams, postBody, headerParams, formParams, fileParams,
pathParams, contentType);

// set timeout
RestClient.Timeout = Configuration.Timeout;
// set user agent
RestClient.UserAgent = Configuration.UserAgent;

var response = RestClient.Execute(request);
return (Object) response;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ namespace {{packageName}}.Client
string tempFolderPath = null,
string dateTimeFormat = null,
int timeout = 100000,
string httpUserAgent = "{{#httpUserAgent}}{{.}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/{{packageVersion}}/csharp{{/httpUserAgent}}"
string userAgent = "{{#httpUserAgent}}{{.}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/{{packageVersion}}/csharp{{/httpUserAgent}}"
)
{
setApiClientUsingDefault(apiClient);

Username = username;
Password = password;
AccessToken = accessToken;
HttpUserAgent = httpUserAgent;
UserAgent = userAgent;

if (defaultHeader != null)
DefaultHeader = defaultHeader;
Expand Down Expand Up @@ -152,7 +152,7 @@ namespace {{packageName}}.Client
/// Gets or sets the HTTP user agent.
/// </summary>
/// <value>Http user agent.</value>
public String HttpUserAgent { get; set; }
public String UserAgent { get; set; }

/// <summary>
/// Gets or sets the username (HTTP basic authentication).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class Configuration
*
* @var string
*/
protected $userAgent = "PHP-Swagger/{{artifactVersion}}";
protected $userAgent = "{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/{{{artifactVersion}}}/php{{/httpUserAgent}}";

/**
* Debug switch (default set to false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class ApiClient(object):
self.host = host
self.cookie = cookie
# Set default User-Agent.
self.user_agent = 'Python-Swagger/{{packageVersion}}'
self.user_agent = '{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/{{{packageVersion}}}/python{{/httpUserAgent}}'

@property
def user_agent(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module {{moduleName}}

def initialize(config = Configuration.default)
@config = config
@user_agent = "ruby-swagger-#{VERSION}"
@user_agent = "{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/#{VERSION}/ruby{{/httpUserAgent}}"
@default_headers = {
'Content-Type' => "application/json",
'User-Agent' => @user_agent
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@
<swagger-parser-version>1.0.18-SNAPSHOT</swagger-parser-version>
<scala-version>2.11.1</scala-version>
<felix-version>2.3.4</felix-version>
<swagger-core-version>1.5.7</swagger-core-version>
<swagger-core-version>1.5.8</swagger-core-version>
<commons-io-version>2.4</commons-io-version>
<commons-cli-version>1.2</commons-cli-version>
<junit-version>4.8.1</junit-version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public class ApiInvoker {
DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));

// Set default User-Agent.
setUserAgent("Android-Java-Swagger");
setUserAgent("Swagger-Codegen/1.0.0/android");
}

public static void setUserAgent(String userAgent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,22 +185,28 @@ public static void initializeInstance(Cache cache) {

public static void initializeInstance(Cache cache, Network network, int threadPoolSize, ResponseDelivery delivery, int connectionTimeout) {
INSTANCE = new ApiInvoker(cache, network, threadPoolSize, delivery, connectionTimeout);
setUserAgent("Android-Volley-Swagger");
setUserAgent("Swagger-Codegen/1.0.0/android");

// Setup authentications (key: authentication name, value: authentication).
INSTANCE.authentications = new HashMap<String, Authentication>();


INSTANCE.authentications.put("test_api_key_header", new ApiKeyAuth("header", "test_api_key_header"));


INSTANCE.authentications.put("petstore_auth", new OAuth());



INSTANCE.authentications.put("test_api_client_id", new ApiKeyAuth("header", "x-test_api_client_id"));
INSTANCE.authentications.put("api_key", new ApiKeyAuth("header", "api_key"));






INSTANCE.authentications.put("test_http_basic", new HttpBasicAuth());




INSTANCE.authentications.put("test_api_client_secret", new ApiKeyAuth("header", "x-test_api_client_secret"));
Expand All @@ -209,7 +215,7 @@ public static void initializeInstance(Cache cache, Network network, int threadPo



INSTANCE.authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
INSTANCE.authentications.put("test_api_client_id", new ApiKeyAuth("header", "x-test_api_client_id"));



Expand All @@ -221,9 +227,9 @@ public static void initializeInstance(Cache cache, Network network, int threadPo



INSTANCE.authentications.put("test_api_key_header", new ApiKeyAuth("header", "test_api_key_header"));


INSTANCE.authentications.put("petstore_auth", new OAuth());


// Prevent the authentications from being modified.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,40 @@ public static <T> T deserializeToObject(String jsonString, Class cls){
public static Type getListTypeForDeserialization(Class cls) {
String className = cls.getSimpleName();

if ("Category".equalsIgnoreCase(className)) {
return new TypeToken<List<Category>>(){}.getType();
}

if ("InlineResponse200".equalsIgnoreCase(className)) {
return new TypeToken<List<InlineResponse200>>(){}.getType();
}

if ("ModelReturn".equalsIgnoreCase(className)) {
return new TypeToken<List<ModelReturn>>(){}.getType();
}

if ("Name".equalsIgnoreCase(className)) {
return new TypeToken<List<Name>>(){}.getType();
}

if ("Order".equalsIgnoreCase(className)) {
return new TypeToken<List<Order>>(){}.getType();
}

if ("User".equalsIgnoreCase(className)) {
return new TypeToken<List<User>>(){}.getType();
if ("Pet".equalsIgnoreCase(className)) {
return new TypeToken<List<Pet>>(){}.getType();
}

if ("Category".equalsIgnoreCase(className)) {
return new TypeToken<List<Category>>(){}.getType();
if ("SpecialModelName".equalsIgnoreCase(className)) {
return new TypeToken<List<SpecialModelName>>(){}.getType();
}

if ("Tag".equalsIgnoreCase(className)) {
return new TypeToken<List<Tag>>(){}.getType();
}

if ("Pet".equalsIgnoreCase(className)) {
return new TypeToken<List<Pet>>(){}.getType();
if ("User".equalsIgnoreCase(className)) {
return new TypeToken<List<User>>(){}.getType();
}

return new TypeToken<List<Object>>(){}.getType();
Expand All @@ -61,24 +77,40 @@ public static Type getListTypeForDeserialization(Class cls) {
public static Type getTypeForDeserialization(Class cls) {
String className = cls.getSimpleName();

if ("Category".equalsIgnoreCase(className)) {
return new TypeToken<Category>(){}.getType();
}

if ("InlineResponse200".equalsIgnoreCase(className)) {
return new TypeToken<InlineResponse200>(){}.getType();
}

if ("ModelReturn".equalsIgnoreCase(className)) {
return new TypeToken<ModelReturn>(){}.getType();
}

if ("Name".equalsIgnoreCase(className)) {
return new TypeToken<Name>(){}.getType();
}

if ("Order".equalsIgnoreCase(className)) {
return new TypeToken<Order>(){}.getType();
}

if ("User".equalsIgnoreCase(className)) {
return new TypeToken<User>(){}.getType();
if ("Pet".equalsIgnoreCase(className)) {
return new TypeToken<Pet>(){}.getType();
}

if ("Category".equalsIgnoreCase(className)) {
return new TypeToken<Category>(){}.getType();
if ("SpecialModelName".equalsIgnoreCase(className)) {
return new TypeToken<SpecialModelName>(){}.getType();
}

if ("Tag".equalsIgnoreCase(className)) {
return new TypeToken<Tag>(){}.getType();
}

if ("Pet".equalsIgnoreCase(className)) {
return new TypeToken<Pet>(){}.getType();
if ("User".equalsIgnoreCase(className)) {
return new TypeToken<User>(){}.getType();
}

return new TypeToken<Object>(){}.getType();
Expand Down
Loading