com.lightningkite.lightningserver.jsonschema.PostFields.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of server-core Show documentation
Show all versions of server-core Show documentation
A set of tools to fill in/replace what Ktor is lacking in.
The newest version!
@file:UseContextualSerialization(UUID::class)
@file:OptIn(ExperimentalSerializationApi::class, InternalSerializationApi::class)
package com.lightningkite.lightningserver.jsonschema
import com.lightningkite.lightningdb.GenerateDataClassPaths
import com.lightningkite.lightningdb.HasId
import kotlinx.serialization.Serializable
import kotlinx.serialization.UseContextualSerialization
import java.util.*
import com.lightningkite.lightningdb.*
import kotlin.reflect.*
import kotlinx.serialization.*
import kotlinx.serialization.builtins.*
import kotlinx.serialization.internal.GeneratedSerializer
import java.time.*
fun preparePostFields() {
Post::_id.setCopyImplementation { original, value -> original.copy(_id = value) }
Post::author.setCopyImplementation { original, value -> original.copy(author = value) }
Post::title.setCopyImplementation { original, value -> original.copy(title = value) }
Post::content.setCopyImplementation { original, value -> original.copy(content = value) }
}
val DataClassPath._id: DataClassPath get() = this[Post::_id]
val DataClassPath.author: DataClassPath get() = this[Post::author]
val DataClassPath.title: DataClassPath get() = this[Post::title]
val DataClassPath.content: DataClassPath get() = this[Post::content]
inline val Post.Companion.path: DataClassPath get() = path()