Firebase. AI. Schema
ASchema object allows the definition of input and output data types.
Summary
These types can be objects, but also primitives and arrays. Represents a select subset of anOpenAPI 3.0 schema object.
Public types | |
|---|---|
SchemaType | enum The value type of a Schema. |
Properties | |
|---|---|
AnyOfSchemas | IReadOnlyList<Schema >An array of Schema objects. |
Description | stringA human-readable explanation of the purpose of the schema or property. |
EnumValues | IReadOnlyList< string >Possible values of the element of type "String" with "enum" format. |
Format | stringThe format of the data. |
Items | Schema of the elements of type "Array". |
MaxItems | intAn integer specifying the maximum number of items the generated "Array" must contain. |
Maximum | doubleThe maximum value of a numeric type. |
MinItems | intAn integer specifying the minimum number of items the generated "Array" must contain. |
Minimum | doubleThe minimum value of a numeric type. |
Nullable | boolIndicates if the value may be null. |
Properties | IReadOnlyDictionary< string,Schema >Properties of type "Object". |
PropertyOrdering | IReadOnlyList< string >A specific hint provided to the Gemini model, suggesting the order in which the keys should appear in the generated JSON string. |
RequiredProperties | IReadOnlyList< string >Required properties of type "Object". |
Title | stringA human-readable name/summary for the schema or a specific property. |
Type | The data type. |
Public static functions | |
|---|---|
AnyOf(IEnumerable<Schema > schemas) | Returns a Schema representing a value that must conform toany (one or more) of the provided sub-schemas. |
Array(Schema items, string description, bool nullable, int? minItems, int? maxItems) | Returns a Schema for an array. |
Boolean(string description, bool nullable) | Returns a Schema representing a boolean value. |
Double(string description, bool nullable, double? minimum, double? maximum) | Returns a Schema for a double-precision floating-point number. |
Enum(IEnumerable< string > values, string description, bool nullable) | Returns a Schema for an enumeration. |
Float(string description, bool nullable, float? minimum, float? maximum) | Returns a Schema for a single-precision floating-point number. |
Int(string description, bool nullable, int? minimum, int? maximum) | Returns a Schema for a 32-bit signed integer number. |
Long(string description, bool nullable, long? minimum, long? maximum) | Returns a Schema for a 64-bit signed integer number. |
Object(IDictionary< string,Schema > properties, IEnumerable< string > optionalProperties, IEnumerable< string > propertyOrdering, string description, string title, bool nullable) | Returns a Schema representing an object. |
String(string description, bool nullable,StringFormat? format) | Returns a Schema for a string. |
Structs | |
|---|---|
| Firebase. | Modifiers describing the expected format of a string |
Public types
Properties
AnyOfSchemas
IReadOnlyList<Schema>AnyOfSchemas
An array ofSchema objects.
The generated data must be valid againstany (one or more) of the schemas listed in this array. This allows specifying multiple possible structures or types for a single field.
For example, a value could be either aString or anInt: ```Schema.AnyOf(new [] {Schema.String(),Schema.Int() }) ```
Description
stringDescription
A human-readable explanation of the purpose of the schema or property.
While not strictly enforced on the value itself, good descriptions significantly help the model understand the context and generate more relevant and accurate output.
EnumValues
IReadOnlyList<string>EnumValues
Possible values of the element of type "String" with "enum" format.
Format
stringFormat
The format of the data.
MaxItems
intMaxItems
An integer specifying the maximum number of items the generated "Array" must contain.
Maximum
doubleMaximum
The maximum value of a numeric type.
MinItems
intMinItems
An integer specifying the minimum number of items the generated "Array" must contain.
Minimum
doubleMinimum
The minimum value of a numeric type.
Nullable
boolNullable
Indicates if the value may be null.
PropertyOrdering
IReadOnlyList<string>PropertyOrdering
A specific hint provided to the Gemini model, suggesting the order in which the keys should appear in the generated JSON string.
Important: Standard JSON objects are inherently unordered collections of key-value pairs. While the model will try to respect PropertyOrdering in its textual JSON output, subsequent parsing into native C# objects (like Dictionaries) might not preserve this order. This parameter primarily affects the raw JSON string serialization.
RequiredProperties
IReadOnlyList<string>RequiredProperties
Required properties of type "Object".
Title
stringTitle
A human-readable name/summary for the schema or a specific property.
This helps document the schema's purpose but doesn't typically constrain the generated value. It can subtly guide the model by clarifying the intent of a field.
Public static functions
AnyOf
SchemaAnyOf(IEnumerable<Schema>schemas)
Returns aSchema representing a value that must conform toany (one or more) of the provided sub-schemas.
This schema instructs the model to produce data that is valid against at least one of the schemas listed in theschemas array. This is useful when a field can accept multiple distinct types or structures.
| Details | |||
|---|---|---|---|
| Parameters |
|
Array
SchemaArray(Schemaitems,stringdescription,boolnullable,int?minItems,int?maxItems)
Returns aSchema for an array.
| Details | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Parameters |
|
Boolean
SchemaBoolean(stringdescription,boolnullable)
Returns aSchema representing a boolean value.
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
|
Double
SchemaDouble(stringdescription,boolnullable,double?minimum,double?maximum)
Returns aSchema for a double-precision floating-point number.
| Details | |||||||||
|---|---|---|---|---|---|---|---|---|---|
| Parameters |
|
Enum
SchemaEnum(IEnumerable<string>values,stringdescription,boolnullable)
Returns aSchema for an enumeration.
For example, the cardinal directions can be represented as: ```Schema.Enum(new string[]{ "North", "East", "South", "West" }, "Cardinal directions") ```
| Details | |||||||
|---|---|---|---|---|---|---|---|
| Parameters |
|
Float
SchemaFloat(stringdescription,boolnullable,float?minimum,float?maximum)
Returns aSchema for a single-precision floating-point number.
Important: ThisSchema provides a hint to the model that it should generate a single-precision floating-point number, but only guarantees that the value will be a number. Therefore it'spossible that decoding it as afloat could overflow.
| Details | |||||||||
|---|---|---|---|---|---|---|---|---|---|
| Parameters |
|
Int
SchemaInt(stringdescription,boolnullable,int?minimum,int?maximum)
Returns aSchema for a 32-bit signed integer number.
Important: ThisSchema provides a hint to the model that it should generate a 32-bit integer, but only guarantees that the value will be an integer. Therefore it'spossible that decoding it as anint could overflow.
| Details | |||||||||
|---|---|---|---|---|---|---|---|---|---|
| Parameters |
|
Long
SchemaLong(stringdescription,boolnullable,long?minimum,long?maximum)
Returns aSchema for a 64-bit signed integer number.
| Details | |||||||||
|---|---|---|---|---|---|---|---|---|---|
| Parameters |
|
Object
SchemaObject(IDictionary<string,Schema>properties,IEnumerable<string>optionalProperties,IEnumerable<string>propertyOrdering,stringdescription,stringtitle,boolnullable)
Returns aSchema representing an object.
This schema instructs the model to produce data of type "Object", which has keys of type "String" and values of any other data type (including nested "Objects"s).
Example: ACity could be represented with the following objectSchema. ```Schema.Object(properties: new Dictionary() { { "name",Schema.String() }, { "population", Schema.Integer() } }) ```
| Details | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Parameters |
|
String
SchemaString(stringdescription,boolnullable,StringFormat?format)
Returns aSchema for a string.
| Details | |||||||
|---|---|---|---|---|---|---|---|
| Parameters |
|
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-07-24 UTC.