Merge pull request #1153 from wing328/csharp_fix_encode

[C#] Fix UrlEncode in API client
This commit is contained in:
wing328 2015-08-31 12:42:48 +08:00
commit 2b48ec072c
7 changed files with 23 additions and 7 deletions

View File

@ -170,7 +170,7 @@ namespace {{packageName}}.Client
/// <returns>Escaped string.</returns>
public string EscapeString(string str)
{
return RestSharp.Contrib.HttpUtility.UrlEncode(str);
return RestSharp.Extensions.StringExtensions.UrlEncode(str);
}
/// <summary>

View File

@ -49,6 +49,16 @@ namespace IO.Swagger.Client
{
get { return _defaultHeaderMap; }
}
/// <summary>
/// Gets the status code of the previous request
/// </summary>
public int StatusCode { get; private set; }
/// <summary>
/// Gets the response headers of the previous request
/// </summary>
public Dictionary<String, String> ResponseHeaders { get; private set; }
// Creates and sets up a RestRequest prior to a call.
private RestRequest PrepareRequest(
@ -110,7 +120,10 @@ namespace IO.Swagger.Client
{
var request = PrepareRequest(
path, method, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
return (Object)RestClient.Execute(request);
var response = RestClient.Execute(request);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
return (Object) response;
}
/// <summary>
@ -133,7 +146,10 @@ namespace IO.Swagger.Client
{
var request = PrepareRequest(
path, method, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
return (Object) await RestClient.ExecuteTaskAsync(request);
var response = await RestClient.ExecuteTaskAsync(request);
StatusCode = (int)response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
return (Object)response;
}
/// <summary>
@ -154,7 +170,7 @@ namespace IO.Swagger.Client
/// <returns>Escaped string.</returns>
public string EscapeString(string str)
{
return RestSharp.Contrib.HttpUtility.UrlEncode(str);
return RestSharp.Extensions.StringExtensions.UrlDecode(str);
}
/// <summary>

View File

@ -32,15 +32,15 @@
<Reference Include="Newtonsoft.Json">
<HintPath>Lib\SwaggerClient\bin\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="RestSharp">
<HintPath>Lib\SwaggerClient\bin\RestSharp.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.Serialization" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="nunit.framework">
<HintPath>packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System.Web" />
<Reference Include="RestSharp">
<HintPath>Lib\SwaggerClient\bin\RestSharp.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Lib\SwaggerClient\src\main\csharp\IO\Swagger\Api\PetApi.cs" />