Schema class

Parent class encompassing all Schema types, with static methods that allow building specific Schema types. This class can be converted with JSON.stringify() into a JSON string accepted by Vertex AI REST endpoints. (This string conversion is automatically done when calling SDK methods.)

Signature:

exportdeclareabstractclassSchemaimplementsSchemaInterface

Implements:SchemaInterface

Constructors

ConstructorModifiersDescription
(constructor)(schemaParams)Constructs a new instance of the Schema class

Properties

PropertyModifiersTypeDescription
descriptionstringOptional. The description of the property.
exampleunknownOptional. The example of the property.
formatstringOptional. The format of the property. Supported formats:
  • for NUMBER type: "float", "double"
  • for INTEGER type: "int32", "int64"
  • for STRING type: "email", "byte", etc
nullablebooleanOptional. Whether the property is nullable. Defaults to false.
typeSchemaTypeOptional. The type of the property. SchemaType.

Methods

MethodModifiersDescription
array(arrayParams)static
boolean(booleanParams)static
enumString(stringParams)static
integer(integerParams)static
number(numberParams)static
object(objectParams)static
string(stringParams)static

Schema.(constructor)

Constructs a new instance of the Schema class

Signature:

constructor(schemaParams:SchemaInterface);

Parameters

ParameterTypeDescription
schemaParamsSchemaInterface

Schema.description

Optional. The description of the property.

Signature:

description?:string;

Schema.example

Optional. The example of the property.

Signature:

example?:unknown;

Schema.format

Optional. The format of the property. Supported formats:

  • for NUMBER type: "float", "double"
  • for INTEGER type: "int32", "int64"
  • for STRING type: "email", "byte", etc

Signature:

format?:string;

Schema.nullable

Optional. Whether the property is nullable. Defaults to false.

Signature:

nullable:boolean;

Schema.type

Optional. The type of the property. SchemaType.

Signature:

type:SchemaType;

Schema.array()

Signature:

staticarray(arrayParams:SchemaParams & {items:Schema;}):ArraySchema;

Parameters

ParameterTypeDescription
arrayParamsSchemaParams & { items: Schema; }

Returns:

ArraySchema

Schema.boolean()

Signature:

staticboolean(booleanParams?:SchemaParams):BooleanSchema;

Parameters

ParameterTypeDescription
booleanParamsSchemaParams

Returns:

BooleanSchema

Schema.enumString()

Signature:

staticenumString(stringParams:SchemaParams & {enum:string[];}):StringSchema;

Parameters

ParameterTypeDescription
stringParamsSchemaParams & { enum: string[]; }

Returns:

StringSchema

Schema.integer()

Signature:

staticinteger(integerParams?:SchemaParams):IntegerSchema;

Parameters

ParameterTypeDescription
integerParamsSchemaParams

Returns:

IntegerSchema

Schema.number()

Signature:

staticnumber(numberParams?:SchemaParams):NumberSchema;

Parameters

ParameterTypeDescription
numberParamsSchemaParams

Returns:

NumberSchema

Schema.object()

Signature:

staticobject(objectParams:SchemaParams & {properties:{[k:string]:Schema;};optionalProperties?:string[];}):ObjectSchema;

Parameters

ParameterTypeDescription
objectParamsSchemaParams & { properties: { [k: string]: Schema; }; optionalProperties?: string[]; }

Returns:

ObjectSchema

Schema.string()

Signature:

staticstring(stringParams?:SchemaParams):StringSchema;

Parameters

ParameterTypeDescription
stringParamsSchemaParams

Returns:

StringSchema