This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /api/csharp/settings/vision/schema-generation-settings.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. SchemaGenerationSettings

Settings for SchemaGeneration. Values fall back through three levels: document → SDK → built-in default. Writes target the document only when set on a document’s settings, otherwise the SDK globally when set on SdkSettings.

using Nutrient;

The SDK creates this class through factory methods or other SDK objects.

Properties

AllowDiscriminatedUnions

public bool AllowDiscriminatedUnions { get; set; }

Enable discriminated unions: variant object types expressed as anyOf with a shared constant discriminator field per variant. oneOf is never used — it is rejected by OpenAI strict mode and silently ignored by Gemini. When false (default), the schema contains no union types beyond null unions.

Type: bool

AllowEnums

public bool AllowEnums { get; set; }

Enable enum constraints for fields with a small closed set of known values. Default is true.

Type: bool

AllowNullable

public bool AllowNullable { get; set; }

Enable nullable fields in the generated schema. Nullability is expressed as a type union with null (for example, "type": ["string", "null"]) — the only form accepted across the major structured-output modes. When false, every field is non-nullable. Default is true.

Type: bool

AllowPatterns

public bool AllowPatterns { get; set; }

Enable regex pattern constraints on string fields. Off by default: pattern support differs widely between structured-output modes (several reject common shorthand classes such as \d), so patterns are only generated when explicitly enabled.

Type: bool

AllowStringFormats

public bool AllowStringFormats { get; set; }

Enable string format annotations (for example, date-time or uuid), restricted to the formats the target dialect documents as supported. Default is true.

Type: bool

Compatibility

public SchemaCompatibility Compatibility { get; set; }

Target dialect preset applied on top of the individual knobs. The effective rule is always the stricter of the knob and the dialect limit; features the selected dialect documents as rejected are never emitted. Default is Portable — the intersection accepted by all major structured-output modes.

Type: SchemaCompatibility

IncludeConstraints

public bool IncludeConstraints { get; set; }

Also generate cross-field constraint rules encoding the logical relationships of the document type (for example, a subtotal equaling the sum of line item amounts), as standard JsonLogic expressions (jsonlogic.com). The result is always an envelope object with a schema property (the JSON Schema) and a constraints array; this knob only controls whether constraints are generated — when false (default), the array is empty. Rules referencing fields that don’t exist in the generated schema are dropped, so the constraints always validate against the schema they ship with.

Type: bool

MaxArrayItems

public int MaxArrayItems { get; set; }

When greater than zero, bounds the number of items of arrays in the generated schema. Emitted as a maxItems constraint when the target dialect supports it, and as description text otherwise (the portable and Anthropic dialects reject maxItems). Zero (default) leaves arrays unbounded.

Type: int

MaxFields

public int MaxFields { get; set; }

Maximum total number of properties across the whole generated schema, counting nested objects and union variants. Schemas exceeding the bound are truncated, keeping the most relevant fields first. Values above 200 are clamped to 200. Default is 50.

Type: int

MaxNestingDepth

public int MaxNestingDepth { get; set; }

Maximum object nesting depth of the generated schema. Structures deeper than the bound are flattened. The root object is depth one. Dialect presets may cap this further (OpenAI strict mode and the portable intersection allow at most five levels). Default is three.

Type: int

MaxRetries

public int MaxRetries { get; set; }

How many times to retry the vision model when its output is invalid — unparseable JSON or a draft that fails meta-schema validation. Each retry feeds the specific validation errors back to the model. Zero disables retries; there is no upper bound (each retry is a full model call, so the cost is yours to choose). Default is one.

Type: int

Resource management

public void Dispose()

SchemaGenerationSettings implements IDisposable. Call Dispose() or use a C# using declaration to release its native handle right away. If you don’t, the handle is released when the object is garbage collected.