Skip to content

Commit 427a302

Browse files
russellwheatleymikehardy
authored andcommitted
types/schema.ts
1 parent 6efd13a commit 427a302

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

packages/ai/lib/types/schema.ts

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* See the License for the specific language governing permissions and
1515
* limitations under the License.
1616
*/
17+
1718
/**
1819
* Contains the list of OpenAPI data types
1920
* as defined by the
@@ -36,40 +37,59 @@ export enum SchemaType {
3637
}
3738

3839
/**
39-
* Basic <code>{@link Schema}</code> properties shared across several Schema-related
40+
* Basic {@link Schema} properties shared across several Schema-related
4041
* types.
4142
* @public
4243
*/
4344
export interface SchemaShared<T> {
44-
/** Optional. The format of the property. */
45+
/** Optional. The format of the property.
46+
* When using the Gemini Developer API ({@link GoogleAIBackend}), this must be either `'enum'` or
47+
* `'date-time'`, otherwise requests will fail.
48+
*/
4549
format?: string;
4650
/** Optional. The description of the property. */
4751
description?: string;
52+
/**
53+
* The title of the property. This helps document the schema's purpose but does not typically
54+
* constrain the generated value. It can subtly guide the model by clarifying the intent of a
55+
* field.
56+
*/
57+
title?: string;
4858
/** Optional. The items of the property. */
4959
items?: T;
60+
/** The minimum number of items (elements) in a schema of type {@link SchemaType.ARRAY}. */
61+
minItems?: number;
62+
/** The maximum number of items (elements) in a schema of type {@link SchemaType.ARRAY}. */
63+
maxItems?: number;
5064
/** Optional. Map of `Schema` objects. */
5165
properties?: {
5266
[k: string]: T;
5367
};
68+
/** A hint suggesting the order in which the keys should appear in the generated JSON string. */
69+
propertyOrdering?: string[];
5470
/** Optional. The enum of the property. */
5571
enum?: string[];
5672
/** Optional. The example of the property. */
5773
example?: unknown;
5874
/** Optional. Whether the property is nullable. */
5975
nullable?: boolean;
76+
/** The minimum value of a numeric type. */
77+
minimum?: number;
78+
/** The maximum value of a numeric type. */
79+
maximum?: number;
6080
[key: string]: unknown;
6181
}
6282

6383
/**
64-
* Params passed to <code>{@link Schema}</code> static methods to create specific
65-
* <code>{@link Schema}</code> classes.
84+
* Params passed to {@link Schema} static methods to create specific
85+
* {@link Schema} classes.
6686
* @public
6787
*/
6888
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
6989
export interface SchemaParams extends SchemaShared<SchemaInterface> {}
7090

7191
/**
72-
* Final format for <code>{@link Schema}</code> params passed to backend requests.
92+
* Final format for {@link Schema} params passed to backend requests.
7393
* @public
7494
*/
7595
export interface SchemaRequest extends SchemaShared<SchemaRequest> {
@@ -83,7 +103,7 @@ export interface SchemaRequest extends SchemaShared<SchemaRequest> {
83103
}
84104

85105
/**
86-
* Interface for <code>{@link Schema}</code> class.
106+
* Interface for {@link Schema} class.
87107
* @public
88108
*/
89109
export interface SchemaInterface extends SchemaShared<SchemaInterface> {
@@ -95,7 +115,7 @@ export interface SchemaInterface extends SchemaShared<SchemaInterface> {
95115
}
96116

97117
/**
98-
* Interface for <code>{@link ObjectSchema}</code> class.
118+
* Interface for {@link ObjectSchema} class.
99119
* @public
100120
*/
101121
export interface ObjectSchemaInterface extends SchemaInterface {

0 commit comments

Comments
 (0)