TypeGraphToJsonSchemaTransformer

class TypeGraphToJsonSchemaTransformer @JvmOverloads constructor(val config: JsonSchemaConfig, val json: Json = Json { encodeDefaults = false }) : AbstractTypeGraphTransformer<JsonSchema, JsonSchemaConfig> (source)

Transforms TypeGraph IR into JSON Schema Draft 2020-12 format.

Converts type graphs from introspectors (reflection, KSP) into JSON Schema definitions. Supports primitives, collections, objects, enums, and sealed hierarchies with discriminators. All named types (objects, enums, sealed hierarchies) are emitted as $ref with definitions registered in $defs exactly once, regardless of nullability. Nullable named types use oneOf: [{type: null}, {$ref}].

Parameters

json

JSON encoder for schema elements

Constructors

Link copied to clipboard
constructor(config: JsonSchemaConfig, json: Json = Json { encodeDefaults = false })

Properties

Link copied to clipboard
open override val config: JsonSchemaConfig
Link copied to clipboard
val json: Json

Functions

Link copied to clipboard
open override fun transform(graph: TypeGraph, rootName: String): JsonSchema

Transforms a type graph into a JSON Schema.