Skip to content

Commit

Permalink
fix(specs): ignorePlurals can be a boolean string (generated)
Browse files Browse the repository at this point in the history
algolia/api-clients-automation#3620

Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com>
Co-authored-by: Pierre Millot <pierre.millot@algolia.com>
  • Loading branch information
algolia-bot and millotp committed Aug 30, 2024
1 parent fd2f63c commit 6a3e3a3
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 0 deletions.
31 changes: 31 additions & 0 deletions algoliasearch/Models/Recommend/BooleanString.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
//
using System;
using System.Text;
using System.Linq;
using System.Text.Json.Serialization;
using System.Collections.Generic;
using Algolia.Search.Serializer;
using System.Text.Json;

namespace Algolia.Search.Models.Recommend;

/// <summary>
/// Defines booleanString
/// </summary>
public enum BooleanString
{
/// <summary>
/// Enum True for value: true
/// </summary>
[JsonPropertyName("true")]
True = 1,

/// <summary>
/// Enum False for value: false
/// </summary>
[JsonPropertyName("false")]
False = 2
}

41 changes: 41 additions & 0 deletions algoliasearch/Models/Recommend/IgnorePlurals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ public IgnorePlurals(List<SupportedLanguage> actualInstance)
ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null.");
}

/// <summary>
/// Initializes a new instance of the IgnorePlurals class
/// with a BooleanString
/// </summary>
/// <param name="actualInstance">An instance of BooleanString.</param>
public IgnorePlurals(BooleanString actualInstance)
{
ActualInstance = actualInstance;
}

/// <summary>
/// Initializes a new instance of the IgnorePlurals class
/// with a bool
Expand All @@ -56,6 +66,16 @@ public List<SupportedLanguage> AsListSupportedLanguage()
return (List<SupportedLanguage>)ActualInstance;
}

/// <summary>
/// Get the actual instance of `BooleanString`. If the actual instance is not `BooleanString`,
/// the InvalidClassException will be thrown
/// </summary>
/// <returns>An instance of BooleanString</returns>
public BooleanString AsBooleanString()
{
return (BooleanString)ActualInstance;
}

/// <summary>
/// Get the actual instance of `bool`. If the actual instance is not `bool`,
/// the InvalidClassException will be thrown
Expand All @@ -76,6 +96,15 @@ public bool IsListSupportedLanguage()
return ActualInstance.GetType() == typeof(List<SupportedLanguage>);
}

/// <summary>
/// Check if the actual instance is of `BooleanString` type.
/// </summary>
/// <returns>Whether or not the instance is the type</returns>
public bool IsBooleanString()
{
return ActualInstance.GetType() == typeof(BooleanString);
}

/// <summary>
/// Check if the actual instance is of `bool` type.
/// </summary>
Expand Down Expand Up @@ -181,6 +210,18 @@ public override IgnorePlurals Read(ref Utf8JsonReader reader, Type typeToConvert
System.Diagnostics.Debug.WriteLine($"Failed to deserialize into List<SupportedLanguage>: {exception}");
}
}
if (root.ValueKind == JsonValueKind.String)
{
try
{
return new IgnorePlurals(jsonDocument.Deserialize<BooleanString>(JsonConfig.Options));
}
catch (Exception exception)
{
// deserialization failed, try the next one
System.Diagnostics.Debug.WriteLine($"Failed to deserialize into BooleanString: {exception}");
}
}
if (root.ValueKind == JsonValueKind.True || root.ValueKind == JsonValueKind.False)
{
try
Expand Down
31 changes: 31 additions & 0 deletions algoliasearch/Models/Search/BooleanString.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
//
using System;
using System.Text;
using System.Linq;
using System.Text.Json.Serialization;
using System.Collections.Generic;
using Algolia.Search.Serializer;
using System.Text.Json;

namespace Algolia.Search.Models.Search;

/// <summary>
/// Defines booleanString
/// </summary>
public enum BooleanString
{
/// <summary>
/// Enum True for value: true
/// </summary>
[JsonPropertyName("true")]
True = 1,

/// <summary>
/// Enum False for value: false
/// </summary>
[JsonPropertyName("false")]
False = 2
}

41 changes: 41 additions & 0 deletions algoliasearch/Models/Search/IgnorePlurals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ public IgnorePlurals(List<SupportedLanguage> actualInstance)
ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null.");
}

/// <summary>
/// Initializes a new instance of the IgnorePlurals class
/// with a BooleanString
/// </summary>
/// <param name="actualInstance">An instance of BooleanString.</param>
public IgnorePlurals(BooleanString actualInstance)
{
ActualInstance = actualInstance;
}

/// <summary>
/// Initializes a new instance of the IgnorePlurals class
/// with a bool
Expand All @@ -56,6 +66,16 @@ public List<SupportedLanguage> AsListSupportedLanguage()
return (List<SupportedLanguage>)ActualInstance;
}

/// <summary>
/// Get the actual instance of `BooleanString`. If the actual instance is not `BooleanString`,
/// the InvalidClassException will be thrown
/// </summary>
/// <returns>An instance of BooleanString</returns>
public BooleanString AsBooleanString()
{
return (BooleanString)ActualInstance;
}

/// <summary>
/// Get the actual instance of `bool`. If the actual instance is not `bool`,
/// the InvalidClassException will be thrown
Expand All @@ -76,6 +96,15 @@ public bool IsListSupportedLanguage()
return ActualInstance.GetType() == typeof(List<SupportedLanguage>);
}

/// <summary>
/// Check if the actual instance is of `BooleanString` type.
/// </summary>
/// <returns>Whether or not the instance is the type</returns>
public bool IsBooleanString()
{
return ActualInstance.GetType() == typeof(BooleanString);
}

/// <summary>
/// Check if the actual instance is of `bool` type.
/// </summary>
Expand Down Expand Up @@ -181,6 +210,18 @@ public override IgnorePlurals Read(ref Utf8JsonReader reader, Type typeToConvert
System.Diagnostics.Debug.WriteLine($"Failed to deserialize into List<SupportedLanguage>: {exception}");
}
}
if (root.ValueKind == JsonValueKind.String)
{
try
{
return new IgnorePlurals(jsonDocument.Deserialize<BooleanString>(JsonConfig.Options));
}
catch (Exception exception)
{
// deserialization failed, try the next one
System.Diagnostics.Debug.WriteLine($"Failed to deserialize into BooleanString: {exception}");
}
}
if (root.ValueKind == JsonValueKind.True || root.ValueKind == JsonValueKind.False)
{
try
Expand Down

0 comments on commit 6a3e3a3

Please sign in to comment.