Skip to content

Commit

Permalink
Use lowercase SchemaType enum values (#229)
Browse files Browse the repository at this point in the history
This fixes the serialized values of the `SchemaType` enum to follow [the referenced doc](https://swagger.io/docs/specification/data-models/data-types/) and [the json-schema spec](https://json-schema.org/draft/2020-12/json-schema-core#section-4.2.1) on which the reference is based.

This change makes the JS gemini SDK compatible with the myriad tools like [AJV](https://ajv.js.org/guide/typescript.html) that allow the definition of validators, types, etc using standard json-schema.

In practice the lowercased values appear to work perfectly, but show TypeScript errors.
  • Loading branch information
mike-marcacci authored Sep 11, 2024
1 parent 7d01195 commit 00dc7a1
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 30 deletions.
5 changes: 5 additions & 0 deletions .changeset/warm-mails-grab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@google/generative-ai": minor
---

Use lowercase SchemaType enum values to match json-schema.
12 changes: 6 additions & 6 deletions common/api-review/generative-ai-server.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -440,12 +440,12 @@ export interface Schema {

// @public
export enum SchemaType {
ARRAY = "ARRAY",
BOOLEAN = "BOOLEAN",
INTEGER = "INTEGER",
NUMBER = "NUMBER",
OBJECT = "OBJECT",
STRING = "STRING"
ARRAY = "array",
BOOLEAN = "boolean",
INTEGER = "integer",
NUMBER = "number",
OBJECT = "object",
STRING = "string"
}

// @public
Expand Down
12 changes: 6 additions & 6 deletions common/api-review/generative-ai.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -655,12 +655,12 @@ export interface Schema {

// @public
export enum SchemaType {
ARRAY = "ARRAY",
BOOLEAN = "BOOLEAN",
INTEGER = "INTEGER",
NUMBER = "NUMBER",
OBJECT = "OBJECT",
STRING = "STRING"
ARRAY = "array",
BOOLEAN = "boolean",
INTEGER = "integer",
NUMBER = "number",
OBJECT = "object",
STRING = "string"
}

// @public
Expand Down
12 changes: 6 additions & 6 deletions docs/reference/main/generative-ai.schematype.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ export declare enum SchemaType

| Member | Value | Description |
| --- | --- | --- |
| ARRAY | <code>&quot;ARRAY&quot;</code> | Array type. |
| BOOLEAN | <code>&quot;BOOLEAN&quot;</code> | Boolean type. |
| INTEGER | <code>&quot;INTEGER&quot;</code> | Integer type. |
| NUMBER | <code>&quot;NUMBER&quot;</code> | Number type. |
| OBJECT | <code>&quot;OBJECT&quot;</code> | Object type. |
| STRING | <code>&quot;STRING&quot;</code> | String type. |
| ARRAY | <code>&quot;array&quot;</code> | Array type. |
| BOOLEAN | <code>&quot;boolean&quot;</code> | Boolean type. |
| INTEGER | <code>&quot;integer&quot;</code> | Integer type. |
| NUMBER | <code>&quot;number&quot;</code> | Number type. |
| OBJECT | <code>&quot;object&quot;</code> | Object type. |
| STRING | <code>&quot;string&quot;</code> | String type. |

12 changes: 6 additions & 6 deletions docs/reference/server/generative-ai.schematype.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ export declare enum SchemaType

| Member | Value | Description |
| --- | --- | --- |
| ARRAY | <code>&quot;ARRAY&quot;</code> | Array type. |
| BOOLEAN | <code>&quot;BOOLEAN&quot;</code> | Boolean type. |
| INTEGER | <code>&quot;INTEGER&quot;</code> | Integer type. |
| NUMBER | <code>&quot;NUMBER&quot;</code> | Number type. |
| OBJECT | <code>&quot;OBJECT&quot;</code> | Object type. |
| STRING | <code>&quot;STRING&quot;</code> | String type. |
| ARRAY | <code>&quot;array&quot;</code> | Array type. |
| BOOLEAN | <code>&quot;boolean&quot;</code> | Boolean type. |
| INTEGER | <code>&quot;integer&quot;</code> | Integer type. |
| NUMBER | <code>&quot;number&quot;</code> | Number type. |
| OBJECT | <code>&quot;object&quot;</code> | Object type. |
| STRING | <code>&quot;string&quot;</code> | String type. |

12 changes: 6 additions & 6 deletions types/function-calling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,17 @@ export declare interface FunctionDeclarationsTool {
*/
export enum SchemaType {
/** String type. */
STRING = "STRING",
STRING = "string",
/** Number type. */
NUMBER = "NUMBER",
NUMBER = "number",
/** Integer type. */
INTEGER = "INTEGER",
INTEGER = "integer",
/** Boolean type. */
BOOLEAN = "BOOLEAN",
BOOLEAN = "boolean",
/** Array type. */
ARRAY = "ARRAY",
ARRAY = "array",
/** Object type. */
OBJECT = "OBJECT",
OBJECT = "object",
}

/**
Expand Down

0 comments on commit 00dc7a1

Please sign in to comment.