Table of Contents

Class JsonSchemaGenerator

Namespace
Excalibur.Dispatch.Transport.Kafka
Assembly
Excalibur.Dispatch.Transport.Kafka.dll

Generates JSON Schema from .NET types using System.Text.Json.

public static class JsonSchemaGenerator
Inheritance
JsonSchemaGenerator
Inherited Members

Remarks

This utility uses .NET 9's built-in JSON Schema generation via JsonSchemaExporterOptions and GetJsonSchemaAsNode.

The default options use camelCase property naming for JSON convention compatibility and no indentation for wire efficiency.

Custom schema annotations can be included by setting IncludeAnnotations to true.

Methods

Generate(Type)

Generates a JSON Schema string for the specified type.

public static string Generate(Type type)

Parameters

type Type

The type to generate a schema for.

Returns

string

The JSON Schema as a string.

Exceptions

ArgumentNullException

type is null.

Generate(Type, JsonSchemaOptions)

Generates a JSON Schema string for the specified type with custom options.

public static string Generate(Type type, JsonSchemaOptions options)

Parameters

type Type

The type to generate a schema for.

options JsonSchemaOptions

The schema generation options.

Returns

string

The JSON Schema as a string.

Exceptions

ArgumentNullException

type or options is null.

Generate(Type, JsonSerializerOptions)

Generates a JSON Schema string for the specified type using custom serializer options.

public static string Generate(Type type, JsonSerializerOptions options)

Parameters

type Type

The type to generate a schema for.

options JsonSerializerOptions

The JSON serializer options to use for schema generation.

Returns

string

The JSON Schema as a string.

Exceptions

ArgumentNullException

type or options is null.

Generate(Type, JsonSerializerOptions, JsonSchemaExporterOptions)

Generates a JSON Schema string for the specified type using custom serializer and exporter options.

public static string Generate(Type type, JsonSerializerOptions serializerOptions, JsonSchemaExporterOptions exporterOptions)

Parameters

type Type

The type to generate a schema for.

serializerOptions JsonSerializerOptions

The JSON serializer options to use.

exporterOptions JsonSchemaExporterOptions

The JSON Schema exporter options to use.

Returns

string

The JSON Schema as a string.

Exceptions

ArgumentNullException

Any argument is null.

Generate<T>()

Generates a JSON Schema string for the specified type.

public static string Generate<T>()

Returns

string

The JSON Schema as a string.

Type Parameters

T

The type to generate a schema for.

Generate<T>(JsonSchemaOptions)

Generates a JSON Schema string for the specified type with custom options.

public static string Generate<T>(JsonSchemaOptions options)

Parameters

options JsonSchemaOptions

The schema generation options.

Returns

string

The JSON Schema as a string.

Type Parameters

T

The type to generate a schema for.

Exceptions

ArgumentNullException

options is null.