Skip to content

Commit 6a3e3a3

Browse files
algolia-botmillotp
andcommitted
fix(specs): ignorePlurals can be a boolean string (generated)
algolia/api-clients-automation#3620 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Pierre Millot <[email protected]>
1 parent fd2f63c commit 6a3e3a3

File tree

4 files changed

+144
-0
lines changed

4 files changed

+144
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//
2+
// 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.
3+
//
4+
using System;
5+
using System.Text;
6+
using System.Linq;
7+
using System.Text.Json.Serialization;
8+
using System.Collections.Generic;
9+
using Algolia.Search.Serializer;
10+
using System.Text.Json;
11+
12+
namespace Algolia.Search.Models.Recommend;
13+
14+
/// <summary>
15+
/// Defines booleanString
16+
/// </summary>
17+
public enum BooleanString
18+
{
19+
/// <summary>
20+
/// Enum True for value: true
21+
/// </summary>
22+
[JsonPropertyName("true")]
23+
True = 1,
24+
25+
/// <summary>
26+
/// Enum False for value: false
27+
/// </summary>
28+
[JsonPropertyName("false")]
29+
False = 2
30+
}
31+

algoliasearch/Models/Recommend/IgnorePlurals.cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ public IgnorePlurals(List<SupportedLanguage> actualInstance)
3030
ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null.");
3131
}
3232

33+
/// <summary>
34+
/// Initializes a new instance of the IgnorePlurals class
35+
/// with a BooleanString
36+
/// </summary>
37+
/// <param name="actualInstance">An instance of BooleanString.</param>
38+
public IgnorePlurals(BooleanString actualInstance)
39+
{
40+
ActualInstance = actualInstance;
41+
}
42+
3343
/// <summary>
3444
/// Initializes a new instance of the IgnorePlurals class
3545
/// with a bool
@@ -56,6 +66,16 @@ public List<SupportedLanguage> AsListSupportedLanguage()
5666
return (List<SupportedLanguage>)ActualInstance;
5767
}
5868

69+
/// <summary>
70+
/// Get the actual instance of `BooleanString`. If the actual instance is not `BooleanString`,
71+
/// the InvalidClassException will be thrown
72+
/// </summary>
73+
/// <returns>An instance of BooleanString</returns>
74+
public BooleanString AsBooleanString()
75+
{
76+
return (BooleanString)ActualInstance;
77+
}
78+
5979
/// <summary>
6080
/// Get the actual instance of `bool`. If the actual instance is not `bool`,
6181
/// the InvalidClassException will be thrown
@@ -76,6 +96,15 @@ public bool IsListSupportedLanguage()
7696
return ActualInstance.GetType() == typeof(List<SupportedLanguage>);
7797
}
7898

99+
/// <summary>
100+
/// Check if the actual instance is of `BooleanString` type.
101+
/// </summary>
102+
/// <returns>Whether or not the instance is the type</returns>
103+
public bool IsBooleanString()
104+
{
105+
return ActualInstance.GetType() == typeof(BooleanString);
106+
}
107+
79108
/// <summary>
80109
/// Check if the actual instance is of `bool` type.
81110
/// </summary>
@@ -181,6 +210,18 @@ public override IgnorePlurals Read(ref Utf8JsonReader reader, Type typeToConvert
181210
System.Diagnostics.Debug.WriteLine($"Failed to deserialize into List<SupportedLanguage>: {exception}");
182211
}
183212
}
213+
if (root.ValueKind == JsonValueKind.String)
214+
{
215+
try
216+
{
217+
return new IgnorePlurals(jsonDocument.Deserialize<BooleanString>(JsonConfig.Options));
218+
}
219+
catch (Exception exception)
220+
{
221+
// deserialization failed, try the next one
222+
System.Diagnostics.Debug.WriteLine($"Failed to deserialize into BooleanString: {exception}");
223+
}
224+
}
184225
if (root.ValueKind == JsonValueKind.True || root.ValueKind == JsonValueKind.False)
185226
{
186227
try
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//
2+
// 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.
3+
//
4+
using System;
5+
using System.Text;
6+
using System.Linq;
7+
using System.Text.Json.Serialization;
8+
using System.Collections.Generic;
9+
using Algolia.Search.Serializer;
10+
using System.Text.Json;
11+
12+
namespace Algolia.Search.Models.Search;
13+
14+
/// <summary>
15+
/// Defines booleanString
16+
/// </summary>
17+
public enum BooleanString
18+
{
19+
/// <summary>
20+
/// Enum True for value: true
21+
/// </summary>
22+
[JsonPropertyName("true")]
23+
True = 1,
24+
25+
/// <summary>
26+
/// Enum False for value: false
27+
/// </summary>
28+
[JsonPropertyName("false")]
29+
False = 2
30+
}
31+

algoliasearch/Models/Search/IgnorePlurals.cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ public IgnorePlurals(List<SupportedLanguage> actualInstance)
3030
ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null.");
3131
}
3232

33+
/// <summary>
34+
/// Initializes a new instance of the IgnorePlurals class
35+
/// with a BooleanString
36+
/// </summary>
37+
/// <param name="actualInstance">An instance of BooleanString.</param>
38+
public IgnorePlurals(BooleanString actualInstance)
39+
{
40+
ActualInstance = actualInstance;
41+
}
42+
3343
/// <summary>
3444
/// Initializes a new instance of the IgnorePlurals class
3545
/// with a bool
@@ -56,6 +66,16 @@ public List<SupportedLanguage> AsListSupportedLanguage()
5666
return (List<SupportedLanguage>)ActualInstance;
5767
}
5868

69+
/// <summary>
70+
/// Get the actual instance of `BooleanString`. If the actual instance is not `BooleanString`,
71+
/// the InvalidClassException will be thrown
72+
/// </summary>
73+
/// <returns>An instance of BooleanString</returns>
74+
public BooleanString AsBooleanString()
75+
{
76+
return (BooleanString)ActualInstance;
77+
}
78+
5979
/// <summary>
6080
/// Get the actual instance of `bool`. If the actual instance is not `bool`,
6181
/// the InvalidClassException will be thrown
@@ -76,6 +96,15 @@ public bool IsListSupportedLanguage()
7696
return ActualInstance.GetType() == typeof(List<SupportedLanguage>);
7797
}
7898

99+
/// <summary>
100+
/// Check if the actual instance is of `BooleanString` type.
101+
/// </summary>
102+
/// <returns>Whether or not the instance is the type</returns>
103+
public bool IsBooleanString()
104+
{
105+
return ActualInstance.GetType() == typeof(BooleanString);
106+
}
107+
79108
/// <summary>
80109
/// Check if the actual instance is of `bool` type.
81110
/// </summary>
@@ -181,6 +210,18 @@ public override IgnorePlurals Read(ref Utf8JsonReader reader, Type typeToConvert
181210
System.Diagnostics.Debug.WriteLine($"Failed to deserialize into List<SupportedLanguage>: {exception}");
182211
}
183212
}
213+
if (root.ValueKind == JsonValueKind.String)
214+
{
215+
try
216+
{
217+
return new IgnorePlurals(jsonDocument.Deserialize<BooleanString>(JsonConfig.Options));
218+
}
219+
catch (Exception exception)
220+
{
221+
// deserialization failed, try the next one
222+
System.Diagnostics.Debug.WriteLine($"Failed to deserialize into BooleanString: {exception}");
223+
}
224+
}
184225
if (root.ValueKind == JsonValueKind.True || root.ValueKind == JsonValueKind.False)
185226
{
186227
try

0 commit comments

Comments
 (0)