AIJsonUtilities.CreateJsonSchema Method

Definition

Creates a JSON schema for the specified type.

C#
public static System.Text.Json.JsonElement CreateJsonSchema(Type? type, string? description = default, bool hasDefaultValue = false, object? defaultValue = default, System.Text.Json.JsonSerializerOptions? serializerOptions = default, Microsoft.Extensions.AI.AIJsonSchemaCreateOptions? inferenceOptions = default);

Parameters

type
Type

The type for which to generate the schema.

description
String

The description of the parameter.

hasDefaultValue
Boolean

true if the parameter is optional; otherwise, false.

defaultValue
Object

The default value of the optional parameter, if applicable.

serializerOptions
JsonSerializerOptions

The options used to extract the schema from the specified type.

inferenceOptions
AIJsonSchemaCreateOptions

The options controlling schema inference.

Returns

A JsonElement representing the schema.

Remarks

Uses a cache keyed on the serializerOptions to store schema result, unless a TransformSchemaNode delegate has been specified.

Applies to

Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)