mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 03:18:53 +00:00
Merge pull request #1153 from wing328/csharp_fix_encode
[C#] Fix UrlEncode in API client
This commit is contained in:
commit
2b48ec072c
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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" />
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user