skema

SchemaDef

@Serializable
data class SchemaDef<C>(val entries: Map<String, C>)(source)

Pure-data, serializable form of a Schema. The default root field name is entries; for a different name or adjunct fields, define your own Serializable wrapper and override Schema.definition.

Constructors

Link copied to clipboard
constructor(entries: Map<String, C>)

Properties

Link copied to clipboard

Entries keyed by name, in declaration order.

Link copied to clipboard

Set of entry names.

Link copied to clipboard
val size: Int

Number of entries.

Functions

Link copied to clipboard
fun <C> SchemaDef<C>.diff(other: SchemaDef<C>): SchemaDiff<C>

Computes the SchemaDiff from this schema to other.

Link copied to clipboard
operator fun get(name: String): C

Returns the entry for name, or throws if no such entry exists.

Link copied to clipboard
fun <C> SchemaDef<C>.namespaced(prefix: String, separator: String = "."): SchemaDef<C>

Prefix every entry name (default separator .).

Link copied to clipboard
operator fun <C> SchemaDef<C>.plus(other: SchemaDef<C>): SchemaDef<C>

Combine two schemas into one; throws on any overlapping name.

Link copied to clipboard
fun SchemaDef<JsonSpec>.toJsonSchema(defs: Map<String, JsonSpec> = emptyMap()): JsonObject

JSON Schema (draft 2020-12) for a schema whose entries are JsonSpecs. All entries are emitted as required; post-process the result if a different required-set is needed. Supply defs to populate the root $defs block; reference them with JsonSpec.Ref("#/${'$'}defs/<name>").

fun <C : Any> SchemaDef<C>.toJsonSchema(defs: Map<String, JsonSpec> = emptyMap(), map: (C) -> JsonObject): JsonObject

JSON Schema (draft 2020-12) for an arbitrary config vocabulary. Supply a mapper that turns each entry's config into a JSON Schema fragment for the value it validates. For mixed hierarchies, call JsonSpec.toJsonSchema inside the lambda for the JsonSpec branches. Supply defs to populate the root $defs block.

SchemaDef

constructor(entries: Map<String, C>)(source)

entries

Entries keyed by name, in declaration order.

get

operator fun get(name: String): C(source)

Returns the entry for name, or throws if no such entry exists.

names

Set of entry names.

size

Number of entries.