Schema

data class Schema(val type: Type? = null, val properties: Map<String, Schema>? = null, val items: Schema? = null, val required: List<String>? = null, val description: String? = null, val enum: List<String>? = null, val format: String? = null, val nullable: Boolean? = null, val default: Any? = null, val anyOf: List<Schema>? = null, val title: String? = null, val pattern: String? = null, val minimum: Double? = null, val maximum: Double? = null, val minLength: Long? = null, val maxLength: Long? = null, val minItems: Long? = null, val maxItems: Long? = null, val minProperties: Long? = null, val maxProperties: Long? = null)

Schema is used to define the format of input/output data.

Represents a select subset of an OpenAPI 3.0 schema object.

Constructors

Link copied to clipboard
constructor(type: Type? = null, properties: Map<String, Schema>? = null, items: Schema? = null, required: List<String>? = null, description: String? = null, enum: List<String>? = null, format: String? = null, nullable: Boolean? = null, default: Any? = null, anyOf: List<Schema>? = null, title: String? = null, pattern: String? = null, minimum: Double? = null, maximum: Double? = null, minLength: Long? = null, maxLength: Long? = null, minItems: Long? = null, maxItems: Long? = null, minProperties: Long? = null, maxProperties: Long? = null)

Types

Link copied to clipboard
class Builder

Fluent builder for Schema, provided primarily for Java callers. Any property left unset falls back to the same default as the constructor.

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The value must validate against at least one of these subschemas.

Link copied to clipboard
val default: Any?

The value to assume when the property is absent. Must be JSON-native -- a String, number, Boolean, Map or List -- since anything else fails to serialize. Serializing a Schema that sets this needs a Json whose serializersModule carries a contextual serializer for Any; a plain Json throws. JSON also has a single number type, so a numeric default that crosses a JSON boundary comes back as whatever Kotlin type the reader picks, not necessarily the one it was written as.

Link copied to clipboard

A human-readable description of the schema.

Link copied to clipboard

Restricts a value to a fixed set of values.

Link copied to clipboard

The format of the data, refining type. The field is free-form, but Gemini accepts only int32 or int64 for Type.INTEGER and Type.NUMBER, and enum or date-time for Type.STRING; it rejects a declaration carrying any other value.

Link copied to clipboard

Describes the schema of items in an array. Applicable only if type is Type.ARRAY.

Link copied to clipboard

The largest allowed value. Applicable only if type is Type.INTEGER or Type.NUMBER.

Link copied to clipboard

The most allowed items. Applicable only if type is Type.ARRAY.

Link copied to clipboard

The longest allowed string. Applicable only if type is Type.STRING.

Link copied to clipboard

The most allowed properties. Applicable only if type is Type.OBJECT.

Link copied to clipboard

The smallest allowed value. Applicable only if type is Type.INTEGER or Type.NUMBER.

Link copied to clipboard

The fewest allowed items. Applicable only if type is Type.ARRAY.

Link copied to clipboard

The shortest allowed string. Applicable only if type is Type.STRING.

Link copied to clipboard

The fewest allowed properties. Applicable only if type is Type.OBJECT.

Link copied to clipboard

Whether the value may be null.

Link copied to clipboard

A regular expression the value must match. Applicable only if type is Type.STRING.

Link copied to clipboard

Describes the properties of an object. The keys are property names and values are schemas for corresponding properties. Applicable only if type is Type.OBJECT.

Link copied to clipboard

A list of required property names. Applicable only if type is Type.OBJECT.

Link copied to clipboard

A title for the schema.

Link copied to clipboard
val type: Type?

Data type of the schema.