Class Schema
-
- All Implemented Interfaces:
public abstract class Schema extends JsonSerializable
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 Modifier and Type Class Description public abstract classSchema.BuilderBuilder for Schema.
-
Field Summary
Fields Modifier and Type Field Description public final static StringMAX_READ_LENGTH_PROPERTY
-
Constructor Summary
Constructors Constructor Description Schema()
-
Method Summary
Modifier and Type Method Description abstract Optional<List<Schema>>anyOf()Optional. abstract Optional<Object>default_()Optional. abstract Optional<String>description()Optional. abstract Optional<List<String>>enum_()Optional. abstract Optional<Object>example()Optional. abstract Optional<String>format()Optional. abstract Optional<Schema>items()Optional. abstract Optional<Long>maxItems()Optional. abstract Optional<Long>maxLength()Optional. abstract Optional<Long>maxProperties()Optional. abstract Optional<Double>maximum()Optional. abstract Optional<Long>minItems()Optional. abstract Optional<Long>minLength()Optional. abstract Optional<Long>minProperties()Optional. abstract Optional<Double>minimum()Optional. abstract Optional<Boolean>nullable()Optional. abstract Optional<String>pattern()Optional. abstract Optional<Map<String, Schema>>properties()Optional. abstract Optional<List<String>>propertyOrdering()Optional. abstract Optional<List<String>>required()Optional. abstract Optional<String>title()Optional. abstract Optional<Type>type()Optional. static Schema.Builderbuilder()Instantiates a builder for Schema. abstract Schema.BuildertoBuilder()Creates a builder with the same values as this instance. static SchemafromJson(String jsonString)Deserializes a JSON string to a Schema object. -
Methods inherited from class com.google.genai.JsonSerializable
fromJsonNode, fromJsonString, objectMapper, setMaxReadLength, stringToJsonNode, toJson, toJsonNode, toJsonString -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
anyOf
abstract Optional<List<Schema>> anyOf()
Optional. The instance must be valid against any (one or more) of the subschemas listed in `any_of`.
-
default_
abstract Optional<Object> default_()
Optional. Default value to use if the field is not specified.
-
description
abstract Optional<String> description()
Optional. Describes the data. The model uses this field to understand the purpose of the schema and how to use it. It is a best practice to provide a clear and descriptive explanation for the schema and its properties here, rather than in the prompt.
-
enum_
abstract Optional<List<String>> 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"]}`
-
format
abstract Optional<String> 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
abstract Optional<Schema> items()
Optional. If type is `ARRAY`, `items` specifies the schema of elements in the array.
-
maxItems
abstract Optional<Long> maxItems()
Optional. If type is `ARRAY`, `max_items` specifies the maximum number of items in an array.
-
maxLength
abstract Optional<Long> maxLength()
Optional. If type is `STRING`, `max_length` specifies the maximum length of the string.
-
maxProperties
abstract Optional<Long> maxProperties()
Optional. If type is `OBJECT`, `max_properties` specifies the maximum number of properties that can be provided.
-
maximum
abstract Optional<Double> maximum()
Optional. If type is `INTEGER` or `NUMBER`, `maximum` specifies the maximum allowed value.
-
minItems
abstract Optional<Long> minItems()
Optional. If type is `ARRAY`, `min_items` specifies the minimum number of items in an array.
-
minLength
abstract Optional<Long> minLength()
Optional. If type is `STRING`, `min_length` specifies the minimum length of the string.
-
minProperties
abstract Optional<Long> minProperties()
Optional. If type is `OBJECT`, `min_properties` specifies the minimum number of properties that can be provided.
-
minimum
abstract Optional<Double> minimum()
Optional. If type is `INTEGER` or `NUMBER`, `minimum` specifies the minimum allowed value.
-
nullable
abstract Optional<Boolean> nullable()
Optional. Indicates if the value of this field can be null.
-
pattern
abstract Optional<String> pattern()
Optional. If type is `STRING`, `pattern` specifies a regular expression that the string must match.
-
properties
abstract Optional<Map<String, Schema>> properties()
Optional. If type is `OBJECT`, `properties` is a map of property names to schema definitions for each property of the object.
-
propertyOrdering
abstract Optional<List<String>> 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
abstract Optional<List<String>> required()
Optional. If type is `OBJECT`, `required` lists the names of properties that must be present.
-
builder
static Schema.Builder builder()
Instantiates a builder for Schema.
-
toBuilder
abstract Schema.Builder toBuilder()
Creates a builder with the same values as this instance.
-
-
-
-