Table of Contents

Class JsonSchemaContext

Namespace
Nerdbank.MessagePack
Assembly
Nerdbank.MessagePack.dll

The context provided to GetJsonSchema(JsonSchemaContext, ITypeShape) to aid in the generation of JSON schemas for types.

public class JsonSchemaContext
Inheritance
JsonSchemaContext
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 array constraints to an existing schema using the selected dialect.

public void ApplyTupleSchema(JsonObject schema, JsonArray items)

Parameters

schema JsonObject

The schema to modify.

items JsonArray

The schema for each successive array position. Ownership is transferred to schema.

Remarks

This does not change the schema's type or array length constraints.

Exceptions

ArgumentException

items is empty.

CreateTupleSchema(JsonArray)

Creates an array schema with positional constraints using the selected dialect.

public JsonObject CreateTupleSchema(JsonArray items)

Parameters

items JsonArray

The schema for each successive array position. Ownership is transferred to the returned schema.

Returns

JsonObject

A schema allowing arrays of any length, with the specified positional constraints.

Remarks

Set minItems and maxItems on the result to constrain array length.

Exceptions

ArgumentException

items is empty.

GetJsonSchema(ITypeShape)

Obtains the JSON schema for a given type shape.

public JsonObject GetJsonSchema(ITypeShape typeShape)

Parameters

typeShape ITypeShape

The shape for the type.

Returns

JsonObject

The JSON schema.