From 7f58c57249de4986f443b00fce6e322aa4047df5 Mon Sep 17 00:00:00 2001 From: Jesper Nysteen Date: Sun, 10 May 2020 16:41:03 +0200 Subject: [PATCH] Fix locale issue for numeric string conversions (#6194) * Fix locale issue for numeric string conversions Using a generated C# client from an application with a locale that formats numbers with a comma as a decimal separator will make the client send invalid numeric parameters to the API. Any numeric parameter with decimals will added to the URL with a comma ('0,15' instead of '0.15'), potentially breaking the API integration. In my specific use case, the API interpreted '0,15' as '15', resulting in pretty funky errors. This commit ensures that parameters are parsed with the invariation culture, fixing the mentioned error. * Add missing reference to System.Globalization * Update ClientUtils.mustache --- .../src/main/resources/csharp-netcore/ClientUtils.mustache | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/ClientUtils.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/ClientUtils.mustache index f756a2c86ae..568b5b8c936 100755 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/ClientUtils.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/ClientUtils.mustache @@ -2,6 +2,7 @@ using System; using System.Collections; +using System.Globalization; using System.IO; using System.Linq; using System.Text; @@ -97,7 +98,7 @@ namespace {{packageName}}.Client if (obj is ICollection collection) return string.Join(",", collection.Cast()); - return Convert.ToString(obj); + return Convert.ToString(obj, CultureInfo.InvariantCulture); } ///