Skip to content

Commit ebbad32

Browse files
committed
fix(specs): recommend is optional (generated)
algolia/api-clients-automation#3967 Co-authored-by: algolia-bot <[email protected]>
1 parent d74a4cb commit ebbad32

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

client/src/commonMain/kotlin/com/algolia/client/model/recommend/RecommendHit.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,18 @@ import kotlinx.serialization.json.*
1111
* Recommend hit.
1212
*
1313
* @param objectID Unique record identifier.
14-
* @param score Recommendation score.
1514
* @param highlightResult Surround words that match the query with HTML tags for highlighting.
1615
* @param snippetResult Snippets that show the context around a matching search query.
1716
* @param rankingInfo
1817
* @param distinctSeqID
18+
* @param score Recommendation score.
1919
*/
2020
@Serializable(RecommendHitSerializer::class)
2121
public data class RecommendHit(
2222

2323
/** Unique record identifier. */
2424
val objectID: String,
2525

26-
/** Recommendation score. */
27-
val score: Double,
28-
2926
/** Surround words that match the query with HTML tags for highlighting. */
3027
val highlightResult: Map<kotlin.String, HighlightResult>? = null,
3128

@@ -36,30 +33,33 @@ public data class RecommendHit(
3633

3734
val distinctSeqID: Int? = null,
3835

36+
/** Recommendation score. */
37+
val score: Double? = null,
38+
3939
val additionalProperties: Map<String, JsonElement>? = null,
4040
) : RecommendationsHit
4141

4242
internal object RecommendHitSerializer : KSerializer<RecommendHit> {
4343

4444
override val descriptor: SerialDescriptor = buildClassSerialDescriptor("RecommendHit") {
4545
element<String>("objectID")
46-
element<Double>("_score")
4746
element<Map<kotlin.String, HighlightResult>>("_highlightResult", isOptional = true)
4847
element<Map<kotlin.String, SnippetResult>>("_snippetResult", isOptional = true)
4948
element<RankingInfo>("_rankingInfo", isOptional = true)
5049
element<Int>("_distinctSeqID", isOptional = true)
50+
element<Double>("_score", isOptional = true)
5151
}
5252

5353
override fun deserialize(decoder: Decoder): RecommendHit {
5454
val input = decoder.asJsonDecoder()
5555
val tree = input.decodeJsonObject()
5656
return RecommendHit(
5757
objectID = tree.getValue("objectID").let { input.json.decodeFromJsonElement(it) },
58-
score = tree.getValue("_score").let { input.json.decodeFromJsonElement(it) },
5958
highlightResult = tree["_highlightResult"]?.let { input.json.decodeFromJsonElement(it) },
6059
snippetResult = tree["_snippetResult"]?.let { input.json.decodeFromJsonElement(it) },
6160
rankingInfo = tree["_rankingInfo"]?.let { input.json.decodeFromJsonElement(it) },
6261
distinctSeqID = tree["_distinctSeqID"]?.let { input.json.decodeFromJsonElement(it) },
62+
score = tree["_score"]?.let { input.json.decodeFromJsonElement(it) },
6363
additionalProperties = tree.filterKeys { it !in descriptor.elementNames },
6464
)
6565
}
@@ -68,11 +68,11 @@ internal object RecommendHitSerializer : KSerializer<RecommendHit> {
6868
val output = encoder.asJsonEncoder()
6969
val json = buildJsonObject {
7070
put("objectID", output.json.encodeToJsonElement(value.objectID))
71-
put("_score", output.json.encodeToJsonElement(value.score))
7271
value.highlightResult?.let { put("_highlightResult", output.json.encodeToJsonElement(it)) }
7372
value.snippetResult?.let { put("_snippetResult", output.json.encodeToJsonElement(it)) }
7473
value.rankingInfo?.let { put("_rankingInfo", output.json.encodeToJsonElement(it)) }
7574
value.distinctSeqID?.let { put("_distinctSeqID", output.json.encodeToJsonElement(it)) }
75+
value.score?.let { put("_score", output.json.encodeToJsonElement(it)) }
7676
value.additionalProperties?.onEach { (key, element) -> put(key, element) }
7777
}
7878
(encoder as JsonEncoder).encodeJsonElement(json)

client/src/commonMain/kotlin/com/algolia/client/model/recommend/TrendingFacetHit.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ import kotlinx.serialization.json.*
77
/**
88
* Trending facet hit.
99
*
10-
* @param score Recommendation score.
1110
* @param facetName Facet attribute. To be used in combination with `facetValue`. If specified, only recommendations matching the facet filter will be returned.
1211
* @param facetValue Facet value. To be used in combination with `facetName`. If specified, only recommendations matching the facet filter will be returned.
12+
* @param score Recommendation score.
1313
*/
1414
@Serializable
1515
public data class TrendingFacetHit(
1616

17-
/** Recommendation score. */
18-
@SerialName(value = "_score") val score: Double,
19-
2017
/** Facet attribute. To be used in combination with `facetValue`. If specified, only recommendations matching the facet filter will be returned. */
2118
@SerialName(value = "facetName") val facetName: String,
2219

2320
/** Facet value. To be used in combination with `facetName`. If specified, only recommendations matching the facet filter will be returned. */
2421
@SerialName(value = "facetValue") val facetValue: String,
22+
23+
/** Recommendation score. */
24+
@SerialName(value = "_score") val score: Double? = null,
2525
) : RecommendationsHit

0 commit comments

Comments
 (0)