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
Methods
ApplyTupleSchema(JsonObject, JsonArray)
Adds positional constraints to a schema in the selected dialect.
public void ApplyTupleSchema(JsonObject schema, JsonArray items)
Parameters
schemaJsonObjectThe schema to modify.
itemsJsonArrayThe 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
itemsJsonArrayThe 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
typeShapeITypeShapeThe shape of the type.
Returns
- JsonObject
The schema, which may be a
$refto a shared definition.