Skip to content

Commit 8efcbca

Browse files
committed
Avoid duplicate conversion code for enumerable path parameters
For non-empty array typed path parameters, append separator for all items, and remove after last item.
1 parent 705b831 commit 8efcbca

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/NSwag.CodeGeneration.CSharp/Templates/Client.Class.PathParameter.liquid

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,29 @@ using (var enumerator = {{ parameter.VariableName }}.GetEnumerator())
33
{
44
if (enumerator.MoveNext())
55
{
6-
urlBuilder_.Append(System.Uri.EscapeDataString(enumerator.Current.ToString("{{ ParameterDateTimeFormat }}", System.Globalization.CultureInfo.InvariantCulture)));
7-
86
do
97
{
10-
urlBuilder_.Append(',');
118
urlBuilder_.Append(System.Uri.EscapeDataString(enumerator.Current.ToString("{{ ParameterDateTimeFormat }}", System.Globalization.CultureInfo.InvariantCulture)));
9+
urlBuilder_.Append(',');
1210
}
1311
while (enumerator.MoveNext());
12+
13+
urlBuilder_.Length--;
1414
}
1515
}
1616
{% elsif parameter.IsDateArray -%}
1717
using (var enumerator = {{ parameter.VariableName }}.GetEnumerator())
1818
{
1919
if (enumerator.MoveNext())
2020
{
21-
urlBuilder_.Append(System.Uri.EscapeDataString(enumerator.Current.ToString("{{ ParameterDateFormat }}", System.Globalization.CultureInfo.InvariantCulture)));
22-
2321
do
2422
{
25-
urlBuilder_.Append(',');
2623
urlBuilder_.Append(System.Uri.EscapeDataString(enumerator.Current.ToString("{{ ParameterDateFormat }}", System.Globalization.CultureInfo.InvariantCulture)));
24+
urlBuilder_.Append(',');
2725
}
2826
while (enumerator.MoveNext());
27+
28+
urlBuilder_.Length--;
2929
}
3030
}
3131
{% elsif parameter.IsDateTime -%}
@@ -37,14 +37,14 @@ using (var enumerator = {{ parameter.VariableName }}.GetEnumerator())
3737
{
3838
if (enumerator.MoveNext())
3939
{
40-
urlBuilder_.Append(ConvertToString(enumerator.Current, System.Globalization.CultureInfo.InvariantCulture));
41-
4240
do
4341
{
44-
urlBuilder_.Append(',');
4542
urlBuilder_.Append(ConvertToString(enumerator.Current, System.Globalization.CultureInfo.InvariantCulture));
43+
urlBuilder_.Append(',');
4644
}
4745
while (enumerator.MoveNext());
46+
47+
urlBuilder_.Length--;
4848
}
4949
}
5050
{% else -%}

0 commit comments

Comments
 (0)