Table of Contents

Class GoogleSchemaHelper

Namespace
GenerativeAI.Types
Assembly
GenerativeAI.dll

Provides helper methods for converting JSON schemas to Google-compatible formats.

public static class GoogleSchemaHelper
Inheritance
GoogleSchemaHelper
Inherited Members

Methods

ConvertToCompatibleSchemaSubset(JsonDocument)

Converts a JSON document that contains valid json schema https://json-schema.org/specification as e.g. generated by

Microsoft.Extensions.AI.AIJsonUtilities.CreateJsonSchema

or

JsonSchema.Net

's JsonSchemaBuilder to a subset that is compatible with Google's APIs.

public static Schema? ConvertToCompatibleSchemaSubset(JsonDocument constructedSchema)

Parameters

constructedSchema JsonDocument

Generated, valid json schema.

Returns

Schema

Subset of the given json schema in a google-comaptible format.

ConvertToCompatibleSchemaSubset(JsonNode)

Converts a JSON document that contains valid json schema https://json-schema.org/specification as e.g. generated by

Microsoft.Extensions.AI.AIJsonUtilities.CreateJsonSchema

or

JsonSchema.Net

's JsonSchemaBuilder to a subset that is compatible with Google's APIs.

public static Schema ConvertToCompatibleSchemaSubset(JsonNode node)

Parameters

node JsonNode

Generated, valid json schema as a JsonNode.

Returns

Schema

Subset of the given json schema in a google-comaptible format.

ConvertToSchema(Type, JsonSerializerOptions?, Dictionary<string, string>?)

Converts a .NET type to a Google-compatible schema.

public static Schema ConvertToSchema(Type type, JsonSerializerOptions? jsonOptions = null, Dictionary<string, string>? descriptionTable = null)

Parameters

type Type

The type to convert to a schema.

jsonOptions JsonSerializerOptions

Optional JSON serializer options to use during conversion.

descriptionTable Dictionary<string, string>

Optional dictionary containing custom descriptions for properties.

Returns

Schema

A Google-compatible schema representing the specified type.

ConvertToSchema<T>(JsonSerializerOptions?)

Converts a .NET type to a Google-compatible schema.

public static Schema ConvertToSchema<T>(JsonSerializerOptions? jsonOptions = null)

Parameters

jsonOptions JsonSerializerOptions

Optional JSON serializer options to use during conversion.

Returns

Schema

A Google-compatible schema representing the specified type.

Type Parameters

T

The type to convert to a schema.