mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 11:23:58 +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>
|
/// <returns>Escaped string.</returns>
|
||||||
public string EscapeString(string str)
|
public string EscapeString(string str)
|
||||||
{
|
{
|
||||||
return RestSharp.Contrib.HttpUtility.UrlEncode(str);
|
return RestSharp.Extensions.StringExtensions.UrlEncode(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -49,6 +49,16 @@ namespace IO.Swagger.Client
|
|||||||
{
|
{
|
||||||
get { return _defaultHeaderMap; }
|
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.
|
// Creates and sets up a RestRequest prior to a call.
|
||||||
private RestRequest PrepareRequest(
|
private RestRequest PrepareRequest(
|
||||||
@ -110,7 +120,10 @@ namespace IO.Swagger.Client
|
|||||||
{
|
{
|
||||||
var request = PrepareRequest(
|
var request = PrepareRequest(
|
||||||
path, method, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
|
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>
|
/// <summary>
|
||||||
@ -133,7 +146,10 @@ namespace IO.Swagger.Client
|
|||||||
{
|
{
|
||||||
var request = PrepareRequest(
|
var request = PrepareRequest(
|
||||||
path, method, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
|
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>
|
/// <summary>
|
||||||
@ -154,7 +170,7 @@ namespace IO.Swagger.Client
|
|||||||
/// <returns>Escaped string.</returns>
|
/// <returns>Escaped string.</returns>
|
||||||
public string EscapeString(string str)
|
public string EscapeString(string str)
|
||||||
{
|
{
|
||||||
return RestSharp.Contrib.HttpUtility.UrlEncode(str);
|
return RestSharp.Extensions.StringExtensions.UrlDecode(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -32,15 +32,15 @@
|
|||||||
<Reference Include="Newtonsoft.Json">
|
<Reference Include="Newtonsoft.Json">
|
||||||
<HintPath>Lib\SwaggerClient\bin\Newtonsoft.Json.dll</HintPath>
|
<HintPath>Lib\SwaggerClient\bin\Newtonsoft.Json.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="RestSharp">
|
|
||||||
<HintPath>Lib\SwaggerClient\bin\RestSharp.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="System.Runtime.Serialization" />
|
<Reference Include="System.Runtime.Serialization" />
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
<Reference Include="nunit.framework">
|
<Reference Include="nunit.framework">
|
||||||
<HintPath>packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
|
<HintPath>packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Web" />
|
<Reference Include="System.Web" />
|
||||||
|
<Reference Include="RestSharp">
|
||||||
|
<HintPath>Lib\SwaggerClient\bin\RestSharp.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Lib\SwaggerClient\src\main\csharp\IO\Swagger\Api\PetApi.cs" />
|
<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