From 30596785c27345e7c434bfcb766c469178edcd12 Mon Sep 17 00:00:00 2001 From: tjoubert Date: Wed, 30 Nov 2022 11:48:31 +0400 Subject: [PATCH 1/7] Fixes after review --- .../JsonNetApiClientSerializationTest.cs | 31 +++++++++---------- .../Serialization/ApiClientSerialization.cs | 2 +- .../ApiClientSerializationOptions.cs | 15 ++++----- .../Serialization/DictionaryValueConverter.cs | 2 +- 4 files changed, 24 insertions(+), 26 deletions(-) diff --git a/arangodb-net-standard.Test/Serialization/JsonNetApiClientSerializationTest.cs b/arangodb-net-standard.Test/Serialization/JsonNetApiClientSerializationTest.cs index 227050c5..7d9e6edc 100644 --- a/arangodb-net-standard.Test/Serialization/JsonNetApiClientSerializationTest.cs +++ b/arangodb-net-standard.Test/Serialization/JsonNetApiClientSerializationTest.cs @@ -161,8 +161,7 @@ public void Serialize_ShouldNotCamelCaseBindVars_WhenSerializingPostCursorBody() byte[] jsonBytes = serialization.Serialize(body, new ApiClientSerializationOptions( useCamelCasePropertyNames: true, - ignoreNullValues: true, - camelCasePropertyNamesOfObjectValuesInDictionaries: false)); + ignoreNullValues: true)); string jsonString = Encoding.UTF8.GetString(jsonBytes); @@ -179,22 +178,21 @@ public void Serialize_ShouldCamelCaseBindVars_WhenSerializingPostCursorBody() { BindVars = new Dictionary { - ["DontCamelCaseKey"] = new { DontCamelCaseMe = true } + ["CamelCaseKey"] = new { CamelCaseMe = true } } }; var serialization = new JsonNetApiClientSerialization(); byte[] jsonBytes = serialization.Serialize(body, new ApiClientSerializationOptions( useCamelCasePropertyNames: true, - ignoreNullValues: true, - camelCasePropertyNamesOfObjectValuesInDictionaries: true)); + ignoreNullValues: true)); string jsonString = Encoding.UTF8.GetString(jsonBytes); - Assert.Contains("DontCamelCaseKey", jsonString); - Assert.DoesNotContain("dontCamelCaseKey", jsonString); - Assert.Contains("dontCamelCaseMe", jsonString); - Assert.DoesNotContain("DontCamelCaseMe", jsonString); + Assert.Contains("CamelCaseKey", jsonString); + Assert.DoesNotContain("camelCaseKey", jsonString); + Assert.Contains("camelCaseMe", jsonString); + Assert.DoesNotContain("CamelCaseMe", jsonString); } [Fact] @@ -212,8 +210,7 @@ public void Serialize_ShouldNotCamelCaseParams_WhenSerializingPostTransactionBod byte[] jsonBytes = serialization.Serialize(body, new ApiClientSerializationOptions( useCamelCasePropertyNames: true, - ignoreNullValues: true, - camelCasePropertyNamesOfObjectValuesInDictionaries: false)); + ignoreNullValues: true)); string jsonString = Encoding.UTF8.GetString(jsonBytes); @@ -231,7 +228,7 @@ public void Serialize_ShouldCamelCaseParams_WhenSerializingPostTransactionBody() { Params = new Dictionary { - ["DontCamelCaseKey"] = new { DontCamelCaseMe = true } + ["CamelCaseKey"] = new { CamelCaseMe = true } } }; @@ -240,14 +237,14 @@ public void Serialize_ShouldCamelCaseParams_WhenSerializingPostTransactionBody() byte[] jsonBytes = serialization.Serialize(body, new ApiClientSerializationOptions( useCamelCasePropertyNames: true, ignoreNullValues: true, - camelCasePropertyNamesOfObjectValuesInDictionaries: true)); + applySerializationOptionsToObjectValuesInDictionaries: true)); string jsonString = Encoding.UTF8.GetString(jsonBytes); - Assert.Contains("DontCamelCaseKey", jsonString); - Assert.DoesNotContain("dontCamelCaseKey", jsonString); - Assert.Contains("dontCamelCaseMe", jsonString); - Assert.DoesNotContain("DontCamelCaseMe", jsonString); + Assert.Contains("CamelCaseKey", jsonString); + Assert.DoesNotContain("camelCaseKey", jsonString); + Assert.Contains("camelCaseMe", jsonString); + Assert.DoesNotContain("CamelCaseMe", jsonString); } [Fact] diff --git a/arangodb-net-standard/Serialization/ApiClientSerialization.cs b/arangodb-net-standard/Serialization/ApiClientSerialization.cs index f1608699..2956e652 100644 --- a/arangodb-net-standard/Serialization/ApiClientSerialization.cs +++ b/arangodb-net-standard/Serialization/ApiClientSerialization.cs @@ -17,7 +17,7 @@ public abstract class ApiClientSerialization : IApiClientSerialization ignoreNullValues: true, useStringEnumConversion: false, ignoreMissingMember: true, - camelCasePropertyNamesOfObjectValuesInDictionaries: false); + applySerializationOptionsToObjectValuesInDictionaries: false); /// /// Deserializes the data structure contained by the specified stream diff --git a/arangodb-net-standard/Serialization/ApiClientSerializationOptions.cs b/arangodb-net-standard/Serialization/ApiClientSerializationOptions.cs index 4fa37239..794374c3 100644 --- a/arangodb-net-standard/Serialization/ApiClientSerializationOptions.cs +++ b/arangodb-net-standard/Serialization/ApiClientSerializationOptions.cs @@ -28,12 +28,13 @@ public class ApiClientSerializationOptions public bool UseStringEnumConversion { get; set; } /// - /// True to camel case the names of properties of object values + /// True to apply serialization options to object values /// in dictionaries (i.e. CamelCaseMe => "camelCaseMe"). - /// False to leave the names of properties of object values - /// in dictionaries as they are (i.e. DontCamelCaseMe => "DontCamelCaseMe") + /// False to not apply serialization options to object values + /// in dictionaries (i.e. leave the names of properties of object values + /// in dictionaries as they are: DontCamelCaseMe => "DontCamelCaseMe") /// - public bool CamelCasePropertyNamesOfObjectValuesInDictionaries { get; set; } + public bool ApplySerializationOptionsToObjectValuesInDictionaries { get; set; } /// /// Create serialization options. @@ -42,19 +43,19 @@ public class ApiClientSerializationOptions /// Whether null values should be ignored - i.e. not defined at all in the serialized string. /// Whether to serialize enum values to a string value instead of an integer. /// Whether missing members should be ignored. - /// Whether to camel case the names of properties of object values in dictionaries. + /// Whether to apply serialization options to object values in dictionaries. public ApiClientSerializationOptions( bool useCamelCasePropertyNames, bool ignoreNullValues, bool useStringEnumConversion = false, bool ignoreMissingMember = true, - bool camelCasePropertyNamesOfObjectValuesInDictionaries = false) + bool applySerializationOptionsToObjectValuesInDictionaries = false) { UseCamelCasePropertyNames = useCamelCasePropertyNames; IgnoreNullValues = ignoreNullValues; UseStringEnumConversion = useStringEnumConversion; IgnoreMissingMember = ignoreMissingMember; - CamelCasePropertyNamesOfObjectValuesInDictionaries = camelCasePropertyNamesOfObjectValuesInDictionaries; + ApplySerializationOptionsToObjectValuesInDictionaries = applySerializationOptionsToObjectValuesInDictionaries; } } } \ No newline at end of file diff --git a/arangodb-net-standard/Serialization/DictionaryValueConverter.cs b/arangodb-net-standard/Serialization/DictionaryValueConverter.cs index 42a4b81a..c6a3f3db 100644 --- a/arangodb-net-standard/Serialization/DictionaryValueConverter.cs +++ b/arangodb-net-standard/Serialization/DictionaryValueConverter.cs @@ -31,7 +31,7 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s { // Use a local serializer for writing instead of the passed-in serializer JsonSerializer mySerializer; - if (_serializationOptions != null && _serializationOptions.CamelCasePropertyNamesOfObjectValuesInDictionaries) + if (_serializationOptions != null && _serializationOptions.ApplySerializationOptionsToObjectValuesInDictionaries) { mySerializer = new JsonSerializer { From b32f42c876a7dbea23a0ca510571b59fa9665e8f Mon Sep 17 00:00:00 2001 From: tjoubert Date: Wed, 30 Nov 2022 11:52:41 +0400 Subject: [PATCH 2/7] Fixed tests --- .../Serialization/JsonNetApiClientSerializationTest.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arangodb-net-standard.Test/Serialization/JsonNetApiClientSerializationTest.cs b/arangodb-net-standard.Test/Serialization/JsonNetApiClientSerializationTest.cs index 7d9e6edc..a60e4148 100644 --- a/arangodb-net-standard.Test/Serialization/JsonNetApiClientSerializationTest.cs +++ b/arangodb-net-standard.Test/Serialization/JsonNetApiClientSerializationTest.cs @@ -185,7 +185,8 @@ public void Serialize_ShouldCamelCaseBindVars_WhenSerializingPostCursorBody() byte[] jsonBytes = serialization.Serialize(body, new ApiClientSerializationOptions( useCamelCasePropertyNames: true, - ignoreNullValues: true)); + ignoreNullValues: true, + applySerializationOptionsToObjectValuesInDictionaries: true)); string jsonString = Encoding.UTF8.GetString(jsonBytes); From e69c3a97fee37753457e4958be1b3f28e22f9965 Mon Sep 17 00:00:00 2001 From: tjoubert Date: Mon, 5 Dec 2022 11:44:33 +0400 Subject: [PATCH 3/7] Added custom ApiClientSerializationOptions parameter to PostCreateViewAsync() --- .../Serialization/JsonNetApiClientSerializationTest.cs | 4 ++-- arangodb-net-standard/ViewApi/IViewsApiClient.cs | 6 ++++-- arangodb-net-standard/ViewApi/ViewsApiClient.cs | 8 ++++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/arangodb-net-standard.Test/Serialization/JsonNetApiClientSerializationTest.cs b/arangodb-net-standard.Test/Serialization/JsonNetApiClientSerializationTest.cs index a60e4148..edfdf427 100644 --- a/arangodb-net-standard.Test/Serialization/JsonNetApiClientSerializationTest.cs +++ b/arangodb-net-standard.Test/Serialization/JsonNetApiClientSerializationTest.cs @@ -172,7 +172,7 @@ public void Serialize_ShouldNotCamelCaseBindVars_WhenSerializingPostCursorBody() } [Fact] - public void Serialize_ShouldCamelCaseBindVars_WhenSerializingPostCursorBody() + public void Serialize_ShouldCamelCaseBindVars_WhenSerializingPostCursorBodyWithDictionaryOption() { var body = new PostCursorBody { @@ -223,7 +223,7 @@ public void Serialize_ShouldNotCamelCaseParams_WhenSerializingPostTransactionBod [Fact] - public void Serialize_ShouldCamelCaseParams_WhenSerializingPostTransactionBody() + public void Serialize_ShouldCamelCaseParams_WhenSerializingPostTransactionBodyWithDictionaryOption() { var body = new PostTransactionBody { diff --git a/arangodb-net-standard/ViewApi/IViewsApiClient.cs b/arangodb-net-standard/ViewApi/IViewsApiClient.cs index 70214952..9aab6e1a 100644 --- a/arangodb-net-standard/ViewApi/IViewsApiClient.cs +++ b/arangodb-net-standard/ViewApi/IViewsApiClient.cs @@ -1,4 +1,5 @@ -using ArangoDBNetStandard.ViewApi.Models; +using ArangoDBNetStandard.Serialization; +using ArangoDBNetStandard.ViewApi.Models; using System.Threading.Tasks; namespace ArangoDBNetStandard.ViewApi @@ -21,8 +22,9 @@ public interface IViewApiClient /// POST /_api/view /// /// The body of the request containing required properties. + /// Custom serialization options to be used. /// - Task PostCreateViewAsync(ViewDetails body); + Task PostCreateViewAsync(ViewDetails body, ApiClientSerializationOptions serializationOptions = null); /// /// Delete / drop a view diff --git a/arangodb-net-standard/ViewApi/ViewsApiClient.cs b/arangodb-net-standard/ViewApi/ViewsApiClient.cs index 689a91eb..2214db29 100644 --- a/arangodb-net-standard/ViewApi/ViewsApiClient.cs +++ b/arangodb-net-standard/ViewApi/ViewsApiClient.cs @@ -70,11 +70,15 @@ public virtual async Task GetAllViewsAsync() /// POST /_api/view /// /// The body of the request containing required properties. + /// Custom serialization options to be used. /// - public virtual async Task PostCreateViewAsync(ViewDetails body) + public virtual async Task PostCreateViewAsync(ViewDetails body, ApiClientSerializationOptions serializationOptions = null) { string uri = _apiPath; - var content = GetContent(body, new ApiClientSerializationOptions(true, true)); + var content = GetContent(body, + serializationOptions ?? new ApiClientSerializationOptions( + useCamelCasePropertyNames: true, + ignoreNullValues: true)); using (var response = await _transport.PostAsync(uri, content).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) From e43e6623c68e14a626e7b1654d45689872367808 Mon Sep 17 00:00:00 2001 From: tjoubert Date: Tue, 6 Dec 2022 08:33:55 +0400 Subject: [PATCH 4/7] Removed serializationOptions parameter from PostCreateViewAsync(). Applied changes to PatchViewPropertiesAsync() and PutViewPropertiesAsync() --- .../JsonNetApiClientSerializationTest.cs | 4 ++-- .../Serialization/ApiClientSerialization.cs | 2 +- .../ApiClientSerializationOptions.cs | 8 +++---- .../Serialization/DictionaryValueConverter.cs | 2 +- .../ViewApi/IViewsApiClient.cs | 3 +-- .../ViewApi/ViewsApiClient.cs | 22 +++++++++++++------ 6 files changed, 24 insertions(+), 17 deletions(-) diff --git a/arangodb-net-standard.Test/Serialization/JsonNetApiClientSerializationTest.cs b/arangodb-net-standard.Test/Serialization/JsonNetApiClientSerializationTest.cs index edfdf427..2fde95a7 100644 --- a/arangodb-net-standard.Test/Serialization/JsonNetApiClientSerializationTest.cs +++ b/arangodb-net-standard.Test/Serialization/JsonNetApiClientSerializationTest.cs @@ -186,7 +186,7 @@ public void Serialize_ShouldCamelCaseBindVars_WhenSerializingPostCursorBodyWithD byte[] jsonBytes = serialization.Serialize(body, new ApiClientSerializationOptions( useCamelCasePropertyNames: true, ignoreNullValues: true, - applySerializationOptionsToObjectValuesInDictionaries: true)); + applySerializationOptionsToDictionaryValues: true)); string jsonString = Encoding.UTF8.GetString(jsonBytes); @@ -238,7 +238,7 @@ public void Serialize_ShouldCamelCaseParams_WhenSerializingPostTransactionBodyWi byte[] jsonBytes = serialization.Serialize(body, new ApiClientSerializationOptions( useCamelCasePropertyNames: true, ignoreNullValues: true, - applySerializationOptionsToObjectValuesInDictionaries: true)); + applySerializationOptionsToDictionaryValues: true)); string jsonString = Encoding.UTF8.GetString(jsonBytes); diff --git a/arangodb-net-standard/Serialization/ApiClientSerialization.cs b/arangodb-net-standard/Serialization/ApiClientSerialization.cs index 2956e652..a8245d16 100644 --- a/arangodb-net-standard/Serialization/ApiClientSerialization.cs +++ b/arangodb-net-standard/Serialization/ApiClientSerialization.cs @@ -17,7 +17,7 @@ public abstract class ApiClientSerialization : IApiClientSerialization ignoreNullValues: true, useStringEnumConversion: false, ignoreMissingMember: true, - applySerializationOptionsToObjectValuesInDictionaries: false); + applySerializationOptionsToDictionaryValues: false); /// /// Deserializes the data structure contained by the specified stream diff --git a/arangodb-net-standard/Serialization/ApiClientSerializationOptions.cs b/arangodb-net-standard/Serialization/ApiClientSerializationOptions.cs index 794374c3..d825ac83 100644 --- a/arangodb-net-standard/Serialization/ApiClientSerializationOptions.cs +++ b/arangodb-net-standard/Serialization/ApiClientSerializationOptions.cs @@ -34,7 +34,7 @@ public class ApiClientSerializationOptions /// in dictionaries (i.e. leave the names of properties of object values /// in dictionaries as they are: DontCamelCaseMe => "DontCamelCaseMe") /// - public bool ApplySerializationOptionsToObjectValuesInDictionaries { get; set; } + public bool ApplySerializationOptionsToDictionaryValues { get; set; } /// /// Create serialization options. @@ -43,19 +43,19 @@ public class ApiClientSerializationOptions /// Whether null values should be ignored - i.e. not defined at all in the serialized string. /// Whether to serialize enum values to a string value instead of an integer. /// Whether missing members should be ignored. - /// Whether to apply serialization options to object values in dictionaries. + /// Whether to apply serialization options to object values in dictionaries. public ApiClientSerializationOptions( bool useCamelCasePropertyNames, bool ignoreNullValues, bool useStringEnumConversion = false, bool ignoreMissingMember = true, - bool applySerializationOptionsToObjectValuesInDictionaries = false) + bool applySerializationOptionsToDictionaryValues = false) { UseCamelCasePropertyNames = useCamelCasePropertyNames; IgnoreNullValues = ignoreNullValues; UseStringEnumConversion = useStringEnumConversion; IgnoreMissingMember = ignoreMissingMember; - ApplySerializationOptionsToObjectValuesInDictionaries = applySerializationOptionsToObjectValuesInDictionaries; + ApplySerializationOptionsToDictionaryValues = applySerializationOptionsToDictionaryValues; } } } \ No newline at end of file diff --git a/arangodb-net-standard/Serialization/DictionaryValueConverter.cs b/arangodb-net-standard/Serialization/DictionaryValueConverter.cs index c6a3f3db..65125f92 100644 --- a/arangodb-net-standard/Serialization/DictionaryValueConverter.cs +++ b/arangodb-net-standard/Serialization/DictionaryValueConverter.cs @@ -31,7 +31,7 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s { // Use a local serializer for writing instead of the passed-in serializer JsonSerializer mySerializer; - if (_serializationOptions != null && _serializationOptions.ApplySerializationOptionsToObjectValuesInDictionaries) + if (_serializationOptions != null && _serializationOptions.ApplySerializationOptionsToDictionaryValues) { mySerializer = new JsonSerializer { diff --git a/arangodb-net-standard/ViewApi/IViewsApiClient.cs b/arangodb-net-standard/ViewApi/IViewsApiClient.cs index d27a3fe0..09972166 100644 --- a/arangodb-net-standard/ViewApi/IViewsApiClient.cs +++ b/arangodb-net-standard/ViewApi/IViewsApiClient.cs @@ -25,10 +25,9 @@ Task GetAllViewsAsync( /// POST /_api/view /// /// The body of the request containing required properties. - /// Custom serialization options to be used. /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - Task PostCreateViewAsync(ViewDetails body, ApiClientSerializationOptions serializationOptions = null, CancellationToken token = default); + Task PostCreateViewAsync(ViewDetails body, CancellationToken token = default); /// /// Delete / drop a view diff --git a/arangodb-net-standard/ViewApi/ViewsApiClient.cs b/arangodb-net-standard/ViewApi/ViewsApiClient.cs index e8bdbd5c..39eae554 100644 --- a/arangodb-net-standard/ViewApi/ViewsApiClient.cs +++ b/arangodb-net-standard/ViewApi/ViewsApiClient.cs @@ -73,16 +73,16 @@ public virtual async Task GetAllViewsAsync( /// POST /_api/view /// /// The body of the request containing required properties. - /// Custom serialization options to be used. /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - public virtual async Task PostCreateViewAsync(ViewDetails body, ApiClientSerializationOptions serializationOptions = null, CancellationToken token = default) + public virtual async Task PostCreateViewAsync(ViewDetails body, CancellationToken token = default) { string uri = _apiPath; var content = GetContent(body, - serializationOptions ?? new ApiClientSerializationOptions( - useCamelCasePropertyNames: true, - ignoreNullValues: true)); + new ApiClientSerializationOptions( + useCamelCasePropertyNames: true, + ignoreNullValues: false, + applySerializationOptionsToDictionaryValues: true)); using (var response = await _transport.PostAsync(uri, content).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) @@ -172,7 +172,11 @@ public virtual async Task PatchViewPropertiesAsync(string viewName CancellationToken token = default) { string uri = $"{_apiPath}/{viewNameOrId}/properties"; - var content = GetContent(body, new ApiClientSerializationOptions(true, true)); + var content = GetContent(body, + new ApiClientSerializationOptions( + useCamelCasePropertyNames: true, + ignoreNullValues: false, + applySerializationOptionsToDictionaryValues: true)); using (var response = await _transport.PatchAsync(uri, content, token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) @@ -196,7 +200,11 @@ public virtual async Task PutViewPropertiesAsync(string viewName, CancellationToken token = default) { string uri = $"{_apiPath}/{viewName}/properties"; - var content = GetContent(body, new ApiClientSerializationOptions(true, true)); + var content = GetContent(body, + new ApiClientSerializationOptions( + useCamelCasePropertyNames: true, + ignoreNullValues: false, + applySerializationOptionsToDictionaryValues: true)); using (var response = await _transport.PutAsync(uri, content, token: token).ConfigureAwait(false)) { if (response.IsSuccessStatusCode) From 194010da31dc685dd9c6cc478883319a9e84d02b Mon Sep 17 00:00:00 2001 From: tjoubert Date: Tue, 6 Dec 2022 08:57:39 +0400 Subject: [PATCH 5/7] Added ignoreNullValuesOnSerialization parameter to PostCreateViewAsync(), PatchViewPropertiesAsync() and PutViewPropertiesAsync() --- .../ViewApi/IViewsApiClient.cs | 9 ++++++--- arangodb-net-standard/ViewApi/ViewsApiClient.cs | 17 ++++++++++------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/arangodb-net-standard/ViewApi/IViewsApiClient.cs b/arangodb-net-standard/ViewApi/IViewsApiClient.cs index 09972166..6458a2e6 100644 --- a/arangodb-net-standard/ViewApi/IViewsApiClient.cs +++ b/arangodb-net-standard/ViewApi/IViewsApiClient.cs @@ -25,9 +25,10 @@ Task GetAllViewsAsync( /// POST /_api/view /// /// The body of the request containing required properties. + /// Indicates whether to ignore null values during serialization. /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - Task PostCreateViewAsync(ViewDetails body, CancellationToken token = default); + Task PostCreateViewAsync(ViewDetails body, bool ignoreNullValuesOnSerialization = true, CancellationToken token = default); /// /// Delete / drop a view @@ -65,9 +66,10 @@ Task GetViewPropertiesAsync(string viewNameOrId, /// /// The name or identifier of the view. /// The body of the request containing required properties. + /// Indicates whether to ignore null values during serialization. /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - Task PatchViewPropertiesAsync(string viewNameOrId, ViewDetails body, + Task PatchViewPropertiesAsync(string viewNameOrId, ViewDetails body, bool ignoreNullValuesOnSerialization = true, CancellationToken token = default); /// @@ -76,9 +78,10 @@ Task PatchViewPropertiesAsync(string viewNameOrId, ViewDetails bod /// /// The name of the view. /// The body of the request containing required properties. + /// Indicates whether to ignore null values during serialization. /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - Task PutViewPropertiesAsync(string viewName, ViewDetails body, + Task PutViewPropertiesAsync(string viewName, ViewDetails body, bool ignoreNullValuesOnSerialization = true, CancellationToken token = default); /// diff --git a/arangodb-net-standard/ViewApi/ViewsApiClient.cs b/arangodb-net-standard/ViewApi/ViewsApiClient.cs index 39eae554..98c10f9a 100644 --- a/arangodb-net-standard/ViewApi/ViewsApiClient.cs +++ b/arangodb-net-standard/ViewApi/ViewsApiClient.cs @@ -72,16 +72,17 @@ public virtual async Task GetAllViewsAsync( /// Create a new View /// POST /_api/view /// - /// The body of the request containing required properties. + /// The body of the request containing required properties. + /// Indicates whether to ignore null values during serialization. /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - public virtual async Task PostCreateViewAsync(ViewDetails body, CancellationToken token = default) + public virtual async Task PostCreateViewAsync(ViewDetails body, bool ignoreNullValuesOnSerialization=true, CancellationToken token = default) { string uri = _apiPath; var content = GetContent(body, new ApiClientSerializationOptions( useCamelCasePropertyNames: true, - ignoreNullValues: false, + ignoreNullValues: ignoreNullValuesOnSerialization, applySerializationOptionsToDictionaryValues: true)); using (var response = await _transport.PostAsync(uri, content).ConfigureAwait(false)) { @@ -166,16 +167,17 @@ public virtual async Task GetViewPropertiesAsync(stri /// /// The name or identifier of the view. /// The body of the request containing required properties. + /// Indicates whether to ignore null values during serialization. /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - public virtual async Task PatchViewPropertiesAsync(string viewNameOrId, ViewDetails body, + public virtual async Task PatchViewPropertiesAsync(string viewNameOrId, ViewDetails body, bool ignoreNullValuesOnSerialization = true, CancellationToken token = default) { string uri = $"{_apiPath}/{viewNameOrId}/properties"; var content = GetContent(body, new ApiClientSerializationOptions( useCamelCasePropertyNames: true, - ignoreNullValues: false, + ignoreNullValues: ignoreNullValuesOnSerialization, applySerializationOptionsToDictionaryValues: true)); using (var response = await _transport.PatchAsync(uri, content, token: token).ConfigureAwait(false)) { @@ -194,16 +196,17 @@ public virtual async Task PatchViewPropertiesAsync(string viewName /// /// The name of the view. /// The body of the request containing required properties. + /// Indicates whether to ignore null values during serialization. /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - public virtual async Task PutViewPropertiesAsync(string viewName, ViewDetails body, + public virtual async Task PutViewPropertiesAsync(string viewName, ViewDetails body, bool ignoreNullValuesOnSerialization = true, CancellationToken token = default) { string uri = $"{_apiPath}/{viewName}/properties"; var content = GetContent(body, new ApiClientSerializationOptions( useCamelCasePropertyNames: true, - ignoreNullValues: false, + ignoreNullValues: ignoreNullValuesOnSerialization, applySerializationOptionsToDictionaryValues: true)); using (var response = await _transport.PutAsync(uri, content, token: token).ConfigureAwait(false)) { From 5ae3706cbec1d72939b35e4a1df6ddfc49417e8d Mon Sep 17 00:00:00 2001 From: tjoubert Date: Tue, 6 Dec 2022 09:04:18 +0400 Subject: [PATCH 6/7] Reformatted code file --- arangodb-net-standard/ViewApi/ViewsApiClient.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arangodb-net-standard/ViewApi/ViewsApiClient.cs b/arangodb-net-standard/ViewApi/ViewsApiClient.cs index 98c10f9a..fb46f454 100644 --- a/arangodb-net-standard/ViewApi/ViewsApiClient.cs +++ b/arangodb-net-standard/ViewApi/ViewsApiClient.cs @@ -170,8 +170,8 @@ public virtual async Task GetViewPropertiesAsync(stri /// Indicates whether to ignore null values during serialization. /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - public virtual async Task PatchViewPropertiesAsync(string viewNameOrId, ViewDetails body, bool ignoreNullValuesOnSerialization = true, - CancellationToken token = default) + public virtual async Task PatchViewPropertiesAsync(string viewNameOrId, ViewDetails body, + bool ignoreNullValuesOnSerialization = true, CancellationToken token = default) { string uri = $"{_apiPath}/{viewNameOrId}/properties"; var content = GetContent(body, @@ -199,8 +199,8 @@ public virtual async Task PatchViewPropertiesAsync(string viewName /// Indicates whether to ignore null values during serialization. /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// - public virtual async Task PutViewPropertiesAsync(string viewName, ViewDetails body, bool ignoreNullValuesOnSerialization = true, - CancellationToken token = default) + public virtual async Task PutViewPropertiesAsync(string viewName, ViewDetails body, + bool ignoreNullValuesOnSerialization = true, CancellationToken token = default) { string uri = $"{_apiPath}/{viewName}/properties"; var content = GetContent(body, From 43cee7b4beb7ae1e0ef3433be6546060cf6eadc7 Mon Sep 17 00:00:00 2001 From: tjoubert Date: Tue, 20 Dec 2022 11:56:41 +0400 Subject: [PATCH 7/7] Fixed comments --- .../ViewApi/IViewsApiClient.cs | 18 +++++++++++++++--- .../ViewApi/ViewsApiClient.cs | 18 +++++++++++++++--- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/arangodb-net-standard/ViewApi/IViewsApiClient.cs b/arangodb-net-standard/ViewApi/IViewsApiClient.cs index 6458a2e6..e9fa96ac 100644 --- a/arangodb-net-standard/ViewApi/IViewsApiClient.cs +++ b/arangodb-net-standard/ViewApi/IViewsApiClient.cs @@ -25,7 +25,11 @@ Task GetAllViewsAsync( /// POST /_api/view /// /// The body of the request containing required properties. - /// Indicates whether to ignore null values during serialization. + /// + /// Indicates whether to ignore null values during serialization. + /// This parameter can be used together with + /// set to false to control if fields with null values are included. + /// /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task PostCreateViewAsync(ViewDetails body, bool ignoreNullValuesOnSerialization = true, CancellationToken token = default); @@ -66,7 +70,11 @@ Task GetViewPropertiesAsync(string viewNameOrId, /// /// The name or identifier of the view. /// The body of the request containing required properties. - /// Indicates whether to ignore null values during serialization. + /// + /// Indicates whether to ignore null values during serialization. + /// This parameter can be used together with + /// set to false to control if fields with null values are included. + /// /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task PatchViewPropertiesAsync(string viewNameOrId, ViewDetails body, bool ignoreNullValuesOnSerialization = true, @@ -78,7 +86,11 @@ Task PatchViewPropertiesAsync(string viewNameOrId, ViewDetails bod /// /// The name of the view. /// The body of the request containing required properties. - /// Indicates whether to ignore null values during serialization. + /// + /// Indicates whether to ignore null values during serialization. + /// This parameter can be used together with + /// set to false to control if fields with null values are included. + /// /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// Task PutViewPropertiesAsync(string viewName, ViewDetails body, bool ignoreNullValuesOnSerialization = true, diff --git a/arangodb-net-standard/ViewApi/ViewsApiClient.cs b/arangodb-net-standard/ViewApi/ViewsApiClient.cs index fb46f454..d605c5c0 100644 --- a/arangodb-net-standard/ViewApi/ViewsApiClient.cs +++ b/arangodb-net-standard/ViewApi/ViewsApiClient.cs @@ -73,7 +73,11 @@ public virtual async Task GetAllViewsAsync( /// POST /_api/view /// /// The body of the request containing required properties. - /// Indicates whether to ignore null values during serialization. + /// + /// Indicates whether to ignore null values during serialization. + /// This parameter can be used together with + /// set to false to control if fields with null values are included. + /// /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task PostCreateViewAsync(ViewDetails body, bool ignoreNullValuesOnSerialization=true, CancellationToken token = default) @@ -167,7 +171,11 @@ public virtual async Task GetViewPropertiesAsync(stri /// /// The name or identifier of the view. /// The body of the request containing required properties. - /// Indicates whether to ignore null values during serialization. + /// + /// Indicates whether to ignore null values during serialization. + /// This parameter can be used together with + /// set to false to control if fields with null values are included. + /// /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task PatchViewPropertiesAsync(string viewNameOrId, ViewDetails body, @@ -196,7 +204,11 @@ public virtual async Task PatchViewPropertiesAsync(string viewName /// /// The name of the view. /// The body of the request containing required properties. - /// Indicates whether to ignore null values during serialization. + /// + /// Indicates whether to ignore null values during serialization. + /// This parameter can be used together with + /// set to false to control if fields with null values are included. + /// /// A CancellationToken to observe while waiting for the task to complete or to cancel the task. /// public virtual async Task PutViewPropertiesAsync(string viewName, ViewDetails body,