All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.com.xebia.functional.openai.generated.model.ThreadStreamEvent.kt Maven / Gradle / Ivy

The newest version!
/**
 *
 * Please note:
 * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * Do not edit this file manually.
 *
 */

@file:Suppress(
    "ArrayInDataClass",
    "EnumEntryName",
    "RemoveRedundantQualifierName",
    "UnusedImport"
)

package com.xebia.functional.openai.generated.model

import com.xebia.functional.openai.generated.model.ThreadObject
import com.xebia.functional.openai.generated.model.ThreadStreamEventOneOf
import com.xebia.functional.openai.attemptDeserialize
import kotlin.jvm.JvmInline
import kotlinx.serialization.*
import kotlinx.serialization.builtins.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*
import kotlinx.serialization.json.*

@Serializable(with = ThreadStreamEventSerializer::class)
sealed interface ThreadStreamEvent {

  @JvmInline
  @Serializable
  value class CaseThreadStreamEventOneOf(val value: ThreadStreamEventOneOf): ThreadStreamEvent

}

object ThreadStreamEventSerializer : KSerializer {
    @OptIn(InternalSerializationApi::class, ExperimentalSerializationApi::class)
    override val descriptor: SerialDescriptor = buildSerialDescriptor("ThreadStreamEvent", PolymorphicKind.SEALED) { 
      element("1", ThreadStreamEventOneOf.serializer().descriptor)
    }

    override fun deserialize(decoder: Decoder): ThreadStreamEvent {
      val jsonSerde = Json { ignoreUnknownKeys = true }
      val json = decoder.decodeSerializableValue(JsonElement.serializer())
      return attemptDeserialize(json, 
        Pair(ThreadStreamEvent.CaseThreadStreamEventOneOf::class) {
          ThreadStreamEvent.CaseThreadStreamEventOneOf(jsonSerde.decodeFromJsonElement(ThreadStreamEventOneOf.serializer(), json))
      })
    }

    override fun serialize(encoder: Encoder, value: ThreadStreamEvent) =
      when(value) { 
        is ThreadStreamEvent.CaseThreadStreamEventOneOf ->
        encoder.encodeSerializableValue(ThreadStreamEventOneOf.serializer(), value.value)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy