Skip to content

Commit 425eb39

Browse files
refactor(specs): re-organise response for Composition API (#5744) (generated) [skip ci]
Co-authored-by: Clara Muller <5667350+ClaraMuller@users.noreply.github.com>
1 parent 5dabdc5 commit 425eb39

File tree

115 files changed

+1076
-1410
lines changed

Some content is hidden

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

115 files changed

+1076
-1410
lines changed

clients/algoliasearch-client-csharp/algoliasearch/Models/Composition/CompositionRunAppliedRules.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ public CompositionRunAppliedRules() { }
2525
/// <summary>
2626
/// Initializes a new instance of the CompositionRunAppliedRules class.
2727
/// </summary>
28-
/// <param name="objectID">Unique record identifier. (required).</param>
28+
/// <param name="objectID">The objectID of the applied composition rule on this query. (required).</param>
2929
public CompositionRunAppliedRules(string objectID)
3030
{
3131
ObjectID = objectID ?? throw new ArgumentNullException(nameof(objectID));
3232
}
3333

3434
/// <summary>
35-
/// Unique record identifier.
35+
/// The objectID of the applied composition rule on this query.
3636
/// </summary>
37-
/// <value>Unique record identifier.</value>
37+
/// <value>The objectID of the applied composition rule on this query.</value>
3838
[JsonPropertyName("objectID")]
3939
public string ObjectID { get; set; }
4040

clients/algoliasearch-client-csharp/algoliasearch/Models/Composition/CompositionRunSearchResponse.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ public CompositionRunSearchResponse()
2828
/// <summary>
2929
/// Initializes a new instance of the CompositionRunSearchResponse class.
3030
/// </summary>
31-
/// <param name="objectID">Unique record identifier. (required).</param>
31+
/// <param name="objectID">The objectID of the composition which generated this result set. (required).</param>
3232
public CompositionRunSearchResponse(string objectID)
3333
{
3434
ObjectID = objectID ?? throw new ArgumentNullException(nameof(objectID));
3535
AdditionalProperties = new Dictionary<string, object>();
3636
}
3737

3838
/// <summary>
39-
/// Unique record identifier.
39+
/// The objectID of the composition which generated this result set.
4040
/// </summary>
41-
/// <value>Unique record identifier.</value>
41+
/// <value>The objectID of the composition which generated this result set.</value>
4242
[JsonPropertyName("objectID")]
4343
public string ObjectID { get; set; }
4444

clients/algoliasearch-client-csharp/algoliasearch/Models/Composition/ResultsInjectedItemAppliedRulesInfoResponse.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ public ResultsInjectedItemAppliedRulesInfoResponse() { }
2525
/// <summary>
2626
/// Initializes a new instance of the ResultsInjectedItemAppliedRulesInfoResponse class.
2727
/// </summary>
28-
/// <param name="objectID">Unique record identifier. (required).</param>
28+
/// <param name="objectID">The objectID of the applied index level rule on this injected group. (required).</param>
2929
public ResultsInjectedItemAppliedRulesInfoResponse(string objectID)
3030
{
3131
ObjectID = objectID ?? throw new ArgumentNullException(nameof(objectID));
3232
}
3333

3434
/// <summary>
35-
/// Unique record identifier.
35+
/// The objectID of the applied index level rule on this injected group.
3636
/// </summary>
37-
/// <value>Unique record identifier.</value>
37+
/// <value>The objectID of the applied index level rule on this injected group.</value>
3838
[JsonPropertyName("objectID")]
3939
public string ObjectID { get; set; }
4040

clients/algoliasearch-client-csharp/algoliasearch/Models/Composition/ResultsInjectedItemInfoResponse.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,17 @@ public ResultsInjectedItemInfoResponse()
2828
/// <summary>
2929
/// Initializes a new instance of the ResultsInjectedItemInfoResponse class.
3030
/// </summary>
31-
/// <param name="key">key (required).</param>
31+
/// <param name="key">The key of the injected group. (required).</param>
3232
public ResultsInjectedItemInfoResponse(string key)
3333
{
3434
Key = key ?? throw new ArgumentNullException(nameof(key));
3535
AdditionalProperties = new Dictionary<string, object>();
3636
}
3737

3838
/// <summary>
39-
/// Gets or Sets Key
39+
/// The key of the injected group.
4040
/// </summary>
41+
/// <value>The key of the injected group.</value>
4142
[JsonPropertyName("key")]
4243
public string Key { get; set; }
4344

clients/algoliasearch-client-csharp/algoliasearch/Models/Composition/SearchResultsItem.cs

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -25,32 +25,32 @@ public SearchResultsItem() { }
2525
/// <summary>
2626
/// Initializes a new instance of the SearchResultsItem class.
2727
/// </summary>
28-
/// <param name="page">The current page of the results. (required).</param>
28+
/// <param name="hits">Search results (hits). Hits are records from your index that match the search criteria, augmented with additional attributes, such as, for highlighting. (required).</param>
29+
/// <param name="hitsPerPage">Number of hits returned per page. (required).</param>
2930
/// <param name="nbHits">Number of results (hits). (required).</param>
3031
/// <param name="nbPages">Number of pages of results. (required).</param>
31-
/// <param name="hitsPerPage">Number of hits returned per page. (required).</param>
32-
/// <param name="hits">Search results (hits). Hits are records from your index that match the search criteria, augmented with additional attributes, such as, for highlighting. (required).</param>
33-
/// <param name="query">The search query string. (required).</param>
32+
/// <param name="page">The current page of the results. (required).</param>
3433
/// <param name="varParams">URL-encoded string of all search parameters. (required).</param>
34+
/// <param name="query">The search query string. (required).</param>
3535
/// <param name="compositions">compositions (required).</param>
3636
public SearchResultsItem(
37-
int page,
37+
List<T> hits,
38+
int hitsPerPage,
3839
int nbHits,
3940
int nbPages,
40-
int hitsPerPage,
41-
List<T> hits,
42-
string query,
41+
int page,
4342
string varParams,
43+
string query,
4444
Dictionary<string, ResultsCompositionInfoResponse> compositions
4545
)
4646
{
47-
Page = page;
47+
Hits = hits ?? throw new ArgumentNullException(nameof(hits));
48+
HitsPerPage = hitsPerPage;
4849
NbHits = nbHits;
4950
NbPages = nbPages;
50-
HitsPerPage = hitsPerPage;
51-
Hits = hits ?? throw new ArgumentNullException(nameof(hits));
52-
Query = query ?? throw new ArgumentNullException(nameof(query));
51+
Page = page;
5352
Params = varParams ?? throw new ArgumentNullException(nameof(varParams));
53+
Query = query ?? throw new ArgumentNullException(nameof(query));
5454
Compositions = compositions ?? throw new ArgumentNullException(nameof(compositions));
5555
}
5656

@@ -237,11 +237,18 @@ Dictionary<string, ResultsCompositionInfoResponse> compositions
237237
public bool? AutomaticInsights { get; set; }
238238

239239
/// <summary>
240-
/// The current page of the results.
240+
/// Search results (hits). Hits are records from your index that match the search criteria, augmented with additional attributes, such as, for highlighting.
241241
/// </summary>
242-
/// <value>The current page of the results.</value>
243-
[JsonPropertyName("page")]
244-
public int Page { get; set; }
242+
/// <value>Search results (hits). Hits are records from your index that match the search criteria, augmented with additional attributes, such as, for highlighting. </value>
243+
[JsonPropertyName("hits")]
244+
public List<T> Hits { get; set; }
245+
246+
/// <summary>
247+
/// Number of hits returned per page.
248+
/// </summary>
249+
/// <value>Number of hits returned per page.</value>
250+
[JsonPropertyName("hitsPerPage")]
251+
public int HitsPerPage { get; set; }
245252

246253
/// <summary>
247254
/// Number of results (hits).
@@ -258,18 +265,18 @@ Dictionary<string, ResultsCompositionInfoResponse> compositions
258265
public int NbPages { get; set; }
259266

260267
/// <summary>
261-
/// Number of hits returned per page.
268+
/// The current page of the results.
262269
/// </summary>
263-
/// <value>Number of hits returned per page.</value>
264-
[JsonPropertyName("hitsPerPage")]
265-
public int HitsPerPage { get; set; }
270+
/// <value>The current page of the results.</value>
271+
[JsonPropertyName("page")]
272+
public int Page { get; set; }
266273

267274
/// <summary>
268-
/// Search results (hits). Hits are records from your index that match the search criteria, augmented with additional attributes, such as, for highlighting.
275+
/// URL-encoded string of all search parameters.
269276
/// </summary>
270-
/// <value>Search results (hits). Hits are records from your index that match the search criteria, augmented with additional attributes, such as, for highlighting. </value>
271-
[JsonPropertyName("hits")]
272-
public List<T> Hits { get; set; }
277+
/// <value>URL-encoded string of all search parameters.</value>
278+
[JsonPropertyName("params")]
279+
public string Params { get; set; }
273280

274281
/// <summary>
275282
/// The search query string.
@@ -278,13 +285,6 @@ Dictionary<string, ResultsCompositionInfoResponse> compositions
278285
[JsonPropertyName("query")]
279286
public string Query { get; set; }
280287

281-
/// <summary>
282-
/// URL-encoded string of all search parameters.
283-
/// </summary>
284-
/// <value>URL-encoded string of all search parameters.</value>
285-
[JsonPropertyName("params")]
286-
public string Params { get; set; }
287-
288288
/// <summary>
289289
/// Gets or Sets Compositions
290290
/// </summary>
@@ -325,13 +325,13 @@ public override string ToString()
325325
sb.Append(" UserData: ").Append(UserData).Append("\n");
326326
sb.Append(" QueryID: ").Append(QueryID).Append("\n");
327327
sb.Append(" AutomaticInsights: ").Append(AutomaticInsights).Append("\n");
328-
sb.Append(" Page: ").Append(Page).Append("\n");
328+
sb.Append(" Hits: ").Append(Hits).Append("\n");
329+
sb.Append(" HitsPerPage: ").Append(HitsPerPage).Append("\n");
329330
sb.Append(" NbHits: ").Append(NbHits).Append("\n");
330331
sb.Append(" NbPages: ").Append(NbPages).Append("\n");
331-
sb.Append(" HitsPerPage: ").Append(HitsPerPage).Append("\n");
332-
sb.Append(" Hits: ").Append(Hits).Append("\n");
333-
sb.Append(" Query: ").Append(Query).Append("\n");
332+
sb.Append(" Page: ").Append(Page).Append("\n");
334333
sb.Append(" Params: ").Append(Params).Append("\n");
334+
sb.Append(" Query: ").Append(Query).Append("\n");
335335
sb.Append(" Compositions: ").Append(Compositions).Append("\n");
336336
sb.Append("}\n");
337337
return sb.ToString();
@@ -433,15 +433,15 @@ public override bool Equals(object obj)
433433
AutomaticInsights == input.AutomaticInsights
434434
|| AutomaticInsights.Equals(input.AutomaticInsights)
435435
)
436-
&& (Page == input.Page || Page.Equals(input.Page))
437-
&& (NbHits == input.NbHits || NbHits.Equals(input.NbHits))
438-
&& (NbPages == input.NbPages || NbPages.Equals(input.NbPages))
439-
&& (HitsPerPage == input.HitsPerPage || HitsPerPage.Equals(input.HitsPerPage))
440436
&& (
441437
Hits == input.Hits || Hits != null && input.Hits != null && Hits.SequenceEqual(input.Hits)
442438
)
443-
&& (Query == input.Query || (Query != null && Query.Equals(input.Query)))
439+
&& (HitsPerPage == input.HitsPerPage || HitsPerPage.Equals(input.HitsPerPage))
440+
&& (NbHits == input.NbHits || NbHits.Equals(input.NbHits))
441+
&& (NbPages == input.NbPages || NbPages.Equals(input.NbPages))
442+
&& (Page == input.Page || Page.Equals(input.Page))
444443
&& (Params == input.Params || (Params != null && Params.Equals(input.Params)))
444+
&& (Query == input.Query || (Query != null && Query.Equals(input.Query)))
445445
&& (
446446
Compositions == input.Compositions
447447
|| Compositions != null
@@ -536,22 +536,22 @@ public override int GetHashCode()
536536
hashCode = (hashCode * 59) + QueryID.GetHashCode();
537537
}
538538
hashCode = (hashCode * 59) + AutomaticInsights.GetHashCode();
539-
hashCode = (hashCode * 59) + Page.GetHashCode();
540-
hashCode = (hashCode * 59) + NbHits.GetHashCode();
541-
hashCode = (hashCode * 59) + NbPages.GetHashCode();
542-
hashCode = (hashCode * 59) + HitsPerPage.GetHashCode();
543539
if (Hits != null)
544540
{
545541
hashCode = (hashCode * 59) + Hits.GetHashCode();
546542
}
547-
if (Query != null)
548-
{
549-
hashCode = (hashCode * 59) + Query.GetHashCode();
550-
}
543+
hashCode = (hashCode * 59) + HitsPerPage.GetHashCode();
544+
hashCode = (hashCode * 59) + NbHits.GetHashCode();
545+
hashCode = (hashCode * 59) + NbPages.GetHashCode();
546+
hashCode = (hashCode * 59) + Page.GetHashCode();
551547
if (Params != null)
552548
{
553549
hashCode = (hashCode * 59) + Params.GetHashCode();
554550
}
551+
if (Query != null)
552+
{
553+
hashCode = (hashCode * 59) + Query.GetHashCode();
554+
}
555555
if (Compositions != null)
556556
{
557557
hashCode = (hashCode * 59) + Compositions.GetHashCode();

clients/algoliasearch-client-dart/packages/client_composition/lib/algolia_client_composition.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,11 @@ export 'src/model/rules_multiple_batch_response.dart';
8585
export 'src/model/search.dart';
8686
export 'src/model/search_composition_rules_params.dart';
8787
export 'src/model/search_composition_rules_response.dart';
88+
export 'src/model/search_fields.dart';
8889
export 'src/model/search_for_facet_values_params.dart';
8990
export 'src/model/search_for_facet_values_request.dart';
9091
export 'src/model/search_for_facet_values_response.dart';
9192
export 'src/model/search_for_facet_values_results.dart';
92-
export 'src/model/search_hits.dart';
93-
export 'src/model/search_pagination.dart';
9493
export 'src/model/search_response.dart';
9594
export 'src/model/search_results.dart';
9695
export 'src/model/search_results_item.dart';

clients/algoliasearch-client-dart/packages/client_composition/lib/src/deserialize.dart

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,11 @@ import 'package:algolia_client_composition/src/model/rules_multiple_batch_respon
7878
import 'package:algolia_client_composition/src/model/search.dart';
7979
import 'package:algolia_client_composition/src/model/search_composition_rules_params.dart';
8080
import 'package:algolia_client_composition/src/model/search_composition_rules_response.dart';
81+
import 'package:algolia_client_composition/src/model/search_fields.dart';
8182
import 'package:algolia_client_composition/src/model/search_for_facet_values_params.dart';
8283
import 'package:algolia_client_composition/src/model/search_for_facet_values_request.dart';
8384
import 'package:algolia_client_composition/src/model/search_for_facet_values_response.dart';
8485
import 'package:algolia_client_composition/src/model/search_for_facet_values_results.dart';
85-
import 'package:algolia_client_composition/src/model/search_hits.dart';
86-
import 'package:algolia_client_composition/src/model/search_pagination.dart';
8786
import 'package:algolia_client_composition/src/model/search_response.dart';
8887
import 'package:algolia_client_composition/src/model/search_results.dart';
8988
import 'package:algolia_client_composition/src/model/search_results_item.dart';
@@ -322,6 +321,8 @@ ReturnType deserialize<ReturnType, BaseType>(dynamic value, String targetType,
322321
case 'SearchCompositionRulesResponse':
323322
return SearchCompositionRulesResponse.fromJson(
324323
value as Map<String, dynamic>) as ReturnType;
324+
case 'SearchFields':
325+
return SearchFields.fromJson(value as Map<String, dynamic>) as ReturnType;
325326
case 'SearchForFacetValuesParams':
326327
return SearchForFacetValuesParams.fromJson(value as Map<String, dynamic>)
327328
as ReturnType;
@@ -334,11 +335,6 @@ ReturnType deserialize<ReturnType, BaseType>(dynamic value, String targetType,
334335
case 'SearchForFacetValuesResults':
335336
return SearchForFacetValuesResults.fromJson(value as Map<String, dynamic>)
336337
as ReturnType;
337-
case 'SearchHits':
338-
return SearchHits.fromJson(value as Map<String, dynamic>) as ReturnType;
339-
case 'SearchPagination':
340-
return SearchPagination.fromJson(value as Map<String, dynamic>)
341-
as ReturnType;
342338
case 'SearchResponse':
343339
return SearchResponse.fromJson(value as Map<String, dynamic>)
344340
as ReturnType;

clients/algoliasearch-client-dart/packages/client_composition/lib/src/model/composition_base_search_response.dart

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,16 @@
22
// ignore_for_file: unused_element
33
import 'package:algolia_client_composition/src/model/compositions_search_response.dart';
44

5-
import 'package:collection/collection.dart';
65
import 'package:json_annotation/json_annotation.dart';
76

87
part 'composition_base_search_response.g.dart';
98

10-
@JsonSerializable(createFieldMap: true)
11-
final class CompositionBaseSearchResponse
12-
extends DelegatingMap<String, dynamic> {
9+
@JsonSerializable()
10+
final class CompositionBaseSearchResponse {
1311
/// Returns a new [CompositionBaseSearchResponse] instance.
1412
const CompositionBaseSearchResponse({
1513
this.compositions,
16-
Map<String, dynamic> additionalProperties = const {},
17-
}) : super(additionalProperties);
14+
});
1815

1916
@JsonKey(name: r'compositions')
2017
final CompositionsSearchResponse? compositions;
@@ -23,26 +20,15 @@ final class CompositionBaseSearchResponse
2320
bool operator ==(Object other) =>
2421
identical(this, other) ||
2522
other is CompositionBaseSearchResponse &&
26-
other.compositions == compositions &&
27-
const MapEquality<String, dynamic>().equals(this, this);
23+
other.compositions == compositions;
2824

2925
@override
30-
int get hashCode =>
31-
compositions.hashCode + const MapEquality<String, dynamic>().hash(this);
32-
33-
factory CompositionBaseSearchResponse.fromJson(Map<String, dynamic> json) {
34-
final instance = _$CompositionBaseSearchResponseFromJson(json);
35-
final additionalProperties = Map<String, dynamic>.from(json)
36-
..removeWhere((key, value) =>
37-
_$CompositionBaseSearchResponseFieldMap.containsKey(key));
38-
return CompositionBaseSearchResponse(
39-
compositions: instance.compositions,
40-
additionalProperties: additionalProperties,
41-
);
42-
}
26+
int get hashCode => compositions.hashCode;
27+
28+
factory CompositionBaseSearchResponse.fromJson(Map<String, dynamic> json) =>
29+
_$CompositionBaseSearchResponseFromJson(json);
4330

44-
Map<String, dynamic> toJson() =>
45-
_$CompositionBaseSearchResponseToJson(this)..addAll(this);
31+
Map<String, dynamic> toJson() => _$CompositionBaseSearchResponseToJson(this);
4632

4733
@override
4834
String toString() {

clients/algoliasearch-client-dart/packages/client_composition/lib/src/model/composition_base_search_response.g.dart

Lines changed: 0 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clients/algoliasearch-client-dart/packages/client_composition/lib/src/model/composition_run_applied_rules.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ final class CompositionRunAppliedRules {
1212
required this.objectID,
1313
});
1414

15-
/// Unique record identifier.
15+
/// The objectID of the applied composition rule on this query.
1616
@JsonKey(name: r'objectID')
1717
final String objectID;
1818

0 commit comments

Comments
 (0)