Skip to content

Commit

Permalink
Fix Nullable for form values.
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianStehle committed Aug 19, 2024
1 parent a98d8ae commit 296d73b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,12 @@
{% for parameter in operation.FormParameters %}
{% if parameter.IsNullable -%}
if ({{ parameter.VariableName }} != null)
{% else -%}
{% elsif parameter.IsNullable == false and parameter.IsRequired -%}
if ({{ parameter.VariableName }} == null)
throw new System.ArgumentNullException("{{ parameter.VariableName }}");
else
{% else -%}
if ({{ parameter.VariableName }} != null)
{% endif -%}
{
{% if parameter.IsFile -%}
Expand Down
2 changes: 1 addition & 1 deletion csharp/Squidex.ClientLibrary/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<PackageTags>Squidex HeadlessCMS</PackageTags>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<Version>19.6.0</Version>
<Version>19.7.0</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
Expand Down
52 changes: 14 additions & 38 deletions csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/Generated.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//----------------------
//----------------------
// <auto-generated>
// Generated using the NSwag toolchain v14.0.1.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0)) (http://NSwag.org)
// </auto-generated>
Expand Down Expand Up @@ -16796,26 +16796,20 @@ private static Newtonsoft.Json.JsonSerializerSettings CreateSerializerSettings()
content_.Headers.Remove("Content-Type");
content_.Headers.TryAddWithoutValidation("Content-Type", "multipart/form-data; boundary=" + boundary_);

if (file == null)
throw new System.ArgumentNullException("file");
else
if (file != null)
{
var content_file_ = new System.Net.Http.StreamContent(file.Data);
if (!string.IsNullOrEmpty(file.ContentType))
content_file_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse(file.ContentType);
content_.Add(content_file_, "file", file.FileName ?? "file");
}

if (fileUrl == null)
throw new System.ArgumentNullException("fileUrl");
else
if (fileUrl != null)
{
content_.Add(new System.Net.Http.StringContent(ConvertToString(fileUrl, System.Globalization.CultureInfo.InvariantCulture)), "fileUrl");
}

if (fileName == null)
throw new System.ArgumentNullException("fileName");
else
if (fileName != null)
{
content_.Add(new System.Net.Http.StringContent(ConvertToString(fileName, System.Globalization.CultureInfo.InvariantCulture)), "fileName");
}
Expand Down Expand Up @@ -17178,26 +17172,20 @@ private static Newtonsoft.Json.JsonSerializerSettings CreateSerializerSettings()
content_.Headers.Remove("Content-Type");
content_.Headers.TryAddWithoutValidation("Content-Type", "multipart/form-data; boundary=" + boundary_);

if (file == null)
throw new System.ArgumentNullException("file");
else
if (file != null)
{
var content_file_ = new System.Net.Http.StreamContent(file.Data);
if (!string.IsNullOrEmpty(file.ContentType))
content_file_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse(file.ContentType);
content_.Add(content_file_, "file", file.FileName ?? "file");
}

if (fileUrl == null)
throw new System.ArgumentNullException("fileUrl");
else
if (fileUrl != null)
{
content_.Add(new System.Net.Http.StringContent(ConvertToString(fileUrl, System.Globalization.CultureInfo.InvariantCulture)), "fileUrl");
}

if (fileName == null)
throw new System.ArgumentNullException("fileName");
else
if (fileName != null)
{
content_.Add(new System.Net.Http.StringContent(ConvertToString(fileName, System.Globalization.CultureInfo.InvariantCulture)), "fileName");
}
Expand Down Expand Up @@ -17675,26 +17663,20 @@ private static Newtonsoft.Json.JsonSerializerSettings CreateSerializerSettings()
content_.Headers.Remove("Content-Type");
content_.Headers.TryAddWithoutValidation("Content-Type", "multipart/form-data; boundary=" + boundary_);

if (file == null)
throw new System.ArgumentNullException("file");
else
if (file != null)
{
var content_file_ = new System.Net.Http.StreamContent(file.Data);
if (!string.IsNullOrEmpty(file.ContentType))
content_file_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse(file.ContentType);
content_.Add(content_file_, "file", file.FileName ?? "file");
}

if (fileUrl == null)
throw new System.ArgumentNullException("fileUrl");
else
if (fileUrl != null)
{
content_.Add(new System.Net.Http.StringContent(ConvertToString(fileUrl, System.Globalization.CultureInfo.InvariantCulture)), "fileUrl");
}

if (fileName == null)
throw new System.ArgumentNullException("fileName");
else
if (fileName != null)
{
content_.Add(new System.Net.Http.StringContent(ConvertToString(fileName, System.Globalization.CultureInfo.InvariantCulture)), "fileName");
}
Expand Down Expand Up @@ -19547,26 +19529,20 @@ private static Newtonsoft.Json.JsonSerializerSettings CreateSerializerSettings()
content_.Headers.Remove("Content-Type");
content_.Headers.TryAddWithoutValidation("Content-Type", "multipart/form-data; boundary=" + boundary_);

if (file == null)
throw new System.ArgumentNullException("file");
else
if (file != null)
{
var content_file_ = new System.Net.Http.StreamContent(file.Data);
if (!string.IsNullOrEmpty(file.ContentType))
content_file_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse(file.ContentType);
content_.Add(content_file_, "file", file.FileName ?? "file");
}

if (fileUrl == null)
throw new System.ArgumentNullException("fileUrl");
else
if (fileUrl != null)
{
content_.Add(new System.Net.Http.StringContent(ConvertToString(fileUrl, System.Globalization.CultureInfo.InvariantCulture)), "fileUrl");
}

if (fileName == null)
throw new System.ArgumentNullException("fileName");
else
if (fileName != null)
{
content_.Add(new System.Net.Http.StringContent(ConvertToString(fileName, System.Globalization.CultureInfo.InvariantCulture)), "fileName");
}
Expand Down Expand Up @@ -28084,4 +28060,4 @@ public SquidexException(string message, int statusCode, string response, System.
#pragma warning restore 3016
#pragma warning restore 8603
#pragma warning restore 8604
#pragma warning restore 8625
#pragma warning restore 8625

0 comments on commit 296d73b

Please sign in to comment.