JsonSchema

data class JsonSchema(val type: @Serializable(with = JsonSchema.SchemaType.Serializer::class) JsonSchema.SchemaType? = null, val title: String? = null, val description: String? = null, val required: List<String>? = null, val allOf: List<ReferenceOr<JsonSchema>>? = null, val oneOf: List<ReferenceOr<JsonSchema>>? = null, val not: ReferenceOr<JsonSchema>? = null, val anyOf: List<ReferenceOr<JsonSchema>>? = null, val properties: Map<String, ReferenceOr<JsonSchema>>? = null, val additionalProperties: AdditionalProperties? = null, val discriminator: JsonSchemaDiscriminator? = null, val readOnly: Boolean? = null, val writeOnly: Boolean? = null, val xml: Xml? = null, val externalDocs: ExternalDocs? = null, val example: GenericElement? = null, val examples: List<GenericElement>? = null, val deprecated: Boolean? = null, val maxProperties: Int? = null, val minProperties: Int? = null, val default: GenericElement? = null, val format: String? = null, val items: ReferenceOr<JsonSchema>? = null, val prefixItems: List<ReferenceOr<JsonSchema>>? = null, val maximum: Double? = null, val exclusiveMaximum: Double? = null, val minimum: Double? = null, val exclusiveMinimum: Double? = null, val maxLength: Int? = null, val minLength: Int? = null, val pattern: String? = null, val maxItems: Int? = null, val minItems: Int? = null, val uniqueItems: Boolean? = null, val enum: List<GenericElement?>? = null, val const: GenericElement? = null, val multipleOf: Double? = null, val id: String? = null, val anchor: String? = null, val dynamicAnchor: Boolean? = null)(source)

The Schema Object allows the definition of input and output data types. These types can be objects, but also primitives and arrays. This object is an extended subset of the JSON Schema Specification Wright Draft 00. For more information about the properties, see JSON Schema Core and JSON Schema Validation. Unless stated otherwise, the property definitions follow the JSON Schema.

Report a problem

Constructors

Link copied to clipboard
constructor(type: @Serializable(with = JsonSchema.SchemaType.Serializer::class) JsonSchema.SchemaType? = null, title: String? = null, description: String? = null, required: List<String>? = null, allOf: List<ReferenceOr<JsonSchema>>? = null, oneOf: List<ReferenceOr<JsonSchema>>? = null, not: ReferenceOr<JsonSchema>? = null, anyOf: List<ReferenceOr<JsonSchema>>? = null, properties: Map<String, ReferenceOr<JsonSchema>>? = null, additionalProperties: AdditionalProperties? = null, discriminator: JsonSchemaDiscriminator? = null, readOnly: Boolean? = null, writeOnly: Boolean? = null, xml: Xml? = null, externalDocs: ExternalDocs? = null, example: GenericElement? = null, examples: List<GenericElement>? = null, deprecated: Boolean? = null, maxProperties: Int? = null, minProperties: Int? = null, default: GenericElement? = null, format: String? = null, items: ReferenceOr<JsonSchema>? = null, prefixItems: List<ReferenceOr<JsonSchema>>? = null, maximum: Double? = null, exclusiveMaximum: Double? = null, minimum: Double? = null, exclusiveMinimum: Double? = null, maxLength: Int? = null, minLength: Int? = null, pattern: String? = null, maxItems: Int? = null, minItems: Int? = null, uniqueItems: Boolean? = null, enum: List<GenericElement?>? = null, const: GenericElement? = null, multipleOf: Double? = null, id: String? = null, anchor: String? = null, dynamicAnchor: Boolean? = null)

Types

Link copied to clipboard

Sets additionalProperties to true or false. Use AdditionalPropertiesRef if you need to define a schema for additional properties.

Link copied to clipboard

Defines the schema for any additional properties not explicitly listed in properties.

Link copied to clipboard
annotation class Anchor(val value: String, val dynamic: Boolean = false)

$anchor

Link copied to clipboard
annotation class AnyOfRefs(val value: String)

Validates the data against any of the provided schema references.

Link copied to clipboard
annotation class Const(val value: String)

const (JSON literal as text)

Link copied to clipboard
annotation class Default(val value: String)

default (JSON literal as text)

Link copied to clipboard
Link copied to clipboard
annotation class Description(val value: String)

description

Link copied to clipboard

Configures polymorphism using a discriminator property and optional explicit mappings.

Link copied to clipboard
annotation class Enum(val value: String)

enum (each entry is a JSON literal as text)

Link copied to clipboard
annotation class Example(val value: String)

example (JSON literal as text)

Link copied to clipboard
annotation class Format(val value: String)

format (e.g. "date-time", "uuid")

