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
Methods
ApplyTupleSchema(JsonObject, JsonArray)
Adds positional array constraints to an existing schema using the selected dialect.
public void ApplyTupleSchema(JsonObject schema, JsonArray items)
Parameters
schemaJsonObjectThe schema to modify.
itemsJsonArrayThe 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
itemsis empty.
CreateTupleSchema(JsonArray)
Creates an array schema with positional constraints using the selected dialect.
public JsonObject CreateTupleSchema(JsonArray items)
Parameters
itemsJsonArrayThe 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
itemsis empty.
GetJsonSchema(ITypeShape)
Obtains the JSON schema for a given type shape.
public JsonObject GetJsonSchema(ITypeShape typeShape)
Parameters
typeShapeITypeShapeThe shape for the type.
Returns
- JsonObject
The JSON schema.