From e2f2ffa870cdfc3c54435ff5243d5db2c1e89d50 Mon Sep 17 00:00:00 2001 From: Elzo Lubbers Date: Fri, 2 Feb 2024 15:49:00 +0100 Subject: [PATCH] Apply ParameterDateFormat to date in header as well --- .../Templates/Client.Class.HeaderParameter.liquid | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/NSwag.CodeGeneration.CSharp/Templates/Client.Class.HeaderParameter.liquid b/src/NSwag.CodeGeneration.CSharp/Templates/Client.Class.HeaderParameter.liquid index 9d686c515d..571aa4e388 100644 --- a/src/NSwag.CodeGeneration.CSharp/Templates/Client.Class.HeaderParameter.liquid +++ b/src/NSwag.CodeGeneration.CSharp/Templates/Client.Class.HeaderParameter.liquid @@ -1,7 +1,9 @@ {% if parameter.IsStringArray -%} request_.Headers.TryAddWithoutValidation("{{ parameter.Name }}", {{ parameter.VariableName }}); {% elsif parameter.IsDateTime -%} -request_.Headers.TryAddWithoutValidation("{{ parameter.Name }}", ConvertToString({{ parameter.VariableName }}{% if parameter.IsNullable %}?{% endif %}.ToString("{{ ParameterDateTimeFormat }}"), System.Globalization.CultureInfo.InvariantCulture)); +request_.Headers.TryAddWithoutValidation("{{ parameter.Name }}", ConvertToString({{ parameter.VariableName }}{% if parameter.IsNullable or parameter.IsSystemNullable %}?{% endif %}.ToString("{{ ParameterDateTimeFormat }}"), System.Globalization.CultureInfo.InvariantCulture)); +{% elsif parameter.IsDate -%} +request_.Headers.TryAddWithoutValidation("{{ parameter.Name }}", ConvertToString({{ parameter.VariableName }}{% if parameter.IsNullable or parameter.IsSystemNullable %}?{% endif %}.ToString("{{ ParameterDateFormat }}"), System.Globalization.CultureInfo.InvariantCulture)); {% else -%} request_.Headers.TryAddWithoutValidation("{{ parameter.Name }}", ConvertToString({{ parameter.VariableName }}, System.Globalization.CultureInfo.InvariantCulture)); {%- endif %}