Skip to content

Commit

Permalink
fix(specs): multiple clients fixes (generated)
Browse files Browse the repository at this point in the history
algolia/api-clients-automation#3971

Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com>
  • Loading branch information
algolia-bot committed Oct 16, 2024
1 parent a066ab9 commit 7ab4c2e
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 23 deletions.
8 changes: 4 additions & 4 deletions Sources/Abtesting/Models/ABTestConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import Foundation

/// A/B test configuration.
public struct ABTestConfiguration: Codable, JSONEncodable {
public var outliers: Outliers
public var outliers: Outliers?
public var emptySearch: EmptySearch?
public var minimumDetectableEffect: MinimumDetectableEffect?

public init(
outliers: Outliers,
outliers: Outliers? = nil,
emptySearch: EmptySearch? = nil,
minimumDetectableEffect: MinimumDetectableEffect? = nil
) {
Expand All @@ -32,7 +32,7 @@ public struct ABTestConfiguration: Codable, JSONEncodable {

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(self.outliers, forKey: .outliers)
try container.encodeIfPresent(self.outliers, forKey: .outliers)
try container.encodeIfPresent(self.emptySearch, forKey: .emptySearch)
try container.encodeIfPresent(self.minimumDetectableEffect, forKey: .minimumDetectableEffect)
}
Expand All @@ -48,7 +48,7 @@ extension ABTestConfiguration: Equatable {

extension ABTestConfiguration: Hashable {
public func hash(into hasher: inout Hasher) {
hasher.combine(self.outliers.hashValue)
hasher.combine(self.outliers?.hashValue)
hasher.combine(self.emptySearch?.hashValue)
hasher.combine(self.minimumDetectableEffect?.hashValue)
}
Expand Down
8 changes: 4 additions & 4 deletions Sources/Abtesting/Models/Variant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public struct Variant: Codable, JSONEncodable {
/// A/B test currencies.
public var currencies: [String: Currency]?
/// Description for this variant.
public var description: String
public var description: String?
/// Estimated number of searches required to achieve the desired statistical significance. The A/B test
/// configuration must include a `mininmumDetectableEffect` setting for this number to be included in the response.
public var estimatedSampleSize: Int?
Expand Down Expand Up @@ -64,7 +64,7 @@ public struct Variant: Codable, JSONEncodable {
conversionCount: Int,
conversionRate: Double? = nil,
currencies: [String: Currency]? = nil,
description: String,
description: String? = nil,
estimatedSampleSize: Int? = nil,
filterEffects: FilterEffects? = nil,
index: String,
Expand Down Expand Up @@ -134,7 +134,7 @@ public struct Variant: Codable, JSONEncodable {
try container.encode(self.conversionCount, forKey: .conversionCount)
try container.encodeIfPresent(self.conversionRate, forKey: .conversionRate)
try container.encodeIfPresent(self.currencies, forKey: .currencies)
try container.encode(self.description, forKey: .description)
try container.encodeIfPresent(self.description, forKey: .description)
try container.encodeIfPresent(self.estimatedSampleSize, forKey: .estimatedSampleSize)
try container.encodeIfPresent(self.filterEffects, forKey: .filterEffects)
try container.encode(self.index, forKey: .index)
Expand Down Expand Up @@ -184,7 +184,7 @@ extension Variant: Hashable {
hasher.combine(self.conversionCount.hashValue)
hasher.combine(self.conversionRate?.hashValue)
hasher.combine(self.currencies?.hashValue)
hasher.combine(self.description.hashValue)
hasher.combine(self.description?.hashValue)
hasher.combine(self.estimatedSampleSize?.hashValue)
hasher.combine(self.filterEffects?.hashValue)
hasher.combine(self.index.hashValue)
Expand Down
14 changes: 13 additions & 1 deletion Sources/Recommend/Models/RecommendBaseSearchResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public struct RecommendBaseSearchResponse: Codable, JSONEncodable {
/// Distance from a central coordinate provided by `aroundLatLng`.
public var automaticRadius: String?
public var exhaustive: RecommendExhaustive?
/// Rules applied to the query.
public var appliedRules: [AnyCodable]?
/// See the `facetsCount` field of the `exhaustive` object in the response.
@available(*, deprecated, message: "This property is deprecated.")
public var exhaustiveFacetsCount: Bool?
Expand Down Expand Up @@ -67,6 +69,7 @@ public struct RecommendBaseSearchResponse: Codable, JSONEncodable {
aroundLatLng: String? = nil,
automaticRadius: String? = nil,
exhaustive: RecommendExhaustive? = nil,
appliedRules: [AnyCodable]? = nil,
exhaustiveFacetsCount: Bool? = nil,
exhaustiveNbHits: Bool? = nil,
exhaustiveTypo: Bool? = nil,
Expand All @@ -93,6 +96,7 @@ public struct RecommendBaseSearchResponse: Codable, JSONEncodable {
self.aroundLatLng = aroundLatLng
self.automaticRadius = automaticRadius
self.exhaustive = exhaustive
self.appliedRules = appliedRules
self.exhaustiveFacetsCount = exhaustiveFacetsCount
self.exhaustiveNbHits = exhaustiveNbHits
self.exhaustiveTypo = exhaustiveTypo
Expand Down Expand Up @@ -121,6 +125,7 @@ public struct RecommendBaseSearchResponse: Codable, JSONEncodable {
case aroundLatLng
case automaticRadius
case exhaustive
case appliedRules
case exhaustiveFacetsCount
case exhaustiveNbHits
case exhaustiveTypo
Expand Down Expand Up @@ -169,6 +174,8 @@ public struct RecommendBaseSearchResponse: Codable, JSONEncodable {

self.exhaustive = dictionary["exhaustive"]?.value as? RecommendExhaustive

self.appliedRules = dictionary["appliedRules"]?.value as? [AnyCodable]

self.exhaustiveFacetsCount = dictionary["exhaustiveFacetsCount"]?.value as? Bool

self.exhaustiveNbHits = dictionary["exhaustiveNbHits"]?.value as? Bool
Expand Down Expand Up @@ -213,7 +220,7 @@ public struct RecommendBaseSearchResponse: Codable, JSONEncodable {

for (key, value) in dictionary {
switch key {
case "abTestID", "abTestVariantID", "aroundLatLng", "automaticRadius", "exhaustive",
case "abTestID", "abTestVariantID", "aroundLatLng", "automaticRadius", "exhaustive", "appliedRules",
"exhaustiveFacetsCount", "exhaustiveNbHits", "exhaustiveTypo", "facets", "facetsStats", "index",
"indexUsed", "message", "nbSortedHits", "parsedQuery", "processingTimeMS", "processingTimingsMS",
"queryAfterRemoval", "redirect", "renderingContent", "serverTimeMS", "serverUsed", "userData",
Expand All @@ -234,6 +241,7 @@ public struct RecommendBaseSearchResponse: Codable, JSONEncodable {
try container.encodeIfPresent(self.aroundLatLng, forKey: .aroundLatLng)
try container.encodeIfPresent(self.automaticRadius, forKey: .automaticRadius)
try container.encodeIfPresent(self.exhaustive, forKey: .exhaustive)
try container.encodeIfPresent(self.appliedRules, forKey: .appliedRules)
try container.encodeIfPresent(self.exhaustiveFacetsCount, forKey: .exhaustiveFacetsCount)
try container.encodeIfPresent(self.exhaustiveNbHits, forKey: .exhaustiveNbHits)
try container.encodeIfPresent(self.exhaustiveTypo, forKey: .exhaustiveTypo)
Expand Down Expand Up @@ -268,6 +276,7 @@ public struct RecommendBaseSearchResponse: Codable, JSONEncodable {
self.aroundLatLng = try container.decodeIfPresent(String.self, forKey: .aroundLatLng)
self.automaticRadius = try container.decodeIfPresent(String.self, forKey: .automaticRadius)
self.exhaustive = try container.decodeIfPresent(RecommendExhaustive.self, forKey: .exhaustive)
self.appliedRules = try container.decodeIfPresent([AnyCodable].self, forKey: .appliedRules)
self.exhaustiveFacetsCount = try container.decodeIfPresent(Bool.self, forKey: .exhaustiveFacetsCount)
self.exhaustiveNbHits = try container.decodeIfPresent(Bool.self, forKey: .exhaustiveNbHits)
self.exhaustiveTypo = try container.decodeIfPresent(Bool.self, forKey: .exhaustiveTypo)
Expand All @@ -294,6 +303,7 @@ public struct RecommendBaseSearchResponse: Codable, JSONEncodable {
nonAdditionalPropertyKeys.insert("aroundLatLng")
nonAdditionalPropertyKeys.insert("automaticRadius")
nonAdditionalPropertyKeys.insert("exhaustive")
nonAdditionalPropertyKeys.insert("appliedRules")
nonAdditionalPropertyKeys.insert("exhaustiveFacetsCount")
nonAdditionalPropertyKeys.insert("exhaustiveNbHits")
nonAdditionalPropertyKeys.insert("exhaustiveTypo")
Expand Down Expand Up @@ -329,6 +339,7 @@ extension RecommendBaseSearchResponse: Equatable {
lhs.aroundLatLng == rhs.aroundLatLng &&
lhs.automaticRadius == rhs.automaticRadius &&
lhs.exhaustive == rhs.exhaustive &&
lhs.appliedRules == rhs.appliedRules &&
lhs.exhaustiveFacetsCount == rhs.exhaustiveFacetsCount &&
lhs.exhaustiveNbHits == rhs.exhaustiveNbHits &&
lhs.exhaustiveTypo == rhs.exhaustiveTypo &&
Expand Down Expand Up @@ -360,6 +371,7 @@ extension RecommendBaseSearchResponse: Hashable {
hasher.combine(self.aroundLatLng?.hashValue)
hasher.combine(self.automaticRadius?.hashValue)
hasher.combine(self.exhaustive?.hashValue)
hasher.combine(self.appliedRules?.hashValue)
hasher.combine(self.exhaustiveFacetsCount?.hashValue)
hasher.combine(self.exhaustiveNbHits?.hashValue)
hasher.combine(self.exhaustiveTypo?.hashValue)
Expand Down
8 changes: 8 additions & 0 deletions Sources/Recommend/Models/RecommendationsResults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public struct RecommendationsResults: Codable, JSONEncodable {
/// Distance from a central coordinate provided by `aroundLatLng`.
public var automaticRadius: String?
public var exhaustive: RecommendExhaustive?
/// Rules applied to the query.
public var appliedRules: [AnyCodable]?
/// See the `facetsCount` field of the `exhaustive` object in the response.
@available(*, deprecated, message: "This property is deprecated.")
public var exhaustiveFacetsCount: Bool?
Expand Down Expand Up @@ -76,6 +78,7 @@ public struct RecommendationsResults: Codable, JSONEncodable {
aroundLatLng: String? = nil,
automaticRadius: String? = nil,
exhaustive: RecommendExhaustive? = nil,
appliedRules: [AnyCodable]? = nil,
exhaustiveFacetsCount: Bool? = nil,
exhaustiveNbHits: Bool? = nil,
exhaustiveTypo: Bool? = nil,
Expand Down Expand Up @@ -107,6 +110,7 @@ public struct RecommendationsResults: Codable, JSONEncodable {
self.aroundLatLng = aroundLatLng
self.automaticRadius = automaticRadius
self.exhaustive = exhaustive
self.appliedRules = appliedRules
self.exhaustiveFacetsCount = exhaustiveFacetsCount
self.exhaustiveNbHits = exhaustiveNbHits
self.exhaustiveTypo = exhaustiveTypo
Expand Down Expand Up @@ -140,6 +144,7 @@ public struct RecommendationsResults: Codable, JSONEncodable {
case aroundLatLng
case automaticRadius
case exhaustive
case appliedRules
case exhaustiveFacetsCount
case exhaustiveNbHits
case exhaustiveTypo
Expand Down Expand Up @@ -176,6 +181,7 @@ public struct RecommendationsResults: Codable, JSONEncodable {
try container.encodeIfPresent(self.aroundLatLng, forKey: .aroundLatLng)
try container.encodeIfPresent(self.automaticRadius, forKey: .automaticRadius)
try container.encodeIfPresent(self.exhaustive, forKey: .exhaustive)
try container.encodeIfPresent(self.appliedRules, forKey: .appliedRules)
try container.encodeIfPresent(self.exhaustiveFacetsCount, forKey: .exhaustiveFacetsCount)
try container.encodeIfPresent(self.exhaustiveNbHits, forKey: .exhaustiveNbHits)
try container.encodeIfPresent(self.exhaustiveTypo, forKey: .exhaustiveTypo)
Expand Down Expand Up @@ -211,6 +217,7 @@ extension RecommendationsResults: Equatable {
lhs.aroundLatLng == rhs.aroundLatLng &&
lhs.automaticRadius == rhs.automaticRadius &&
lhs.exhaustive == rhs.exhaustive &&
lhs.appliedRules == rhs.appliedRules &&
lhs.exhaustiveFacetsCount == rhs.exhaustiveFacetsCount &&
lhs.exhaustiveNbHits == rhs.exhaustiveNbHits &&
lhs.exhaustiveTypo == rhs.exhaustiveTypo &&
Expand Down Expand Up @@ -246,6 +253,7 @@ extension RecommendationsResults: Hashable {
hasher.combine(self.aroundLatLng?.hashValue)
hasher.combine(self.automaticRadius?.hashValue)
hasher.combine(self.exhaustive?.hashValue)
hasher.combine(self.appliedRules?.hashValue)
hasher.combine(self.exhaustiveFacetsCount?.hashValue)
hasher.combine(self.exhaustiveNbHits?.hashValue)
hasher.combine(self.exhaustiveTypo?.hashValue)
Expand Down
8 changes: 4 additions & 4 deletions Sources/Search/Models/BaseGetApiKeyResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import Foundation

public struct BaseGetApiKeyResponse: Codable, JSONEncodable {
/// API key.
public var value: String?
public var value: String
/// Timestamp when the object was created, in milliseconds since the Unix epoch.
public var createdAt: Int64

public init(value: String? = nil, createdAt: Int64) {
public init(value: String, createdAt: Int64) {
self.value = value
self.createdAt = createdAt
}
Expand All @@ -26,7 +26,7 @@ public struct BaseGetApiKeyResponse: Codable, JSONEncodable {

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(self.value, forKey: .value)
try container.encode(self.value, forKey: .value)
try container.encode(self.createdAt, forKey: .createdAt)
}
}
Expand All @@ -40,7 +40,7 @@ extension BaseGetApiKeyResponse: Equatable {

extension BaseGetApiKeyResponse: Hashable {
public func hash(into hasher: inout Hasher) {
hasher.combine(self.value?.hashValue)
hasher.combine(self.value.hashValue)
hasher.combine(self.createdAt.hashValue)
}
}
8 changes: 8 additions & 0 deletions Sources/Search/Models/BrowseResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public struct BrowseResponse<T: Codable>: Codable, JSONEncodable {
/// Distance from a central coordinate provided by `aroundLatLng`.
public var automaticRadius: String?
public var exhaustive: SearchExhaustive?
/// Rules applied to the query.
public var appliedRules: [AnyCodable]?
/// See the `facetsCount` field of the `exhaustive` object in the response.
@available(*, deprecated, message: "This property is deprecated.")
public var exhaustiveFacetsCount: Bool?
Expand Down Expand Up @@ -85,6 +87,7 @@ public struct BrowseResponse<T: Codable>: Codable, JSONEncodable {
aroundLatLng: String? = nil,
automaticRadius: String? = nil,
exhaustive: SearchExhaustive? = nil,
appliedRules: [AnyCodable]? = nil,
exhaustiveFacetsCount: Bool? = nil,
exhaustiveNbHits: Bool? = nil,
exhaustiveTypo: Bool? = nil,
Expand Down Expand Up @@ -119,6 +122,7 @@ public struct BrowseResponse<T: Codable>: Codable, JSONEncodable {
self.aroundLatLng = aroundLatLng
self.automaticRadius = automaticRadius
self.exhaustive = exhaustive
self.appliedRules = appliedRules
self.exhaustiveFacetsCount = exhaustiveFacetsCount
self.exhaustiveNbHits = exhaustiveNbHits
self.exhaustiveTypo = exhaustiveTypo
Expand Down Expand Up @@ -155,6 +159,7 @@ public struct BrowseResponse<T: Codable>: Codable, JSONEncodable {
case aroundLatLng
case automaticRadius
case exhaustive
case appliedRules
case exhaustiveFacetsCount
case exhaustiveNbHits
case exhaustiveTypo
Expand Down Expand Up @@ -194,6 +199,7 @@ public struct BrowseResponse<T: Codable>: Codable, JSONEncodable {
try container.encodeIfPresent(self.aroundLatLng, forKey: .aroundLatLng)
try container.encodeIfPresent(self.automaticRadius, forKey: .automaticRadius)
try container.encodeIfPresent(self.exhaustive, forKey: .exhaustive)
try container.encodeIfPresent(self.appliedRules, forKey: .appliedRules)
try container.encodeIfPresent(self.exhaustiveFacetsCount, forKey: .exhaustiveFacetsCount)
try container.encodeIfPresent(self.exhaustiveNbHits, forKey: .exhaustiveNbHits)
try container.encodeIfPresent(self.exhaustiveTypo, forKey: .exhaustiveTypo)
Expand Down Expand Up @@ -232,6 +238,7 @@ extension BrowseResponse: Equatable where T: Equatable {
lhs.aroundLatLng == rhs.aroundLatLng &&
lhs.automaticRadius == rhs.automaticRadius &&
lhs.exhaustive == rhs.exhaustive &&
lhs.appliedRules == rhs.appliedRules &&
lhs.exhaustiveFacetsCount == rhs.exhaustiveFacetsCount &&
lhs.exhaustiveNbHits == rhs.exhaustiveNbHits &&
lhs.exhaustiveTypo == rhs.exhaustiveTypo &&
Expand Down Expand Up @@ -270,6 +277,7 @@ extension BrowseResponse: Hashable where T: Hashable {
hasher.combine(self.aroundLatLng?.hashValue)
hasher.combine(self.automaticRadius?.hashValue)
hasher.combine(self.exhaustive?.hashValue)
hasher.combine(self.appliedRules?.hashValue)
hasher.combine(self.exhaustiveFacetsCount?.hashValue)
hasher.combine(self.exhaustiveNbHits?.hashValue)
hasher.combine(self.exhaustiveTypo?.hashValue)
Expand Down
8 changes: 4 additions & 4 deletions Sources/Search/Models/GetApiKeyResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Foundation

public struct GetApiKeyResponse: Codable, JSONEncodable {
/// API key.
public var value: String?
public var value: String
/// Timestamp when the object was created, in milliseconds since the Unix epoch.
public var createdAt: Int64
/// Permissions that determine the type of API requests this key can make. The required ACL is listed in each
Expand Down Expand Up @@ -43,7 +43,7 @@ public struct GetApiKeyResponse: Codable, JSONEncodable {
public var validity: Int?

public init(
value: String? = nil,
value: String,
createdAt: Int64,
acl: [Acl],
description: String? = nil,
Expand Down Expand Up @@ -83,7 +83,7 @@ public struct GetApiKeyResponse: Codable, JSONEncodable {

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(self.value, forKey: .value)
try container.encode(self.value, forKey: .value)
try container.encode(self.createdAt, forKey: .createdAt)
try container.encode(self.acl, forKey: .acl)
try container.encodeIfPresent(self.description, forKey: .description)
Expand Down Expand Up @@ -113,7 +113,7 @@ extension GetApiKeyResponse: Equatable {

extension GetApiKeyResponse: Hashable {
public func hash(into hasher: inout Hasher) {
hasher.combine(self.value?.hashValue)
hasher.combine(self.value.hashValue)
hasher.combine(self.createdAt.hashValue)
hasher.combine(self.acl.hashValue)
hasher.combine(self.description?.hashValue)
Expand Down
8 changes: 4 additions & 4 deletions Sources/Search/Models/GetObjectsResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import Foundation

public struct GetObjectsResponse<T: Codable>: Codable, JSONEncodable {
/// Retrieved records.
public var results: [T]
public var results: [T]?

public init(results: [T]) {
public init(results: [T]? = nil) {
self.results = results
}

Expand All @@ -22,7 +22,7 @@ public struct GetObjectsResponse<T: Codable>: Codable, JSONEncodable {

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(self.results, forKey: .results)
try container.encodeIfPresent(self.results, forKey: .results)
}
}

Expand All @@ -34,6 +34,6 @@ extension GetObjectsResponse: Equatable where T: Equatable {

extension GetObjectsResponse: Hashable where T: Hashable {
public func hash(into hasher: inout Hasher) {
hasher.combine(self.results.hashValue)
hasher.combine(self.results?.hashValue)
}
}
Loading

0 comments on commit 7ab4c2e

Please sign in to comment.