From 91b328c785c03891cdcc24c0b99c3373fef1eea6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20=E2=80=9CCLOVIS=E2=80=9D=20Canet?= Date: Tue, 24 Feb 2026 21:01:06 +0100 Subject: [PATCH] docs(bson): Improve the documentation of ObjectId.Serializer --- bson/src/commonMain/kotlin/types/ObjectId.kt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/bson/src/commonMain/kotlin/types/ObjectId.kt b/bson/src/commonMain/kotlin/types/ObjectId.kt index e18e4ffe..cba8e461 100644 --- a/bson/src/commonMain/kotlin/types/ObjectId.kt +++ b/bson/src/commonMain/kotlin/types/ObjectId.kt @@ -23,6 +23,7 @@ import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder +import opensavvy.ktmongo.bson.BsonType import opensavvy.ktmongo.bson.types.ObjectId.Companion.maxAt import opensavvy.ktmongo.bson.types.ObjectId.Companion.minAt import opensavvy.ktmongo.dsl.LowLevelApi @@ -267,13 +268,17 @@ class ObjectId : Comparable { /** * Default serializer for [ObjectId]. * - * `:bson-multiplatform` and `:bson-official` both override this serializer. - * This serializer exists so that `@Contextual` is not required. - * It may also be used to convert the DTOs to other formats, like JSON. + * ### When serializing to BSON * - * Using this serializer, [ObjectId] is represented as if it were a [String]. + * [ObjectId] instances are encoded using MongoDB's native [BsonType.ObjectId] BSON type. * - * Avoid interacting with this type directly. + * Supported drivers: + * - The official `:bson-kotlinx` serialization library. + * - The KtMongo Multiplatform driver. + * + * ### When serializing to other formats + * + * When serializing to other formats, like JSON, [ObjectId] instances are represented as 24-characters [hex] strings. */ @LowLevelApi object Serializer : KSerializer { -- 2.51.2