Firebase. AI. Schema
A Schema
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 an OpenAPI 3.0 schema object.
Public types |
|
---|---|
SchemaType
|
enum The value type of a Schema . |
Properties |
|
---|---|
AnyOfSchemas
|
IEnumerable< Schema >
An array of
Schema objects. |
Description
|
string
A human-readable explanation of the purpose of the schema or property.
|
EnumValues
|
IEnumerable< string >
Possible values of the element of type "String" with "enum" format.
|
Format
|
string
The format of the data.
|
Items
|
Schema of the elements of type "Array".
|
MaxItems
|
int
An integer specifying the maximum number of items the generated "Array" must contain.
|
Maximum
|
double
The maximum value of a numeric type.
|
MinItems
|
int
An integer specifying the minimum number of items the generated "Array" must contain.
|
Minimum
|
double
The minimum value of a numeric type.
|
Nullable
|
bool
Indicates if the value may be null.
|
Properties
|
IReadOnlyDictionary< string, Schema >
Properties of type "Object".
|
PropertyOrdering
|
IEnumerable< string >
A specific hint provided to the Gemini model, suggesting the order in which the keys should appear in the generated JSON string.
|
RequiredProperties
|
IEnumerable< string >
Required properties of type "Object".
|
Title
|
string
A 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 to any (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
IEnumerable< Schema > AnyOfSchemas
An array of Schema
objects.
The generated data must be valid against any (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 a String
or an Int
: ``` Schema.AnyOf(new [] { Schema.String(), Schema.Int() }) ```
Description
string Description
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
IEnumerable< string > EnumValues
Possible values of the element of type "String" with "enum" format.
Format
string Format
The format of the data.
MaxItems
int MaxItems
An integer specifying the maximum number of items the generated "Array" must contain.
Maximum
double Maximum
The maximum value of a numeric type.
MinItems
int MinItems
An integer specifying the minimum number of items the generated "Array" must contain.
Minimum
double Minimum
The minimum value of a numeric type.
Nullable
bool Nullable
Indicates if the value may be null.
PropertyOrdering
IEnumerable< 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
IEnumerable< string > RequiredProperties
Required properties of type "Object".
Title
string Title
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
Schema AnyOf( IEnumerable< Schema > schemas )
Returns a Schema
representing a value that must conform to any (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 the schemas
array. This is useful when a field can accept multiple distinct types or structures.
Details | |||
---|---|---|---|
Parameters |
|
Array
Schema Array( Schema items, string description, bool nullable, int? minItems, int? maxItems )
Returns a Schema
for an array.
Details | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
Boolean
Schema Boolean( string description, bool nullable )
Returns a Schema
representing a boolean value.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
Double
Schema Double( string description, bool nullable, double? minimum, double? maximum )
Returns a Schema
for a double-precision floating-point number.
Details | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
Enum
Schema Enum( IEnumerable< string > values, string description, bool nullable )
Returns a Schema
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
Schema Float( string description, bool nullable, float? minimum, float? maximum )
Returns a Schema
for a single-precision floating-point number.
Important: This Schema
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's possible that decoding it as a float
could overflow.
Details | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
Int
Schema Int( string description, bool nullable, int? minimum, int? maximum )
Returns a Schema
for a 32-bit signed integer number.
Important: This Schema
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's possible that decoding it as an int
could overflow.
Details | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
Long
Schema Long( string description, bool nullable, long? minimum, long? maximum )
Returns a Schema
for a 64-bit signed integer number.
Details | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
Object
Schema Object( IDictionary< string, Schema > properties, IEnumerable< string > optionalProperties, IEnumerable< string > propertyOrdering, string description, string title, bool nullable )
Returns a Schema
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: A City
could be represented with the following object Schema
. ``` Schema.Object(properties: new Dictionary() { { "name", Schema.String() }, { "population", Schema.Integer() } }) ```
Details | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
String
Schema String( string description, bool nullable, StringFormat? format )
Returns a Schema
for a string.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|