add httpUserAgent option, add customized user-agent support to C#

This commit is contained in:
wing328
2016-03-13 17:28:43 +08:00
parent d3f26f72d9
commit cdecb5133f
14 changed files with 124 additions and 3 deletions

View File

@@ -541,6 +541,12 @@ namespace IO.Swagger.Api
public PetApi(String basePath)
{
this.Configuration = new Configuration(new ApiClient(basePath));
// ensure API client has configuration ready
if (Configuration.ApiClient.Configuration == null)
{
this.Configuration.ApiClient.Configuration = this.Configuration;
}
}
/// <summary>
@@ -555,6 +561,12 @@ namespace IO.Swagger.Api
this.Configuration = Configuration.Default;
else
this.Configuration = configuration;
// ensure API client has configuration ready
if (Configuration.ApiClient.Configuration == null)
{
this.Configuration.ApiClient.Configuration = this.Configuration;
}
}
/// <summary>

View File

@@ -293,6 +293,12 @@ namespace IO.Swagger.Api
public StoreApi(String basePath)
{
this.Configuration = new Configuration(new ApiClient(basePath));
// ensure API client has configuration ready
if (Configuration.ApiClient.Configuration == null)
{
this.Configuration.ApiClient.Configuration = this.Configuration;
}
}
/// <summary>
@@ -307,6 +313,12 @@ namespace IO.Swagger.Api
this.Configuration = Configuration.Default;
else
this.Configuration = configuration;
// ensure API client has configuration ready
if (Configuration.ApiClient.Configuration == null)
{
this.Configuration.ApiClient.Configuration = this.Configuration;
}
}
/// <summary>

View File

@@ -393,6 +393,12 @@ namespace IO.Swagger.Api
public UserApi(String basePath)
{
this.Configuration = new Configuration(new ApiClient(basePath));
// ensure API client has configuration ready
if (Configuration.ApiClient.Configuration == null)
{
this.Configuration.ApiClient.Configuration = this.Configuration;
}
}
/// <summary>
@@ -407,6 +413,12 @@ namespace IO.Swagger.Api
this.Configuration = Configuration.Default;
else
this.Configuration = configuration;
// ensure API client has configuration ready
if (Configuration.ApiClient.Configuration == null)
{
this.Configuration.ApiClient.Configuration = this.Configuration;
}
}
/// <summary>

View File

@@ -84,6 +84,9 @@ namespace IO.Swagger.Client
String contentType)
{
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)

View File

@@ -34,7 +34,8 @@ namespace IO.Swagger.Client
Dictionary<String, String> apiKeyPrefix = null,
string tempFolderPath = null,
string dateTimeFormat = null,
int timeout = 100000
int timeout = 100000,
string httpUserAgent = "Swagger-Codegen/1.0.0/csharp"
)
{
setApiClientUsingDefault(apiClient);
@@ -42,6 +43,7 @@ namespace IO.Swagger.Client
Username = username;
Password = password;
AccessToken = accessToken;
HttpUserAgent = httpUserAgent;
if (defaultHeader != null)
DefaultHeader = defaultHeader;
@@ -146,6 +148,12 @@ namespace IO.Swagger.Client
_defaultHeaderMap.Add(key, value);
}
/// <summary>
/// Gets or sets the HTTP user agent.
/// </summary>
/// <value>Http user agent.</value>
public String HttpUserAgent { get; set; }
/// <summary>
/// Gets or sets the username (HTTP basic authentication).
/// </summary>

View File

@@ -2,9 +2,16 @@
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
<MonoDevelop.Ide.Workbench ActiveDocument="TestPet.cs">
<Files>
<File FileName="TestPet.cs" Line="189" Column="4" />
<File FileName="TestPet.cs" Line="69" Column="32" />
<File FileName="TestOrder.cs" Line="1" Column="1" />
</Files>
<Pads>
<Pad Id="MonoDevelop.NUnit.TestPad">
<State name="__root__">
<Node name="SwaggerClientTest" expanded="True" />
</State>
</Pad>
</Pads>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints>
<BreakpointStore />