Link copied to clipboard
annotation class Id(val value: String)

$id

Link copied to clipboard
annotation class Ignore

Skips the property from the inferred JSON schema model

Link copied to clipboard
annotation class ItemsRef(val value: KClass<*>)

Defines the schema for items within an array.

Link copied to clipboard
annotation class Maximum(val value: Double, val exclusive: Boolean = false)

maximum (+ optional exclusivity)

Link copied to clipboard
annotation class MaxItems(val value: Int)

maxItems

Link copied to clipboard
annotation class MaxLength(val value: Int)

maxLength

Link copied to clipboard
annotation class MaxProperties(val value: Int)

maxProperties

Link copied to clipboard
annotation class Minimum(val value: Double, val exclusive: Boolean = false)

minimum (+ optional exclusivity)

Link copied to clipboard
annotation class MinItems(val value: Int)

minItems

Link copied to clipboard
annotation class MinLength(val value: Int)

minLength

Link copied to clipboard
annotation class MinProperties(val value: Int)

minProperties

Link copied to clipboard
annotation class MultipleOf(val value: Double)

multipleOf

Link copied to clipboard
annotation class Not(val value: KClass<*>)

Ensures the data does not match the provided schema.

Link copied to clipboard
annotation class OneOf(val value: KClass<*>)

Validates the data against exactly one of the provided schemas.

Link copied to clipboard
annotation class Pattern(val value: String)

pattern

Link copied to clipboard
annotation class PrefixItemsRef(val value: KClass<*>)

Defines positional schemas for items within a tuple-style array (prefixItems).

Link copied to clipboard

readOnly

Link copied to clipboard
annotation class Required(val value: String)

required (property names)

Link copied to clipboard

Represents a sealed interface for defining schema types in a JSON structure.

Link copied to clipboard
annotation class Title(val value: String)

title

Link copied to clipboard
annotation class Type(val value: JsonType)

type (e.g. "string", "object", "array")

Link copied to clipboard

uniqueItems

Link copied to clipboard

writeOnly

Properties

Link copied to clipboard

Schema or boolean defining allowed additional properties.

Link copied to clipboard

Subschemas that must all be valid.

Link copied to clipboard
@SerialName(value = "$anchor")
val anchor: String?

The $anchor reference anchor of the schema.

Link copied to clipboard

Subschemas where at least one must be valid.

Link copied to clipboard

Constant value for the instance.

Link copied to clipboard

Unlike JSON Schema, this value MUST conform to the defined type for this parameter.

Link copied to clipboard

Indicates that the schema is deprecated.

Link copied to clipboard

A verbose explanation of the schema behavior.

Link copied to clipboard

Polymorphic discriminator configuration.

Link copied to clipboard
@SerialName(value = "$dynamicAnchor")
val dynamicAnchor: Boolean?

The $dynamicAnchor dynamic anchor flag of the schema.

Link copied to clipboard

Allowed values for the instance.

Link copied to clipboard

A single example value for the schema.

Link copied to clipboard

A list of example values for the schema.

Link copied to clipboard

Numeric maximum value (exclusive).

Link copied to clipboard

Numeric minimum value (exclusive).

Link copied to clipboard

External documentation reference.

Link copied to clipboard

Semantic format validation hint (e.g., date-time, uuid).

Link copied to clipboard
@SerialName(value = "$id")
val id: String?

The $id identifier of the schema.

Link copied to clipboard

Schema for items within an array.

Link copied to clipboard

Numeric maximum value (inclusive).

Link copied to clipboard

Maximum number of items in an array.

Link copied to clipboard

Maximum length for strings.

Link copied to clipboard

Maximum number of properties allowed in an object.

Link copied to clipboard

Numeric minimum value (inclusive).

Link copied to clipboard

Minimum number of items in an array.

Link copied to clipboard

Minimum length for strings.

Link copied to clipboard

Minimum number of properties allowed in an object.

Link copied to clipboard

Numeric factor for multiples.

Link copied to clipboard

A subschema that must not be valid.

Link copied to clipboard

Subschemas where exactly one must be valid.

Link copied to clipboard

Regular expression pattern for strings.

Link copied to clipboard

Positional schemas for items within an array (tuple validation).

Link copied to clipboard

Definitions for object properties, keyed by property name.

Link copied to clipboard

Indicates that the property is read-only.

Link copied to clipboard

An array of property names that are required.

Link copied to clipboard

A short title for the schema.

Link copied to clipboard

The type of the schema (e.g. string, object, array).

Link copied to clipboard

Indicates whether all items in an array must be unique.

Link copied to clipboard

Indicates that the property is write-only.

Link copied to clipboard
val xml: Xml?

XML representation metadata.

Functions

Link copied to clipboard