Package-level declarations

Intermediate representation (IR) models and transformers.

Types

Link copied to clipboard
abstract class AbstractTypeGraphTransformer<R, C>(val config: C) : TypeGraphTransformer<R, C>

Abstract base class for implementing type graph transformations into target schema formats.

Link copied to clipboard
data class AnyNode(val description: String? = null) : TypeNode

Any/unconstrained type node — emits {} in JSON Schema (accepts any value).

Link copied to clipboard
data class AppliedTypeName(val declaration: String, val arguments: List<AppliedTypeName.Argument> = emptyList())

A TypeId split into its declaration and the type arguments it is applied to, see appliedTypeId.

Link copied to clipboard
fun interface DescriptionExtractor

Functional interface describing a strategy for extracting a property/type description from a list of annotations associated with it. It's used to allow custom description annotations.

Link copied to clipboard
data class Discriminator(val name: String, val mapping: Map<String, TypeId>? = null)

Class discriminator information. If mapping is null, default implicit mapping is assumed (typically discriminator value equals subtype serial name).

Link copied to clipboard
data class EnumNode(val name: String, val entries: List<String>, val defaultValue: String? = null, val description: String? = null) : NamedTypeNode

Enum node with symbolic entries.

Link copied to clipboard

Utility object for annotation-based introspection, providing methods to process annotations for descriptions, ignore markers, and name overrides.

Link copied to clipboard
data class ListNode(val element: TypeRef, val description: String? = null) : TypeNode

List/array node.

Link copied to clipboard
sealed interface Literal

A JSON-compatible literal value, independent of any schema dialect; used for defaults and constants.

Link copied to clipboard
data class MapNode(val key: TypeRef, val value: TypeRef, val description: String? = null) : TypeNode

Map/dictionary node.

Link copied to clipboard
sealed interface NamedTypeNode : TypeNode

A named type node.

Link copied to clipboard
data class ObjectNode(val name: String, val properties: List<Property>, val description: String? = null) : NamedTypeNode

Object node with named properties.

Link copied to clipboard
data class PolymorphicNode(val name: String, val subtypes: List<SubtypeRef>, val discriminator: Discriminator, val description: String? = null) : NamedTypeNode

Polymorphic node for sealed/open hierarchies.

Link copied to clipboard

Primitive kinds supported by the IR.

Link copied to clipboard
data class PrimitiveNode(val kind: PrimitiveKind, val description: String? = null) : TypeNode

Primitive node.

Link copied to clipboard
data class Property(val name: String, val type: TypeRef, val description: String? = null, val deprecated: Boolean = false, val optional: Boolean = false, val value: PropertyValue = PropertyValue.None, val annotations: Map<String, String?> = emptyMap())

Property of an object.

Link copied to clipboard
sealed interface PropertyValue

The value attached to a Property: nothing, an unknown default, a default literal, or a constant.

Link copied to clipboard
interface SchemaIntrospector<T, C>

A facade for building TypeGraph from a particular source (e.g. KSP or Serialization).

Link copied to clipboard
data class SubtypeRef(val id: TypeId, val ref: TypeRef.Ref = TypeRef.Ref(id))

Reference to a subtype in a polymorphic hierarchy.

Link copied to clipboard
data class TypeGraph(val root: TypeRef, val nodes: Map<TypeId, TypeNode>)

A graph of discovered types plus the root type reference used to emit schemas.

Link copied to clipboard

Converts a TypeGraph intermediate representation to a target schema format.

Link copied to clipboard
value class TypeId(val value: String)

Identity of a type, used for deduplication and $ref linking.

Link copied to clipboard
sealed interface TypeNode

Base node for all kinds supported by the schema IR.

Link copied to clipboard
sealed interface TypeRef

Reference to a type: either inline node or reference by TypeId.

Functions

Link copied to clipboard
fun appliedTypeId(declaration: String, arguments: List<String>): TypeId

Returns the TypeId of declaration applied to arguments, such as pkg.Box<kotlin.String,kotlin.Int?>.

Link copied to clipboard

Returns whether this property must be present under the base presence rule: constants always are, otherwise it is unless it is Property.optional or has a known default.

Link copied to clipboard

Parses this id as built by appliedTypeId; returns null if it is not well-formed.

Link copied to clipboard

Converts this literal to the equivalent Kotlin value (Long, Double, String, List, Map, ...).

Link copied to clipboard
fun Any?.toLiteral(enumEntryName: (Enum<*>) -> String = { it.name }): Literal?

Converts this Kotlin value to a Literal, or returns null if it has no JSON representation (e.g. a non-finite decimal).

Link copied to clipboard

Returns a copy of this TypeNode with the specified description.

Link copied to clipboard

Returns a copy of this TypeRef with the specified nullable flag. Shared across introspection front ends (reflection, KSP, APT, kotlinx.serialization) so conventions layered on top of native nullability (e.g. @Nullable-style annotations, type-name patterns) all go through the same code path.