JsonSchemaExporter.GetJsonSchemaAsNode Method

Definition

Overloads

GetJsonSchemaAsNode(JsonTypeInfo, JsonSchemaExporterOptions)

Generates a JSON schema corresponding to the specified contract metadata.

GetJsonSchemaAsNode(JsonSerializerOptions, Type, JsonSchemaExporterOptions)

Generates a JSON schema corresponding to the contract metadata of the specified type.

GetJsonSchemaAsNode(JsonTypeInfo, JsonSchemaExporterOptions)

Source:
JsonSchemaExporter.cs

Generates a JSON schema corresponding to the specified contract metadata.

public static System.Text.Json.Nodes.JsonNode GetJsonSchemaAsNode (this System.Text.Json.Serialization.Metadata.JsonTypeInfo typeInfo, System.Text.Json.Schema.JsonSchemaExporterOptions? exporterOptions = default);

Parameters

typeInfo
JsonTypeInfo

The contract metadata for which to generate the schema.

exporterOptions
JsonSchemaExporterOptions

The exporterOptions object controlling the schema generation.

Returns

A new JsonNode instance defining the JSON schema for typeInfo.

Exceptions

One of the specified parameters is null.

The typeInfo parameter contains unsupported exporterOptions.

Applies to

.NET 9 and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 9
.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)

GetJsonSchemaAsNode(JsonSerializerOptions, Type, JsonSchemaExporterOptions)

Source:
JsonSchemaExporter.cs

Generates a JSON schema corresponding to the contract metadata of the specified type.

public static System.Text.Json.Nodes.JsonNode GetJsonSchemaAsNode (this System.Text.Json.JsonSerializerOptions options, Type type, System.Text.Json.Schema.JsonSchemaExporterOptions? exporterOptions = default);

Parameters

options
JsonSerializerOptions

The options instance from which to resolve the contract metadata.

type
Type

The root type for which to generate the JSON schema.

exporterOptions
JsonSchemaExporterOptions

The exporterOptions object controlling the schema generation.

Returns

A new JsonNode instance defining the JSON schema for type.

Exceptions

One of the specified parameters is null.

The options parameter contains unsupported exporterOptions.

Applies to

.NET 9 and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 9
.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)