Back to Firebase Js Sdk

Schema class

docs-devsite/ai.schema.md

12.12.18.2 KB
Original Source

Project: /docs/reference/js/_project.yaml Book: /docs/reference/_book.yaml page_type: reference

{% comment %} DO NOT EDIT THIS FILE! This is generated by the JS SDK team, and any local changes will be overwritten. Changes should be made in the source code at https://github.com/firebase/firebase-js-sdk {% endcomment %}

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.)

<b>Signature:</b>

typescript
export declare abstract class Schema implements SchemaInterface 

<b>Implements:</b> SchemaInterface

Constructors

ConstructorModifiersDescription
(constructor)(schemaParams)Constructs a new instance of the <code>Schema</code> class

Properties

PropertyModifiersTypeDescription
descriptionstringOptional. The description of the property.
exampleunknownOptional. The example of the property.
formatstringOptional. The format of the property. Supported formats:
<ul> <li>for NUMBER type: "float", "double"</li> <li>for INTEGER type: "int32", "int64"</li> <li>for STRING type: "email", "byte", etc</li> </ul> | | [items](./ai.schema.md#schemaitems) | | [SchemaInterface](./ai.schemainterface.md#schemainterface_interface) | Optional. The items of the property. | | [maxItems](./ai.schema.md#schemamaxitems) | | number | The maximum number of items (elements) in a schema of [SchemaType](./ai.md#schematype) <code>array</code>. | | [minItems](./ai.schema.md#schemaminitems) | | number | The minimum number of items (elements) in a schema of [SchemaType](./ai.md#schematype) <code>array</code>. | | [nullable](./ai.schema.md#schemanullable) | | boolean | Optional. Whether the property is nullable. Defaults to false. | | [type](./ai.schema.md#schematype) | | [SchemaType](./ai.md#schematype) | Optional. The type of the property. This can only be undefined when using <code>anyOf</code> schemas, which do not have an explicit type in the [OpenAPI specification](https://swagger.io/docs/specification/v3_0/data-models/data-types/#any-type)<!-- -->. |

Methods

MethodModifiersDescription
anyOf(anyOfParams)<code>static</code>
array(arrayParams)<code>static</code>
boolean(booleanParams)<code>static</code>
enumString(stringParams)<code>static</code>
integer(integerParams)<code>static</code>
number(numberParams)<code>static</code>
object(objectParams)<code>static</code>
string(stringParams)<code>static</code>

Schema.(constructor)

Constructs a new instance of the Schema class

<b>Signature:</b>

typescript
constructor(schemaParams: SchemaInterface);

Parameters

ParameterTypeDescription
schemaParamsSchemaInterface

Schema.description

Optional. The description of the property.

<b>Signature:</b>

typescript
description?: string;

Schema.example

Optional. The example of the property.

<b>Signature:</b>

typescript
example?: unknown;

Schema.format

Optional. The format of the property. Supported formats:

<ul> <li>for NUMBER type: "float", "double"</li> <li>for INTEGER type: "int32", "int64"</li> <li>for STRING type: "email", "byte", etc</li> </ul>

<b>Signature:</b>

typescript
format?: string;

Schema.items

Optional. The items of the property.

<b>Signature:</b>

typescript
items?: SchemaInterface;

Schema.maxItems

The maximum number of items (elements) in a schema of SchemaType array<!-- -->.

<b>Signature:</b>

typescript
maxItems?: number;

Schema.minItems

The minimum number of items (elements) in a schema of SchemaType array<!-- -->.

<b>Signature:</b>

typescript
minItems?: number;

Schema.nullable

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

<b>Signature:</b>

typescript
nullable: boolean;

Schema.type

Optional. The type of the property. This can only be undefined when using anyOf schemas, which do not have an explicit type in the OpenAPI specification<!-- -->.

<b>Signature:</b>

typescript
type?: SchemaType;

Schema.anyOf()

<b>Signature:</b>

typescript
static anyOf(anyOfParams: SchemaParams & {
        anyOf: TypedSchema[];
    }): AnyOfSchema;

Parameters

ParameterTypeDescription
anyOfParamsSchemaParams & { anyOf: TypedSchema<!-- -->[]; }

<b>Returns:</b>

AnyOfSchema

Schema.array()

<b>Signature:</b>

typescript
static array(arrayParams: SchemaParams & {
        items: Schema;
    }): ArraySchema;

Parameters

ParameterTypeDescription
arrayParamsSchemaParams & { items: Schema<!-- -->; }

<b>Returns:</b>

ArraySchema

Schema.boolean()

<b>Signature:</b>

typescript
static boolean(booleanParams?: SchemaParams): BooleanSchema;

Parameters

ParameterTypeDescription
booleanParamsSchemaParams

<b>Returns:</b>

BooleanSchema

Schema.enumString()

<b>Signature:</b>

typescript
static enumString(stringParams: SchemaParams & {
        enum: string[];
    }): StringSchema;

Parameters

ParameterTypeDescription
stringParamsSchemaParams & { enum: string[]; }

<b>Returns:</b>

StringSchema

Schema.integer()

<b>Signature:</b>

typescript
static integer(integerParams?: SchemaParams): IntegerSchema;

Parameters

ParameterTypeDescription
integerParamsSchemaParams

<b>Returns:</b>

IntegerSchema

Schema.number()

<b>Signature:</b>

typescript
static number(numberParams?: SchemaParams): NumberSchema;

Parameters

ParameterTypeDescription
numberParamsSchemaParams

<b>Returns:</b>

NumberSchema

Schema.object()

<b>Signature:</b>

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

Parameters

ParameterTypeDescription
objectParamsSchemaParams & { properties: { [k: string]: Schema<!-- -->; }; optionalProperties?: string[]; }

<b>Returns:</b>

ObjectSchema

Schema.string()

<b>Signature:</b>

typescript
static string(stringParams?: SchemaParams): StringSchema;

Parameters

ParameterTypeDescription
stringParamsSchemaParams

<b>Returns:</b>

StringSchema