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:
export declare abstract class Schema implements SchemaInterface
Implements: SchemaInterface
Constructors
Constructor | Modifiers | Description |
---|---|---|
(constructor)(schemaParams) | Constructs a new instance of the Schema class |
Properties
Property | Modifiers | Type | Description |
---|---|---|---|
description | string | Optional. The description of the property. | |
example | unknown | Optional. The example of the property. | |
format | string | Optional. The format of the property. Supported formats:
|
|
nullable | boolean | Optional. Whether the property is nullable. Defaults to false. | |
type | SchemaType | Optional. The type of the property. SchemaType. |
Methods
Method | Modifiers | Description |
---|---|---|
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
Parameter | Type | Description |
---|---|---|
schemaParams | SchemaInterface |
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:
static array(arrayParams: SchemaParams & {
items: Schema;
}): ArraySchema;
Parameters
Parameter | Type | Description |
---|---|---|
arrayParams | SchemaParams & { items: Schema; } |
Returns:
Schema.boolean()
Signature:
static boolean(booleanParams?: SchemaParams): BooleanSchema;
Parameters
Parameter | Type | Description |
---|---|---|
booleanParams | SchemaParams |
Returns:
Schema.enumString()
Signature:
static enumString(stringParams: SchemaParams & {
enum: string[];
}): StringSchema;
Parameters
Parameter | Type | Description |
---|---|---|
stringParams | SchemaParams & { enum: string[]; } |
Returns:
Schema.integer()
Signature:
static integer(integerParams?: SchemaParams): IntegerSchema;
Parameters
Parameter | Type | Description |
---|---|---|
integerParams | SchemaParams |
Returns:
Schema.number()
Signature:
static number(numberParams?: SchemaParams): NumberSchema;
Parameters
Parameter | Type | Description |
---|---|---|
numberParams | SchemaParams |
Returns:
Schema.object()
Signature:
static object(objectParams: SchemaParams & {
properties: {
[k: string]: Schema;
};
optionalProperties?: string[];
}): ObjectSchema;
Parameters
Parameter | Type | Description |
---|---|---|
objectParams | SchemaParams & { properties: { [k: string]: Schema; }; optionalProperties?: string[]; } |
Returns:
Schema.string()
Signature:
static string(stringParams?: SchemaParams): StringSchema;
Parameters
Parameter | Type | Description |
---|---|---|
stringParams | SchemaParams |
Returns: