Table of Contents

Class JsonSchemaContext

Namespace
Nerdbank.Json
Assembly
Nerdbank.Json.dll

Drives generation of a JSON Schema document, resolving nested schemas, shared definitions, and recursive types. Provided to GetJsonSchema(JsonSchemaContext, ITypeShape) so custom converters can describe nested types consistently.

public sealed class JsonSchemaContext : ITypeShapeFunc
Inheritance
JsonSchemaContext
Implements
Inherited Members

Properties

Dialect

Gets the dialect that converter-generated schema fragments must conform to.

public JsonSchemaDialect Dialect { get; }

Property Value

JsonSchemaDialect

Methods

ApplyTupleSchema(JsonObject, JsonArray)

Adds positional constraints to a schema in the selected dialect.

public void ApplyTupleSchema(JsonObject schema, JsonArray items)

Parameters

schema JsonObject

The schema to modify.

items JsonArray

The positional schemas. Ownership transfers to the schema.

CreateTupleSchema(JsonArray)

Creates a schema for a positional array in the selected dialect.

public JsonObject CreateTupleSchema(JsonArray items)

Parameters

items JsonArray

The positional schemas. Ownership transfers to the result.

Returns

JsonObject

The array schema, without length constraints.

GetJsonSchema(ITypeShape)

Gets the schema for a type shape, resolving shared definitions and recursion.

public JsonObject GetJsonSchema(ITypeShape typeShape)

Parameters

typeShape ITypeShape

The shape of the type.

Returns

JsonObject

The schema, which may be a $ref to a shared definition.