Schema

@Serializable
data class Schema(val type: String, val format: String? = null, val description: String? = null, val nullable: Boolean = false, val enum: List<String> = emptyList(), val properties: Map<String, Schema> = emptyMap(), val required: List<String> = emptyList(), val items: Schema? = null)

Represents the schema definition for a data model, detailing its structure, type, and various constraints.

Constructors

Link copied to clipboard
constructor(type: String, format: String? = null, description: String? = null, nullable: Boolean = false, enum: List<String> = emptyList(), properties: Map<String, Schema> = emptyMap(), required: List<String> = emptyList(), items: Schema? = null)

Properties

Link copied to clipboard
val description: String? = null

A human-readable description of the schema, explaining its purpose and usage.

Link copied to clipboard
val enum: List<String>

A list of acceptable values for this schema if it represents an enumeration type.

Link copied to clipboard
val format: String? = null

Additional formatting information for the data type, providing more precise definition (e.g., "date-time" for string type).

Link copied to clipboard
val items: Schema? = null

The schema for items in an array, applicable when the type is "array". Defines the schema of elements within the array.

Link copied to clipboard
val nullable: Boolean = false

Indicates whether the value can be null.

Link copied to clipboard
val properties: Map<String, Schema>

A map of property names to their respective schemas, defining the structure of an object type. Each entry represents a field and its schema.

Link copied to clipboard
val required: List<String>

A list of property names that are required for this schema, ensuring certain fields must be present in the data.

Link copied to clipboard
val type: String

The primary type of data this schema represents (e.g., "string", "integer", "object").