Skip to content

Commit

Permalink
fix(specs): update search api specs [skip-bc] (generated)
Browse files Browse the repository at this point in the history
algolia/api-clients-automation#3760

Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com>
Co-authored-by: Thomas Raffray <Fluf22@users.noreply.github.com>
  • Loading branch information
algolia-bot and Fluf22 committed Sep 16, 2024
1 parent a9794ff commit 23f3218
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ import kotlin.jvm.JvmInline
*
* Implementations:
* - [HighlightResultOption]
* - [List<HighlightResultOption>] - *[HighlightResult.of]*
* - [List<HighlightResult>] - *[HighlightResult.of]*
* - [Map<kotlin.String, HighlightResult>] - *[HighlightResult.of]*
* - [Map<kotlin.String, HighlightResultOption>] - *[HighlightResult.of]*
*/
@Serializable(HighlightResultSerializer::class)
public sealed interface HighlightResult {
Expand All @@ -27,22 +26,15 @@ public sealed interface HighlightResult {

@Serializable
@JvmInline
public value class MapOfkotlinStringHighlightResultOptionValue(public val value: Map<kotlin.String, HighlightResultOption>) : HighlightResult

@Serializable
@JvmInline
public value class ListOfHighlightResultOptionValue(public val value: List<HighlightResultOption>) : HighlightResult
public value class ListOfHighlightResultValue(public val value: List<HighlightResult>) : HighlightResult

public companion object {

public fun ofMapOfkotlinStringHighlightResult(value: Map<kotlin.String, HighlightResult>): HighlightResult {
public fun of(value: Map<kotlin.String, HighlightResult>): HighlightResult {
return MapOfkotlinStringHighlightResultValue(value)
}
public fun ofMapOfkotlinStringHighlightResultOption(value: Map<kotlin.String, HighlightResultOption>): HighlightResult {
return MapOfkotlinStringHighlightResultOptionValue(value)
}
public fun of(value: List<HighlightResultOption>): HighlightResult {
return ListOfHighlightResultOptionValue(value)
public fun of(value: List<HighlightResult>): HighlightResult {
return ListOfHighlightResultValue(value)
}
}
}
Expand All @@ -52,8 +44,7 @@ internal class HighlightResultSerializer : JsonContentPolymorphicSerializer<High
return when {
element is JsonObject && element.containsKey("matchLevel") && element.containsKey("matchedWords") -> HighlightResultOption.serializer()
element is JsonObject -> HighlightResult.MapOfkotlinStringHighlightResultValue.serializer()
element is JsonObject -> HighlightResult.MapOfkotlinStringHighlightResultOptionValue.serializer()
element.isJsonArrayOfObjects -> HighlightResult.ListOfHighlightResultOptionValue.serializer()
element.isJsonArrayOfObjects -> HighlightResult.ListOfHighlightResultValue.serializer()
else -> throw AlgoliaClientException("Failed to deserialize json element: $element")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ import kotlinx.serialization.json.*
* RecommendationsResults
*
* @param processingTimeMS Time the server took to process the request, in milliseconds.
* @param page Page of search results to retrieve.
* @param nbHits Number of results (hits).
* @param nbPages Number of pages of results.
* @param hitsPerPage Number of hits per page.
* @param hits
* @param abTestID A/B test ID. This is only included in the response for indices that are part of an A/B test.
* @param abTestVariantID Variant ID. This is only included in the response for indices that are part of an A/B test.
Expand All @@ -37,25 +33,17 @@ import kotlinx.serialization.json.*
* @param userData An object with custom data. You can store up to 32kB as custom data.
* @param queryID Unique identifier for the query. This is used for [click analytics](https://www.algolia.com/doc/guides/analytics/click-analytics/).
* @param automaticInsights Whether automatic events collection is enabled for the application.
* @param page Page of search results to retrieve.
* @param nbHits Number of results (hits).
* @param nbPages Number of pages of results.
* @param hitsPerPage Number of hits per page.
*/
@Serializable
public data class RecommendationsResults(

/** Time the server took to process the request, in milliseconds. */
@SerialName(value = "processingTimeMS") val processingTimeMS: Int,

/** Page of search results to retrieve. */
@SerialName(value = "page") val page: Int,

/** Number of results (hits). */
@SerialName(value = "nbHits") val nbHits: Int,

/** Number of pages of results. */
@SerialName(value = "nbPages") val nbPages: Int,

/** Number of hits per page. */
@SerialName(value = "hitsPerPage") val hitsPerPage: Int,

@SerialName(value = "hits") val hits: List<RecommendationsHit>,

/** A/B test ID. This is only included in the response for indices that are part of an A/B test. */
Expand Down Expand Up @@ -129,4 +117,16 @@ public data class RecommendationsResults(

/** Whether automatic events collection is enabled for the application. */
@SerialName(value = "_automaticInsights") val automaticInsights: Boolean? = null,

/** Page of search results to retrieve. */
@SerialName(value = "page") val page: Int? = null,

/** Number of results (hits). */
@SerialName(value = "nbHits") val nbHits: Int? = null,

/** Number of pages of results. */
@SerialName(value = "nbPages") val nbPages: Int? = null,

/** Number of hits per page. */
@SerialName(value = "hitsPerPage") val hitsPerPage: Int? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ import kotlin.jvm.JvmInline
* SnippetResult
*
* Implementations:
* - [List<SnippetResultOption>] - *[SnippetResult.of]*
* - [List<SnippetResult>] - *[SnippetResult.of]*
* - [Map<kotlin.String, SnippetResult>] - *[SnippetResult.of]*
* - [Map<kotlin.String, SnippetResultOption>] - *[SnippetResult.of]*
* - [SnippetResultOption]
*/
@Serializable(SnippetResultSerializer::class)
Expand All @@ -27,22 +26,15 @@ public sealed interface SnippetResult {

@Serializable
@JvmInline
public value class MapOfkotlinStringSnippetResultOptionValue(public val value: Map<kotlin.String, SnippetResultOption>) : SnippetResult

@Serializable
@JvmInline
public value class ListOfSnippetResultOptionValue(public val value: List<SnippetResultOption>) : SnippetResult
public value class ListOfSnippetResultValue(public val value: List<SnippetResult>) : SnippetResult

public companion object {

public fun ofMapOfkotlinStringSnippetResult(value: Map<kotlin.String, SnippetResult>): SnippetResult {
public fun of(value: Map<kotlin.String, SnippetResult>): SnippetResult {
return MapOfkotlinStringSnippetResultValue(value)
}
public fun ofMapOfkotlinStringSnippetResultOption(value: Map<kotlin.String, SnippetResultOption>): SnippetResult {
return MapOfkotlinStringSnippetResultOptionValue(value)
}
public fun of(value: List<SnippetResultOption>): SnippetResult {
return ListOfSnippetResultOptionValue(value)
public fun of(value: List<SnippetResult>): SnippetResult {
return ListOfSnippetResultValue(value)
}
}
}
Expand All @@ -52,8 +44,7 @@ internal class SnippetResultSerializer : JsonContentPolymorphicSerializer<Snippe
return when {
element is JsonObject && element.containsKey("matchLevel") -> SnippetResultOption.serializer()
element is JsonObject -> SnippetResult.MapOfkotlinStringSnippetResultValue.serializer()
element is JsonObject -> SnippetResult.MapOfkotlinStringSnippetResultOptionValue.serializer()
element.isJsonArrayOfObjects -> SnippetResult.ListOfSnippetResultOptionValue.serializer()
element.isJsonArrayOfObjects -> SnippetResult.ListOfSnippetResultValue.serializer()
else -> throw AlgoliaClientException("Failed to deserialize json element: $element")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ import kotlin.jvm.JvmInline
*
* Implementations:
* - [HighlightResultOption]
* - [List<HighlightResultOption>] - *[HighlightResult.of]*
* - [List<HighlightResult>] - *[HighlightResult.of]*
* - [Map<kotlin.String, HighlightResult>] - *[HighlightResult.of]*
* - [Map<kotlin.String, HighlightResultOption>] - *[HighlightResult.of]*
*/
@Serializable(HighlightResultSerializer::class)
public sealed interface HighlightResult {
Expand All @@ -27,22 +26,15 @@ public sealed interface HighlightResult {

@Serializable
@JvmInline
public value class MapOfkotlinStringHighlightResultOptionValue(public val value: Map<kotlin.String, HighlightResultOption>) : HighlightResult

@Serializable
@JvmInline
public value class ListOfHighlightResultOptionValue(public val value: List<HighlightResultOption>) : HighlightResult
public value class ListOfHighlightResultValue(public val value: List<HighlightResult>) : HighlightResult

public companion object {

public fun ofMapOfkotlinStringHighlightResult(value: Map<kotlin.String, HighlightResult>): HighlightResult {
public fun of(value: Map<kotlin.String, HighlightResult>): HighlightResult {
return MapOfkotlinStringHighlightResultValue(value)
}
public fun ofMapOfkotlinStringHighlightResultOption(value: Map<kotlin.String, HighlightResultOption>): HighlightResult {
return MapOfkotlinStringHighlightResultOptionValue(value)
}
public fun of(value: List<HighlightResultOption>): HighlightResult {
return ListOfHighlightResultOptionValue(value)
public fun of(value: List<HighlightResult>): HighlightResult {
return ListOfHighlightResultValue(value)
}
}
}
Expand All @@ -52,8 +44,7 @@ internal class HighlightResultSerializer : JsonContentPolymorphicSerializer<High
return when {
element is JsonObject && element.containsKey("matchLevel") && element.containsKey("matchedWords") -> HighlightResultOption.serializer()
element is JsonObject -> HighlightResult.MapOfkotlinStringHighlightResultValue.serializer()
element is JsonObject -> HighlightResult.MapOfkotlinStringHighlightResultOptionValue.serializer()
element.isJsonArrayOfObjects -> HighlightResult.ListOfHighlightResultOptionValue.serializer()
element.isJsonArrayOfObjects -> HighlightResult.ListOfHighlightResultValue.serializer()
else -> throw AlgoliaClientException("Failed to deserialize json element: $element")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ import kotlinx.serialization.json.*
* SearchResponse
*
* @param processingTimeMS Time the server took to process the request, in milliseconds.
* @param page Page of search results to retrieve.
* @param nbHits Number of results (hits).
* @param nbPages Number of pages of results.
* @param hitsPerPage Number of hits per page.
* @param hits Search results (hits). Hits are records from your index that match the search criteria, augmented with additional attributes, such as, for highlighting.
* @param query Search query.
* @param params URL-encoded string of all search parameters.
Expand Down Expand Up @@ -42,25 +38,17 @@ import kotlinx.serialization.json.*
* @param userData An object with custom data. You can store up to 32kB as custom data.
* @param queryID Unique identifier for the query. This is used for [click analytics](https://www.algolia.com/doc/guides/analytics/click-analytics/).
* @param automaticInsights Whether automatic events collection is enabled for the application.
* @param page Page of search results to retrieve.
* @param nbHits Number of results (hits).
* @param nbPages Number of pages of results.
* @param hitsPerPage Number of hits per page.
*/
@Serializable(SearchResponseSerializer::class)
public data class SearchResponse(

/** Time the server took to process the request, in milliseconds. */
val processingTimeMS: Int,

/** Page of search results to retrieve. */
val page: Int,

/** Number of results (hits). */
val nbHits: Int,

/** Number of pages of results. */
val nbPages: Int,

/** Number of hits per page. */
val hitsPerPage: Int,

/** Search results (hits). Hits are records from your index that match the search criteria, augmented with additional attributes, such as, for highlighting. */
val hits: List<Hit>,

Expand Down Expand Up @@ -142,17 +130,25 @@ public data class SearchResponse(
/** Whether automatic events collection is enabled for the application. */
val automaticInsights: Boolean? = null,

/** Page of search results to retrieve. */
val page: Int? = null,

/** Number of results (hits). */
val nbHits: Int? = null,

/** Number of pages of results. */
val nbPages: Int? = null,

/** Number of hits per page. */
val hitsPerPage: Int? = null,

val additionalProperties: Map<String, JsonElement>? = null,
) : SearchResult

internal object SearchResponseSerializer : KSerializer<SearchResponse> {

override val descriptor: SerialDescriptor = buildClassSerialDescriptor("SearchResponse") {
element<Int>("processingTimeMS")
element<Int>("page")
element<Int>("nbHits")
element<Int>("nbPages")
element<Int>("hitsPerPage")
element<List<Hit>>("hits")
element<String>("query")
element<String>("params")
Expand Down Expand Up @@ -180,17 +176,17 @@ internal object SearchResponseSerializer : KSerializer<SearchResponse> {
element<JsonObject>("userData", isOptional = true)
element<String>("queryID", isOptional = true)
element<Boolean>("_automaticInsights", isOptional = true)
element<Int>("page", isOptional = true)
element<Int>("nbHits", isOptional = true)
element<Int>("nbPages", isOptional = true)
element<Int>("hitsPerPage", isOptional = true)
}

override fun deserialize(decoder: Decoder): SearchResponse {
val input = decoder.asJsonDecoder()
val tree = input.decodeJsonObject()
return SearchResponse(
processingTimeMS = tree.getValue("processingTimeMS").let { input.json.decodeFromJsonElement(it) },
page = tree.getValue("page").let { input.json.decodeFromJsonElement(it) },
nbHits = tree.getValue("nbHits").let { input.json.decodeFromJsonElement(it) },
nbPages = tree.getValue("nbPages").let { input.json.decodeFromJsonElement(it) },
hitsPerPage = tree.getValue("hitsPerPage").let { input.json.decodeFromJsonElement(it) },
hits = tree.getValue("hits").let { input.json.decodeFromJsonElement(it) },
query = tree.getValue("query").let { input.json.decodeFromJsonElement(it) },
params = tree.getValue("params").let { input.json.decodeFromJsonElement(it) },
Expand Down Expand Up @@ -218,6 +214,10 @@ internal object SearchResponseSerializer : KSerializer<SearchResponse> {
userData = tree["userData"]?.let { input.json.decodeFromJsonElement(it) },
queryID = tree["queryID"]?.let { input.json.decodeFromJsonElement(it) },
automaticInsights = tree["_automaticInsights"]?.let { input.json.decodeFromJsonElement(it) },
page = tree["page"]?.let { input.json.decodeFromJsonElement(it) },
nbHits = tree["nbHits"]?.let { input.json.decodeFromJsonElement(it) },
nbPages = tree["nbPages"]?.let { input.json.decodeFromJsonElement(it) },
hitsPerPage = tree["hitsPerPage"]?.let { input.json.decodeFromJsonElement(it) },
additionalProperties = tree.filterKeys { it !in descriptor.elementNames },
)
}
Expand All @@ -226,10 +226,6 @@ internal object SearchResponseSerializer : KSerializer<SearchResponse> {
val output = encoder.asJsonEncoder()
val json = buildJsonObject {
put("processingTimeMS", output.json.encodeToJsonElement(value.processingTimeMS))
put("page", output.json.encodeToJsonElement(value.page))
put("nbHits", output.json.encodeToJsonElement(value.nbHits))
put("nbPages", output.json.encodeToJsonElement(value.nbPages))
put("hitsPerPage", output.json.encodeToJsonElement(value.hitsPerPage))
put("hits", output.json.encodeToJsonElement(value.hits))
put("query", output.json.encodeToJsonElement(value.query))
put("params", output.json.encodeToJsonElement(value.params))
Expand Down Expand Up @@ -257,6 +253,10 @@ internal object SearchResponseSerializer : KSerializer<SearchResponse> {
value.userData?.let { put("userData", output.json.encodeToJsonElement(it)) }
value.queryID?.let { put("queryID", output.json.encodeToJsonElement(it)) }
value.automaticInsights?.let { put("_automaticInsights", output.json.encodeToJsonElement(it)) }
value.page?.let { put("page", output.json.encodeToJsonElement(it)) }
value.nbHits?.let { put("nbHits", output.json.encodeToJsonElement(it)) }
value.nbPages?.let { put("nbPages", output.json.encodeToJsonElement(it)) }
value.hitsPerPage?.let { put("hitsPerPage", output.json.encodeToJsonElement(it)) }
value.additionalProperties?.onEach { (key, element) -> put(key, element) }
}
(encoder as JsonEncoder).encodeJsonElement(json)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ import kotlin.jvm.JvmInline
* SnippetResult
*
* Implementations:
* - [List<SnippetResultOption>] - *[SnippetResult.of]*
* - [List<SnippetResult>] - *[SnippetResult.of]*
* - [Map<kotlin.String, SnippetResult>] - *[SnippetResult.of]*
* - [Map<kotlin.String, SnippetResultOption>] - *[SnippetResult.of]*
* - [SnippetResultOption]
*/
@Serializable(SnippetResultSerializer::class)
Expand All @@ -27,22 +26,15 @@ public sealed interface SnippetResult {

@Serializable
@JvmInline
public value class MapOfkotlinStringSnippetResultOptionValue(public val value: Map<kotlin.String, SnippetResultOption>) : SnippetResult

@Serializable
@JvmInline
public value class ListOfSnippetResultOptionValue(public val value: List<SnippetResultOption>) : SnippetResult
public value class ListOfSnippetResultValue(public val value: List<SnippetResult>) : SnippetResult

public companion object {

public fun ofMapOfkotlinStringSnippetResult(value: Map<kotlin.String, SnippetResult>): SnippetResult {
public fun of(value: Map<kotlin.String, SnippetResult>): SnippetResult {
return MapOfkotlinStringSnippetResultValue(value)
}
public fun ofMapOfkotlinStringSnippetResultOption(value: Map<kotlin.String, SnippetResultOption>): SnippetResult {
return MapOfkotlinStringSnippetResultOptionValue(value)
}
public fun of(value: List<SnippetResultOption>): SnippetResult {
return ListOfSnippetResultOptionValue(value)
public fun of(value: List<SnippetResult>): SnippetResult {
return ListOfSnippetResultValue(value)
}
}
}
Expand All @@ -52,8 +44,7 @@ internal class SnippetResultSerializer : JsonContentPolymorphicSerializer<Snippe
return when {
element is JsonObject && element.containsKey("matchLevel") -> SnippetResultOption.serializer()
element is JsonObject -> SnippetResult.MapOfkotlinStringSnippetResultValue.serializer()
element is JsonObject -> SnippetResult.MapOfkotlinStringSnippetResultOptionValue.serializer()
element.isJsonArrayOfObjects -> SnippetResult.ListOfSnippetResultOptionValue.serializer()
element.isJsonArrayOfObjects -> SnippetResult.ListOfSnippetResultValue.serializer()
else -> throw AlgoliaClientException("Failed to deserialize json element: $element")
}
}
Expand Down

0 comments on commit 23f3218

Please sign in to comment.