Package com.google.genai.types
Class Schema
java.lang.Object
com.google.genai.JsonSerializable
com.google.genai.types.Schema
Schema is used to define the format of input/output data.
Represents a select subset of an [OpenAPI 3.0 schema object](https://spec.openapis.org/oas/v3.0.3#schema-object). More fields may be added in the future as needed.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class com.google.genai.JsonSerializable
MAX_READ_LENGTH_PROPERTY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionanyOf()Optional.static Schema.Builderbuilder()Instantiates a builder for Schema.default_()Optional.Optional.enum_()Optional.example()Optional.format()Optional.static SchemaDeserializes a JSON string to a Schema object.items()Optional.maximum()Optional.maxItems()Optional.Optional.Optional.minimum()Optional.minItems()Optional.Optional.Optional.nullable()Optional.pattern()Optional.Optional.Optional.required()Optional.title()Optional.abstract Schema.BuilderCreates a builder with the same values as this instance.type()Optional.Methods inherited from class com.google.genai.JsonSerializable
fromJsonNode, fromJsonString, objectMapper, setMaxReadLength, stringToJsonNode, toJson, toJsonNode, toJsonString
-
Constructor Details
-
Schema
public Schema()
-
-
Method Details
-
anyOf
Optional. The instance must be valid against any (one or more) of the subschemas listed in `any_of`. -
default_
Optional. Default value to use if the field is not specified. -
description
Optional. Description of the schema. -
enum_
Optional. Possible values of the field. This field can be used to restrict a value to a fixed set of values. To mark a field as an enum, set `format` to `enum` and provide the list of possible values in `enum`. For example: 1. To define directions: `{type:STRING, format:enum, enum:["EAST", "NORTH", "SOUTH", "WEST"]}` 2. To define apartment numbers: `{type:INTEGER, format:enum, enum:["101", "201", "301"]}` -
example
Optional. Example of an instance of this schema. -
format
Optional. The format of the data. For `NUMBER` type, format can be `float` or `double`. For `INTEGER` type, format can be `int32` or `int64`. For `STRING` type, format can be `email`, `byte`, `date`, `date-time`, `password`, and other formats to further refine the data type. -
items
Optional. If type is `ARRAY`, `items` specifies the schema of elements in the array. -
maxItems
Optional. If type is `ARRAY`, `max_items` specifies the maximum number of items in an array. -
maxLength
Optional. If type is `STRING`, `max_length` specifies the maximum length of the string. -
maxProperties
Optional. If type is `OBJECT`, `max_properties` specifies the maximum number of properties that can be provided. -
maximum
Optional. If type is `INTEGER` or `NUMBER`, `maximum` specifies the maximum allowed value. -
minItems
Optional. If type is `ARRAY`, `min_items` specifies the minimum number of items in an array. -
minLength
Optional. If type is `STRING`, `min_length` specifies the minimum length of the string. -
minProperties
Optional. If type is `OBJECT`, `min_properties` specifies the minimum number of properties that can be provided. -
minimum
Optional. If type is `INTEGER` or `NUMBER`, `minimum` specifies the minimum allowed value. -
nullable
Optional. Indicates if the value of this field can be null. -
pattern
Optional. If type is `STRING`, `pattern` specifies a regular expression that the string must match. -
properties
Optional. If type is `OBJECT`, `properties` is a map of property names to schema definitions for each property of the object. -
propertyOrdering
Optional. Order of properties displayed or used where order matters. This is not a standard field in OpenAPI specification, but can be used to control the order of properties. -
required
Optional. If type is `OBJECT`, `required` lists the names of properties that must be present. -
title
Optional. Title for the schema. -
type
Optional. Data type of the schema field. -
builder
Instantiates a builder for Schema. -
toBuilder
Creates a builder with the same values as this instance. -
fromJson
Deserializes a JSON string to a Schema object.
-