Skip to content

Commit

Permalink
feat(specs): recursive snippets and highlights result (generated)
Browse files Browse the repository at this point in the history
algolia/api-clients-automation#3497

Co-authored-by: algolia-bot <[email protected]>
Co-authored-by: Clément Vannicatte <[email protected]>
  • Loading branch information
algolia-bot and shortcuts committed Aug 9, 2024
1 parent 476f2d3 commit a571337
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
9 changes: 8 additions & 1 deletion Sources/Recommend/Models/RecommendHighlightResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ import Foundation
#endif

public enum RecommendHighlightResult: Codable, JSONEncodable, AbstractEncodable {
case dictionaryOfStringToRecommendHighlightResult([String: RecommendHighlightResult])
case recommendHighlightResultOption(RecommendHighlightResultOption)
case dictionaryOfStringToRecommendHighlightResultOption([String: RecommendHighlightResultOption])
case arrayOfRecommendHighlightResultOption([RecommendHighlightResultOption])

public func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer()
switch self {
case let .dictionaryOfStringToRecommendHighlightResult(value):
try container.encode(value)
case let .recommendHighlightResultOption(value):
try container.encode(value)
case let .dictionaryOfStringToRecommendHighlightResultOption(value):
Expand All @@ -25,7 +28,9 @@ public enum RecommendHighlightResult: Codable, JSONEncodable, AbstractEncodable

public init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
if let value = try? container.decode(RecommendHighlightResultOption.self) {
if let value = try? container.decode([String: RecommendHighlightResult].self) {
self = .dictionaryOfStringToRecommendHighlightResult(value)
} else if let value = try? container.decode(RecommendHighlightResultOption.self) {
self = .recommendHighlightResultOption(value)
} else if let value = try? container.decode([String: RecommendHighlightResultOption].self) {
self = .dictionaryOfStringToRecommendHighlightResultOption(value)
Expand All @@ -44,6 +49,8 @@ public enum RecommendHighlightResult: Codable, JSONEncodable, AbstractEncodable

public func GetActualInstance() -> Encodable {
switch self {
case let .dictionaryOfStringToRecommendHighlightResult(value):
value as [String: RecommendHighlightResult]
case let .recommendHighlightResultOption(value):
value as RecommendHighlightResultOption
case let .dictionaryOfStringToRecommendHighlightResultOption(value):
Expand Down
9 changes: 8 additions & 1 deletion Sources/Recommend/Models/RecommendSnippetResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ import Foundation
#endif

public enum RecommendSnippetResult: Codable, JSONEncodable, AbstractEncodable {
case dictionaryOfStringToRecommendSnippetResult([String: RecommendSnippetResult])
case recommendSnippetResultOption(RecommendSnippetResultOption)
case dictionaryOfStringToRecommendSnippetResultOption([String: RecommendSnippetResultOption])
case arrayOfRecommendSnippetResultOption([RecommendSnippetResultOption])

public func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer()
switch self {
case let .dictionaryOfStringToRecommendSnippetResult(value):
try container.encode(value)
case let .recommendSnippetResultOption(value):
try container.encode(value)
case let .dictionaryOfStringToRecommendSnippetResultOption(value):
Expand All @@ -25,7 +28,9 @@ public enum RecommendSnippetResult: Codable, JSONEncodable, AbstractEncodable {

public init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
if let value = try? container.decode(RecommendSnippetResultOption.self) {
if let value = try? container.decode([String: RecommendSnippetResult].self) {
self = .dictionaryOfStringToRecommendSnippetResult(value)
} else if let value = try? container.decode(RecommendSnippetResultOption.self) {
self = .recommendSnippetResultOption(value)
} else if let value = try? container.decode([String: RecommendSnippetResultOption].self) {
self = .dictionaryOfStringToRecommendSnippetResultOption(value)
Expand All @@ -44,6 +49,8 @@ public enum RecommendSnippetResult: Codable, JSONEncodable, AbstractEncodable {

public func GetActualInstance() -> Encodable {
switch self {
case let .dictionaryOfStringToRecommendSnippetResult(value):
value as [String: RecommendSnippetResult]
case let .recommendSnippetResultOption(value):
value as RecommendSnippetResultOption
case let .dictionaryOfStringToRecommendSnippetResultOption(value):
Expand Down
9 changes: 8 additions & 1 deletion Sources/Search/Models/SearchHighlightResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ import Foundation
#endif

public enum SearchHighlightResult: Codable, JSONEncodable, AbstractEncodable {
case dictionaryOfStringToSearchHighlightResult([String: SearchHighlightResult])
case searchHighlightResultOption(SearchHighlightResultOption)
case dictionaryOfStringToSearchHighlightResultOption([String: SearchHighlightResultOption])
case arrayOfSearchHighlightResultOption([SearchHighlightResultOption])

public func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer()
switch self {
case let .dictionaryOfStringToSearchHighlightResult(value):
try container.encode(value)
case let .searchHighlightResultOption(value):
try container.encode(value)
case let .dictionaryOfStringToSearchHighlightResultOption(value):
Expand All @@ -25,7 +28,9 @@ public enum SearchHighlightResult: Codable, JSONEncodable, AbstractEncodable {

public init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
if let value = try? container.decode(SearchHighlightResultOption.self) {
if let value = try? container.decode([String: SearchHighlightResult].self) {
self = .dictionaryOfStringToSearchHighlightResult(value)
} else if let value = try? container.decode(SearchHighlightResultOption.self) {
self = .searchHighlightResultOption(value)
} else if let value = try? container.decode([String: SearchHighlightResultOption].self) {
self = .dictionaryOfStringToSearchHighlightResultOption(value)
Expand All @@ -44,6 +49,8 @@ public enum SearchHighlightResult: Codable, JSONEncodable, AbstractEncodable {

public func GetActualInstance() -> Encodable {
switch self {
case let .dictionaryOfStringToSearchHighlightResult(value):
value as [String: SearchHighlightResult]
case let .searchHighlightResultOption(value):
value as SearchHighlightResultOption
case let .dictionaryOfStringToSearchHighlightResultOption(value):
Expand Down
9 changes: 8 additions & 1 deletion Sources/Search/Models/SearchSnippetResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ import Foundation
#endif

public enum SearchSnippetResult: Codable, JSONEncodable, AbstractEncodable {
case dictionaryOfStringToSearchSnippetResult([String: SearchSnippetResult])
case searchSnippetResultOption(SearchSnippetResultOption)
case dictionaryOfStringToSearchSnippetResultOption([String: SearchSnippetResultOption])
case arrayOfSearchSnippetResultOption([SearchSnippetResultOption])

public func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer()
switch self {
case let .dictionaryOfStringToSearchSnippetResult(value):
try container.encode(value)
case let .searchSnippetResultOption(value):
try container.encode(value)
case let .dictionaryOfStringToSearchSnippetResultOption(value):
Expand All @@ -25,7 +28,9 @@ public enum SearchSnippetResult: Codable, JSONEncodable, AbstractEncodable {

public init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
if let value = try? container.decode(SearchSnippetResultOption.self) {
if let value = try? container.decode([String: SearchSnippetResult].self) {
self = .dictionaryOfStringToSearchSnippetResult(value)
} else if let value = try? container.decode(SearchSnippetResultOption.self) {
self = .searchSnippetResultOption(value)
} else if let value = try? container.decode([String: SearchSnippetResultOption].self) {
self = .dictionaryOfStringToSearchSnippetResultOption(value)
Expand All @@ -44,6 +49,8 @@ public enum SearchSnippetResult: Codable, JSONEncodable, AbstractEncodable {

public func GetActualInstance() -> Encodable {
switch self {
case let .dictionaryOfStringToSearchSnippetResult(value):
value as [String: SearchSnippetResult]
case let .searchSnippetResultOption(value):
value as SearchSnippetResultOption
case let .dictionaryOfStringToSearchSnippetResultOption(value):
Expand Down

0 comments on commit a571337

Please sign in to comment.