Skip to content

Commit ead78f1

Browse files
feat(specs): recursive snippets and highlights result (#3497) (generated) [skip ci]
Co-authored-by: Clément Vannicatte <[email protected]>
1 parent 4c05200 commit ead78f1

File tree

164 files changed

+1066
-479
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

164 files changed

+1066
-479
lines changed

clients/algoliasearch-client-csharp/algoliasearch/Models/Recommend/AroundPrecision.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public int AsInt()
6161
/// the InvalidClassException will be thrown
6262
/// </summary>
6363
/// <returns>An instance of List&lt;Range&gt;</returns>
64-
public List<Range> AsList()
64+
public List<Range> AsListRange()
6565
{
6666
return (List<Range>)ActualInstance;
6767
}
@@ -80,7 +80,7 @@ public bool IsInt()
8080
/// Check if the actual instance is of `List{Range}` type.
8181
/// </summary>
8282
/// <returns>Whether or not the instance is the type</returns>
83-
public bool IsList()
83+
public bool IsListRange()
8484
{
8585
return ActualInstance.GetType() == typeof(List<Range>);
8686
}

clients/algoliasearch-client-csharp/algoliasearch/Models/Recommend/FacetFilters.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public FacetFilters(string actualInstance)
5151
/// the InvalidClassException will be thrown
5252
/// </summary>
5353
/// <returns>An instance of List&lt;FacetFilters&gt;</returns>
54-
public List<FacetFilters> AsList()
54+
public List<FacetFilters> AsListFacetFilters()
5555
{
5656
return (List<FacetFilters>)ActualInstance;
5757
}
@@ -71,7 +71,7 @@ public string AsString()
7171
/// Check if the actual instance is of `List{FacetFilters}` type.
7272
/// </summary>
7373
/// <returns>Whether or not the instance is the type</returns>
74-
public bool IsList()
74+
public bool IsListFacetFilters()
7575
{
7676
return ActualInstance.GetType() == typeof(List<FacetFilters>);
7777
}

clients/algoliasearch-client-csharp/algoliasearch/Models/Recommend/HighlightResult.cs

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ namespace Algolia.Search.Models.Recommend;
2020
[JsonConverter(typeof(HighlightResultJsonConverter))]
2121
public partial class HighlightResult : AbstractSchema
2222
{
23+
/// <summary>
24+
/// Initializes a new instance of the HighlightResult class
25+
/// with a Dictionary{string, HighlightResult}
26+
/// </summary>
27+
/// <param name="actualInstance">An instance of Dictionary&lt;string, HighlightResult&gt;.</param>
28+
public HighlightResult(Dictionary<string, HighlightResult> actualInstance)
29+
{
30+
ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null.");
31+
}
32+
2333
/// <summary>
2434
/// Initializes a new instance of the HighlightResult class
2535
/// with a HighlightResultOption
@@ -56,6 +66,16 @@ public HighlightResult(List<HighlightResultOption> actualInstance)
5666
/// </summary>
5767
public sealed override object ActualInstance { get; set; }
5868

69+
/// <summary>
70+
/// Get the actual instance of `Dictionary{string, HighlightResult}`. If the actual instance is not `Dictionary{string, HighlightResult}`,
71+
/// the InvalidClassException will be thrown
72+
/// </summary>
73+
/// <returns>An instance of Dictionary&lt;string, HighlightResult&gt;</returns>
74+
public Dictionary<string, HighlightResult> AsDictionaryHighlightResult()
75+
{
76+
return (Dictionary<string, HighlightResult>)ActualInstance;
77+
}
78+
5979
/// <summary>
6080
/// Get the actual instance of `HighlightResultOption`. If the actual instance is not `HighlightResultOption`,
6181
/// the InvalidClassException will be thrown
@@ -71,7 +91,7 @@ public HighlightResultOption AsHighlightResultOption()
7191
/// the InvalidClassException will be thrown
7292
/// </summary>
7393
/// <returns>An instance of Dictionary&lt;string, HighlightResultOption&gt;</returns>
74-
public Dictionary<string, HighlightResultOption> AsDictionary()
94+
public Dictionary<string, HighlightResultOption> AsDictionaryHighlightResultOption()
7595
{
7696
return (Dictionary<string, HighlightResultOption>)ActualInstance;
7797
}
@@ -81,12 +101,21 @@ public Dictionary<string, HighlightResultOption> AsDictionary()
81101
/// the InvalidClassException will be thrown
82102
/// </summary>
83103
/// <returns>An instance of List&lt;HighlightResultOption&gt;</returns>
84-
public List<HighlightResultOption> AsList()
104+
public List<HighlightResultOption> AsListHighlightResultOption()
85105
{
86106
return (List<HighlightResultOption>)ActualInstance;
87107
}
88108

89109

110+
/// <summary>
111+
/// Check if the actual instance is of `Dictionary{string, HighlightResult}` type.
112+
/// </summary>
113+
/// <returns>Whether or not the instance is the type</returns>
114+
public bool IsDictionaryHighlightResult()
115+
{
116+
return ActualInstance.GetType() == typeof(Dictionary<string, HighlightResult>);
117+
}
118+
90119
/// <summary>
91120
/// Check if the actual instance is of `HighlightResultOption` type.
92121
/// </summary>
@@ -100,7 +129,7 @@ public bool IsHighlightResultOption()
100129
/// Check if the actual instance is of `Dictionary{string, HighlightResultOption}` type.
101130
/// </summary>
102131
/// <returns>Whether or not the instance is the type</returns>
103-
public bool IsDictionary()
132+
public bool IsDictionaryHighlightResultOption()
104133
{
105134
return ActualInstance.GetType() == typeof(Dictionary<string, HighlightResultOption>);
106135
}
@@ -109,7 +138,7 @@ public bool IsDictionary()
109138
/// Check if the actual instance is of `List{HighlightResultOption}` type.
110139
/// </summary>
111140
/// <returns>Whether or not the instance is the type</returns>
112-
public bool IsList()
141+
public bool IsListHighlightResultOption()
113142
{
114143
return ActualInstance.GetType() == typeof(List<HighlightResultOption>);
115144
}
@@ -199,6 +228,18 @@ public override HighlightResult Read(ref Utf8JsonReader reader, Type typeToConve
199228
var jsonDocument = JsonDocument.ParseValue(ref reader);
200229
var root = jsonDocument.RootElement;
201230
if (root.ValueKind == JsonValueKind.Object)
231+
{
232+
try
233+
{
234+
return new HighlightResult(jsonDocument.Deserialize<Dictionary<string, HighlightResult>>(JsonConfig.Options));
235+
}
236+
catch (Exception exception)
237+
{
238+
// deserialization failed, try the next one
239+
System.Diagnostics.Debug.WriteLine($"Failed to deserialize into Dictionary<string, HighlightResult>: {exception}");
240+
}
241+
}
242+
if (root.ValueKind == JsonValueKind.Object)
202243
{
203244
try
204245
{

clients/algoliasearch-client-csharp/algoliasearch/Models/Recommend/IgnorePlurals.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public IgnorePlurals(bool actualInstance)
5151
/// the InvalidClassException will be thrown
5252
/// </summary>
5353
/// <returns>An instance of List&lt;SupportedLanguage&gt;</returns>
54-
public List<SupportedLanguage> AsList()
54+
public List<SupportedLanguage> AsListSupportedLanguage()
5555
{
5656
return (List<SupportedLanguage>)ActualInstance;
5757
}
@@ -71,7 +71,7 @@ public bool AsBool()
7171
/// Check if the actual instance is of `List{SupportedLanguage}` type.
7272
/// </summary>
7373
/// <returns>Whether or not the instance is the type</returns>
74-
public bool IsList()
74+
public bool IsListSupportedLanguage()
7575
{
7676
return ActualInstance.GetType() == typeof(List<SupportedLanguage>);
7777
}

clients/algoliasearch-client-csharp/algoliasearch/Models/Recommend/NumericFilters.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public NumericFilters(string actualInstance)
5151
/// the InvalidClassException will be thrown
5252
/// </summary>
5353
/// <returns>An instance of List&lt;NumericFilters&gt;</returns>
54-
public List<NumericFilters> AsList()
54+
public List<NumericFilters> AsListNumericFilters()
5555
{
5656
return (List<NumericFilters>)ActualInstance;
5757
}
@@ -71,7 +71,7 @@ public string AsString()
7171
/// Check if the actual instance is of `List{NumericFilters}` type.
7272
/// </summary>
7373
/// <returns>Whether or not the instance is the type</returns>
74-
public bool IsList()
74+
public bool IsListNumericFilters()
7575
{
7676
return ActualInstance.GetType() == typeof(List<NumericFilters>);
7777
}

clients/algoliasearch-client-csharp/algoliasearch/Models/Recommend/OptionalFilters.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public OptionalFilters(string actualInstance)
5151
/// the InvalidClassException will be thrown
5252
/// </summary>
5353
/// <returns>An instance of List&lt;OptionalFilters&gt;</returns>
54-
public List<OptionalFilters> AsList()
54+
public List<OptionalFilters> AsListOptionalFilters()
5555
{
5656
return (List<OptionalFilters>)ActualInstance;
5757
}
@@ -71,7 +71,7 @@ public string AsString()
7171
/// Check if the actual instance is of `List{OptionalFilters}` type.
7272
/// </summary>
7373
/// <returns>Whether or not the instance is the type</returns>
74-
public bool IsList()
74+
public bool IsListOptionalFilters()
7575
{
7676
return ActualInstance.GetType() == typeof(List<OptionalFilters>);
7777
}

clients/algoliasearch-client-csharp/algoliasearch/Models/Recommend/ReRankingApplyFilter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public ReRankingApplyFilter(string actualInstance)
5151
/// the InvalidClassException will be thrown
5252
/// </summary>
5353
/// <returns>An instance of List&lt;ReRankingApplyFilter&gt;</returns>
54-
public List<ReRankingApplyFilter> AsList()
54+
public List<ReRankingApplyFilter> AsListReRankingApplyFilter()
5555
{
5656
return (List<ReRankingApplyFilter>)ActualInstance;
5757
}
@@ -71,7 +71,7 @@ public string AsString()
7171
/// Check if the actual instance is of `List{ReRankingApplyFilter}` type.
7272
/// </summary>
7373
/// <returns>Whether or not the instance is the type</returns>
74-
public bool IsList()
74+
public bool IsListReRankingApplyFilter()
7575
{
7676
return ActualInstance.GetType() == typeof(List<ReRankingApplyFilter>);
7777
}

clients/algoliasearch-client-csharp/algoliasearch/Models/Recommend/RemoveStopWords.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public RemoveStopWords(bool actualInstance)
5151
/// the InvalidClassException will be thrown
5252
/// </summary>
5353
/// <returns>An instance of List&lt;SupportedLanguage&gt;</returns>
54-
public List<SupportedLanguage> AsList()
54+
public List<SupportedLanguage> AsListSupportedLanguage()
5555
{
5656
return (List<SupportedLanguage>)ActualInstance;
5757
}
@@ -71,7 +71,7 @@ public bool AsBool()
7171
/// Check if the actual instance is of `List{SupportedLanguage}` type.
7272
/// </summary>
7373
/// <returns>Whether or not the instance is the type</returns>
74-
public bool IsList()
74+
public bool IsListSupportedLanguage()
7575
{
7676
return ActualInstance.GetType() == typeof(List<SupportedLanguage>);
7777
}

clients/algoliasearch-client-csharp/algoliasearch/Models/Recommend/SnippetResult.cs

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ namespace Algolia.Search.Models.Recommend;
2020
[JsonConverter(typeof(SnippetResultJsonConverter))]
2121
public partial class SnippetResult : AbstractSchema
2222
{
23+
/// <summary>
24+
/// Initializes a new instance of the SnippetResult class
25+
/// with a Dictionary{string, SnippetResult}
26+
/// </summary>
27+
/// <param name="actualInstance">An instance of Dictionary&lt;string, SnippetResult&gt;.</param>
28+
public SnippetResult(Dictionary<string, SnippetResult> actualInstance)
29+
{
30+
ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null.");
31+
}
32+
2333
/// <summary>
2434
/// Initializes a new instance of the SnippetResult class
2535
/// with a SnippetResultOption
@@ -56,6 +66,16 @@ public SnippetResult(List<SnippetResultOption> actualInstance)
5666
/// </summary>
5767
public sealed override object ActualInstance { get; set; }
5868

69+
/// <summary>
70+
/// Get the actual instance of `Dictionary{string, SnippetResult}`. If the actual instance is not `Dictionary{string, SnippetResult}`,
71+
/// the InvalidClassException will be thrown
72+
/// </summary>
73+
/// <returns>An instance of Dictionary&lt;string, SnippetResult&gt;</returns>
74+
public Dictionary<string, SnippetResult> AsDictionarySnippetResult()
75+
{
76+
return (Dictionary<string, SnippetResult>)ActualInstance;
77+
}
78+
5979
/// <summary>
6080
/// Get the actual instance of `SnippetResultOption`. If the actual instance is not `SnippetResultOption`,
6181
/// the InvalidClassException will be thrown
@@ -71,7 +91,7 @@ public SnippetResultOption AsSnippetResultOption()
7191
/// the InvalidClassException will be thrown
7292
/// </summary>
7393
/// <returns>An instance of Dictionary&lt;string, SnippetResultOption&gt;</returns>
74-
public Dictionary<string, SnippetResultOption> AsDictionary()
94+
public Dictionary<string, SnippetResultOption> AsDictionarySnippetResultOption()
7595
{
7696
return (Dictionary<string, SnippetResultOption>)ActualInstance;
7797
}
@@ -81,12 +101,21 @@ public Dictionary<string, SnippetResultOption> AsDictionary()
81101
/// the InvalidClassException will be thrown
82102
/// </summary>
83103
/// <returns>An instance of List&lt;SnippetResultOption&gt;</returns>
84-
public List<SnippetResultOption> AsList()
104+
public List<SnippetResultOption> AsListSnippetResultOption()
85105
{
86106
return (List<SnippetResultOption>)ActualInstance;
87107
}
88108

89109

110+
/// <summary>
111+
/// Check if the actual instance is of `Dictionary{string, SnippetResult}` type.
112+
/// </summary>
113+
/// <returns>Whether or not the instance is the type</returns>
114+
public bool IsDictionarySnippetResult()
115+
{
116+
return ActualInstance.GetType() == typeof(Dictionary<string, SnippetResult>);
117+
}
118+
90119
/// <summary>
91120
/// Check if the actual instance is of `SnippetResultOption` type.
92121
/// </summary>
@@ -100,7 +129,7 @@ public bool IsSnippetResultOption()
100129
/// Check if the actual instance is of `Dictionary{string, SnippetResultOption}` type.
101130
/// </summary>
102131
/// <returns>Whether or not the instance is the type</returns>
103-
public bool IsDictionary()
132+
public bool IsDictionarySnippetResultOption()
104133
{
105134
return ActualInstance.GetType() == typeof(Dictionary<string, SnippetResultOption>);
106135
}
@@ -109,7 +138,7 @@ public bool IsDictionary()
109138
/// Check if the actual instance is of `List{SnippetResultOption}` type.
110139
/// </summary>
111140
/// <returns>Whether or not the instance is the type</returns>
112-
public bool IsList()
141+
public bool IsListSnippetResultOption()
113142
{
114143
return ActualInstance.GetType() == typeof(List<SnippetResultOption>);
115144
}
@@ -199,6 +228,18 @@ public override SnippetResult Read(ref Utf8JsonReader reader, Type typeToConvert
199228
var jsonDocument = JsonDocument.ParseValue(ref reader);
200229
var root = jsonDocument.RootElement;
201230
if (root.ValueKind == JsonValueKind.Object)
231+
{
232+
try
233+
{
234+
return new SnippetResult(jsonDocument.Deserialize<Dictionary<string, SnippetResult>>(JsonConfig.Options));
235+
}
236+
catch (Exception exception)
237+
{
238+
// deserialization failed, try the next one
239+
System.Diagnostics.Debug.WriteLine($"Failed to deserialize into Dictionary<string, SnippetResult>: {exception}");
240+
}
241+
}
242+
if (root.ValueKind == JsonValueKind.Object)
202243
{
203244
try
204245
{

clients/algoliasearch-client-csharp/algoliasearch/Models/Recommend/TagFilters.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public TagFilters(string actualInstance)
5151
/// the InvalidClassException will be thrown
5252
/// </summary>
5353
/// <returns>An instance of List&lt;TagFilters&gt;</returns>
54-
public List<TagFilters> AsList()
54+
public List<TagFilters> AsListTagFilters()
5555
{
5656
return (List<TagFilters>)ActualInstance;
5757
}
@@ -71,7 +71,7 @@ public string AsString()
7171
/// Check if the actual instance is of `List{TagFilters}` type.
7272
/// </summary>
7373
/// <returns>Whether or not the instance is the type</returns>
74-
public bool IsList()
74+
public bool IsListTagFilters()
7575
{
7676
return ActualInstance.GetType() == typeof(List<TagFilters>);
7777
}

clients/algoliasearch-client-csharp/algoliasearch/Models/Search/AroundPrecision.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public int AsInt()
6161
/// the InvalidClassException will be thrown
6262
/// </summary>
6363
/// <returns>An instance of List&lt;Range&gt;</returns>
64-
public List<Range> AsList()
64+
public List<Range> AsListRange()
6565
{
6666
return (List<Range>)ActualInstance;
6767
}
@@ -80,7 +80,7 @@ public bool IsInt()
8080
/// Check if the actual instance is of `List{Range}` type.
8181
/// </summary>
8282
/// <returns>Whether or not the instance is the type</returns>
83-
public bool IsList()
83+
public bool IsListRange()
8484
{
8585
return ActualInstance.GetType() == typeof(List<Range>);
8686
}

clients/algoliasearch-client-csharp/algoliasearch/Models/Search/AutomaticFacetFilters.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public AutomaticFacetFilters(List<string> actualInstance)
5151
/// the InvalidClassException will be thrown
5252
/// </summary>
5353
/// <returns>An instance of List&lt;AutomaticFacetFilter&gt;</returns>
54-
public List<AutomaticFacetFilter> AsList()
54+
public List<AutomaticFacetFilter> AsListAutomaticFacetFilter()
5555
{
5656
return (List<AutomaticFacetFilter>)ActualInstance;
5757
}
@@ -71,7 +71,7 @@ public List<string> AsListString()
7171
/// Check if the actual instance is of `List{AutomaticFacetFilter}` type.
7272
/// </summary>
7373
/// <returns>Whether or not the instance is the type</returns>
74-
public bool IsList()
74+
public bool IsListAutomaticFacetFilter()
7575
{
7676
return ActualInstance.GetType() == typeof(List<AutomaticFacetFilter>);
7777
}

0 commit comments

Comments
 (0)