Skip to content

Commit 15bf21d

Browse files
committed
Merge branch 'csharp_query_param_encoding' of https://github.com/mohamuni/openapi-generator into mohamuni-csharp_query_param_encoding
2 parents 8167aa1 + 89b7029 commit 15bf21d

File tree

12 files changed

+48
-24
lines changed

12 files changed

+48
-24
lines changed

modules/openapi-generator/src/main/resources/csharp/HttpSigningConfiguration.mustache

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,18 @@ namespace {{packageName}}.Client
133133
foreach (var parameter in requestOptions.QueryParameters)
134134
{
135135
#if (NETCOREAPP)
136+
string framework = RuntimeInformation.FrameworkDescription;
137+
string key = framework.StartsWith(".NET 9")?parameter.Key:HttpUtility.UrlEncode(parameter.Key);
136138
if (parameter.Value.Count > 1)
137139
{ // array
138140
foreach (var value in parameter.Value)
139141
{
140-
httpValues.Add(HttpUtility.UrlEncode(parameter.Key) + "[]", value);
142+
httpValues.Add(key + "[]", value);
141143
}
142144
}
143145
else
144146
{
145-
httpValues.Add(HttpUtility.UrlEncode(parameter.Key), parameter.Value[0]);
147+
httpValues.Add(key, parameter.Value[0]);
146148
}
147149
#else
148150
if (parameter.Value.Count > 1)

samples/client/petstore/csharp/httpclient/net9/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,18 @@ public Dictionary<string, string> GetHttpSignedHeader(string basePath,string met
141141
foreach (var parameter in requestOptions.QueryParameters)
142142
{
143143
#if (NETCOREAPP)
144+
string framework = RuntimeInformation.FrameworkDescription;
145+
string key = framework.StartsWith(".NET 9")?parameter.Key:HttpUtility.UrlEncode(parameter.Key);
144146
if (parameter.Value.Count > 1)
145147
{ // array
146148
foreach (var value in parameter.Value)
147149
{
148-
httpValues.Add(HttpUtility.UrlEncode(parameter.Key) + "[]", value);
150+
httpValues.Add(key + "[]", value);
149151
}
150152
}
151153
else
152154
{
153-
httpValues.Add(HttpUtility.UrlEncode(parameter.Key), parameter.Value[0]);
155+
httpValues.Add(key, parameter.Value[0]);
154156
}
155157
#else
156158
if (parameter.Value.Count > 1)

samples/client/petstore/csharp/httpclient/standard2.0/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,18 @@ public Dictionary<string, string> GetHttpSignedHeader(string basePath,string met
141141
foreach (var parameter in requestOptions.QueryParameters)
142142
{
143143
#if (NETCOREAPP)
144+
string framework = RuntimeInformation.FrameworkDescription;
145+
string key = framework.StartsWith(".NET 9")?parameter.Key:HttpUtility.UrlEncode(parameter.Key);
144146
if (parameter.Value.Count > 1)
145147
{ // array
146148
foreach (var value in parameter.Value)
147149
{
148-
httpValues.Add(HttpUtility.UrlEncode(parameter.Key) + "[]", value);
150+
httpValues.Add(key + "[]", value);
149151
}
150152
}
151153
else
152154
{
153-
httpValues.Add(HttpUtility.UrlEncode(parameter.Key), parameter.Value[0]);
155+
httpValues.Add(key, parameter.Value[0]);
154156
}
155157
#else
156158
if (parameter.Value.Count > 1)

samples/client/petstore/csharp/restsharp/net4.7/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,18 @@ public Dictionary<string, string> GetHttpSignedHeader(string basePath,string met
141141
foreach (var parameter in requestOptions.QueryParameters)
142142
{
143143
#if (NETCOREAPP)
144+
string framework = RuntimeInformation.FrameworkDescription;
145+
string key = framework.StartsWith(".NET 9")?parameter.Key:HttpUtility.UrlEncode(parameter.Key);
144146
if (parameter.Value.Count > 1)
145147
{ // array
146148
foreach (var value in parameter.Value)
147149
{
148-
httpValues.Add(HttpUtility.UrlEncode(parameter.Key) + "[]", value);
150+
httpValues.Add(key + "[]", value);
149151
}
150152
}
151153
else
152154
{
153-
httpValues.Add(HttpUtility.UrlEncode(parameter.Key), parameter.Value[0]);
155+
httpValues.Add(key, parameter.Value[0]);
154156
}
155157
#else
156158
if (parameter.Value.Count > 1)

samples/client/petstore/csharp/restsharp/net4.8/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,18 @@ public Dictionary<string, string> GetHttpSignedHeader(string basePath,string met
141141
foreach (var parameter in requestOptions.QueryParameters)
142142
{
143143
#if (NETCOREAPP)
144+
string framework = RuntimeInformation.FrameworkDescription;
145+
string key = framework.StartsWith(".NET 9")?parameter.Key:HttpUtility.UrlEncode(parameter.Key);
144146
if (parameter.Value.Count > 1)
145147
{ // array
146148
foreach (var value in parameter.Value)
147149
{
148-
httpValues.Add(HttpUtility.UrlEncode(parameter.Key) + "[]", value);
150+
httpValues.Add(key + "[]", value);
149151
}
150152
}
151153
else
152154
{
153-
httpValues.Add(HttpUtility.UrlEncode(parameter.Key), parameter.Value[0]);
155+
httpValues.Add(key, parameter.Value[0]);
154156
}
155157
#else
156158
if (parameter.Value.Count > 1)

samples/client/petstore/csharp/restsharp/net8/EnumMappings/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,18 @@ public Dictionary<string, string> GetHttpSignedHeader(string basePath,string met
141141
foreach (var parameter in requestOptions.QueryParameters)
142142
{
143143
#if (NETCOREAPP)
144+
string framework = RuntimeInformation.FrameworkDescription;
145+
string key = framework.StartsWith(".NET 9")?parameter.Key:HttpUtility.UrlEncode(parameter.Key);
144146
if (parameter.Value.Count > 1)
145147
{ // array
146148
foreach (var value in parameter.Value)
147149
{
148-
httpValues.Add(HttpUtility.UrlEncode(parameter.Key) + "[]", value);
150+
httpValues.Add(key + "[]", value);
149151
}
150152
}
151153
else
152154
{
153-
httpValues.Add(HttpUtility.UrlEncode(parameter.Key), parameter.Value[0]);
155+
httpValues.Add(key, parameter.Value[0]);
154156
}
155157
#else
156158
if (parameter.Value.Count > 1)

samples/client/petstore/csharp/restsharp/net8/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,18 @@ public Dictionary<string, string> GetHttpSignedHeader(string basePath,string met
141141
foreach (var parameter in requestOptions.QueryParameters)
142142
{
143143
#if (NETCOREAPP)
144+
string framework = RuntimeInformation.FrameworkDescription;
145+
string key = framework.StartsWith(".NET 9")?parameter.Key:HttpUtility.UrlEncode(parameter.Key);
144146
if (parameter.Value.Count > 1)
145147
{ // array
146148
foreach (var value in parameter.Value)
147149
{
148-
httpValues.Add(HttpUtility.UrlEncode(parameter.Key) + "[]", value);
150+
httpValues.Add(key + "[]", value);
149151
}
150152
}
151153
else
152154
{
153-
httpValues.Add(HttpUtility.UrlEncode(parameter.Key), parameter.Value[0]);
155+
httpValues.Add(key, parameter.Value[0]);
154156
}
155157
#else
156158
if (parameter.Value.Count > 1)

samples/client/petstore/csharp/restsharp/net9/EnumMappings/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,18 @@ public Dictionary<string, string> GetHttpSignedHeader(string basePath,string met
141141
foreach (var parameter in requestOptions.QueryParameters)
142142
{
143143
#if (NETCOREAPP)
144+
string framework = RuntimeInformation.FrameworkDescription;
145+
string key = framework.StartsWith(".NET 9")?parameter.Key:HttpUtility.UrlEncode(parameter.Key);
144146
if (parameter.Value.Count > 1)
145147
{ // array
146148
foreach (var value in parameter.Value)
147149
{
148-
httpValues.Add(HttpUtility.UrlEncode(parameter.Key) + "[]", value);
150+
httpValues.Add(key + "[]", value);
149151
}
150152
}
151153
else
152154
{
153-
httpValues.Add(HttpUtility.UrlEncode(parameter.Key), parameter.Value[0]);
155+
httpValues.Add(key, parameter.Value[0]);
154156
}
155157
#else
156158
if (parameter.Value.Count > 1)

samples/client/petstore/csharp/restsharp/standard2.0/ConditionalSerialization/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,18 @@ public Dictionary<string, string> GetHttpSignedHeader(string basePath,string met
141141
foreach (var parameter in requestOptions.QueryParameters)
142142
{
143143
#if (NETCOREAPP)
144+
string framework = RuntimeInformation.FrameworkDescription;
145+
string key = framework.StartsWith(".NET 9")?parameter.Key:HttpUtility.UrlEncode(parameter.Key);
144146
if (parameter.Value.Count > 1)
145147
{ // array
146148
foreach (var value in parameter.Value)
147149
{
148-
httpValues.Add(HttpUtility.UrlEncode(parameter.Key) + "[]", value);
150+
httpValues.Add(key + "[]", value);
149151
}
150152
}
151153
else
152154
{
153-
httpValues.Add(HttpUtility.UrlEncode(parameter.Key), parameter.Value[0]);
155+
httpValues.Add(key, parameter.Value[0]);
154156
}
155157
#else
156158
if (parameter.Value.Count > 1)

samples/client/petstore/csharp/restsharp/standard2.0/Petstore/src/Org.OpenAPITools/Client/HttpSigningConfiguration.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,18 @@ public Dictionary<string, string> GetHttpSignedHeader(string basePath,string met
141141
foreach (var parameter in requestOptions.QueryParameters)
142142
{
143143
#if (NETCOREAPP)
144+
string framework = RuntimeInformation.FrameworkDescription;
145+
string key = framework.StartsWith(".NET 9")?parameter.Key:HttpUtility.UrlEncode(parameter.Key);
144146
if (parameter.Value.Count > 1)
145147
{ // array
146148
foreach (var value in parameter.Value)
147149
{
148-
httpValues.Add(HttpUtility.UrlEncode(parameter.Key) + "[]", value);
150+
httpValues.Add(key + "[]", value);
149151
}
150152
}
151153
else
152154
{
153-
httpValues.Add(HttpUtility.UrlEncode(parameter.Key), parameter.Value[0]);
155+
httpValues.Add(key, parameter.Value[0]);
154156
}
155157
#else
156158
if (parameter.Value.Count > 1)

0 commit comments

Comments
 (0)