fix path and query parameters encoding (#10069)

This commit is contained in:
William Cheng 2021-08-03 16:43:21 +08:00 committed by GitHub
parent 594d08a7a4
commit 0ceeddb441
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -1,5 +1,6 @@
{{>partial_header}}
using System.Collections.Generic;
using System.Web;
namespace {{packageName}}.Client
{
@ -21,7 +22,7 @@ namespace {{packageName}}.Client
{
foreach (var parameter in parameters)
{
_path = _path.Replace("{" + parameter.Key + "}", parameter.Value);
_path = _path.Replace("{" + parameter.Key + "}", HttpUtility.UrlEncode(parameter.Value));
}
}
@ -31,7 +32,7 @@ namespace {{packageName}}.Client
{
foreach (var value in parameter.Value)
{
_query = _query + parameter.Key + "=" + value + "&";
_query = _query + parameter.Key + "=" + HttpUtility.UrlEncode(value) + "&";
}
}
}

View File

@ -8,6 +8,7 @@
*/
using System.Collections.Generic;
using System.Web;
namespace Org.OpenAPITools.Client
{
@ -29,7 +30,7 @@ namespace Org.OpenAPITools.Client
{
foreach (var parameter in parameters)
{
_path = _path.Replace("{" + parameter.Key + "}", parameter.Value);
_path = _path.Replace("{" + parameter.Key + "}", HttpUtility.UrlEncode(parameter.Value));
}
}
@ -39,7 +40,7 @@ namespace Org.OpenAPITools.Client
{
foreach (var value in parameter.Value)
{
_query = _query + parameter.Key + "=" + value + "&";
_query = _query + parameter.Key + "=" + HttpUtility.UrlEncode(value) + "&";
}
}
}