Schema

@Serializable
sealed class Schema

Represents a JSON Schema definition.

This sealed class and its subclasses model different types in JSON Schema:

  • ObjectSchema: Represents a JSON object with defined properties.

  • StringSchema: Represents a string type, possibly with an enumeration of allowed values.

  • NumberSchema: Represents a numeric type (integers, floats, doubles).

  • ArraySchema: Represents an array type, specifying items as another schema.

  • BooleanSchema: Represents a boolean type.

Inheritors

Types

Link copied to clipboard
@Serializable
@SerialName(value = "array")
data class ArraySchema(val description: String? = null, val items: Schema) : Schema
Link copied to clipboard
@Serializable
@SerialName(value = "boolean")
data class BooleanSchema(val description: String? = null) : Schema
Link copied to clipboard
@Serializable
@SerialName(value = "number")
data class NumberSchema(val description: String? = null) : Schema
Link copied to clipboard
@Serializable
@SerialName(value = "object")
data class ObjectSchema(val description: String? = null, val properties: Map<String, Schema>? = null, val required: List<String>? = null, val additionalProperties: JsonElement? = null) : Schema
Link copied to clipboard
@Serializable
@SerialName(value = "string")
data class StringSchema(val description: String? = null, val enum: List<String>? = null) : Schema

Properties

Link copied to clipboard
abstract val description: String?

Functions

Link copied to clipboard
fun Schema.toJsonElement(): JsonElement

Converts this Schema instance into a JsonElement.