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

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

There is a newer version: 0.0.5-alpha.118
Show 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.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 = CreateCompletionRequestStopSerializer::class)
sealed interface CreateCompletionRequestStop {

  @JvmInline
  @Serializable
  value class CaseString(val value: kotlin.String): CreateCompletionRequestStop
  @JvmInline
  @Serializable
  value class CaseStrings(val value: kotlin.collections.List): CreateCompletionRequestStop

}

object CreateCompletionRequestStopSerializer : KSerializer {
    @OptIn(InternalSerializationApi::class, ExperimentalSerializationApi::class)
    override val descriptor: SerialDescriptor = buildSerialDescriptor("CreateCompletionRequestStop", PolymorphicKind.SEALED) { 
      element("1", kotlin.String.serializer().descriptor)
      element("2", ListSerializer(kotlin.String.serializer()).descriptor)
    }

    override fun deserialize(decoder: Decoder): CreateCompletionRequestStop {
      val jsonSerde = Json { ignoreUnknownKeys = true }
      val json = decoder.decodeSerializableValue(JsonElement.serializer())
      return attemptDeserialize(json, 
        Pair(CreateCompletionRequestStop.CaseString::class) {
          CreateCompletionRequestStop.CaseString(jsonSerde.decodeFromJsonElement(kotlin.String.serializer(), json))
      },
        Pair(CreateCompletionRequestStop.CaseStrings::class) {
          CreateCompletionRequestStop.CaseStrings(jsonSerde.decodeFromJsonElement(ListSerializer(kotlin.String.serializer()), json))
      })
    }

    override fun serialize(encoder: Encoder, value: CreateCompletionRequestStop) =
      when(value) { 
        is CreateCompletionRequestStop.CaseString ->
        encoder.encodeSerializableValue(kotlin.String.serializer(), value.value)

        is CreateCompletionRequestStop.CaseStrings ->
        encoder.encodeSerializableValue(ListSerializer(kotlin.String.serializer()), value.value)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy