<PackageReference Include="NJsonSchema" Version="8.1.6249.15627" />

JsonSchema4

A base class for describing a JSON schema.
public static string ToolchainVersion { get; }

Gets the NJsonSchema toolchain version.

Gets all properties of this schema (i.e. all direct properties and properties from the schemas in allOf which do not have a type).

public virtual JsonSchema4 ActualSchema { get; }

Gets the actual schema, either this or the reference schema.

public JsonSchema4 AdditionalItemsSchema { get; set; }

Gets or sets the schema for the additional items.

Gets or sets the schema for the additional properties.

Gets the list of all inherited/parent schemas.

public ICollection<JsonSchema4> AllOf { get; }

Gets the collection of schemas where each schema must be valid.

public bool AllowAdditionalItems { get; set; }

Gets or sets a value indicating whether additional items are allowed (default: true).

public bool AllowAdditionalProperties { get; set; }

Gets or sets a value indicating whether additional properties are allowed (default: true).

public ICollection<JsonSchema4> AnyOf { get; }

Gets the collection of schemas where at least one must be valid.

public string BaseDiscriminator { get; }

Gets the discriminator or discriminator of an inherited schema (or null).

public object Default { get; set; }

Gets or sets the default value.

public IDictionary<string, JsonSchema4> Definitions { get; }

Gets the other schema definitions of this schema.

public string Description { get; set; }

Gets or sets the description.

public string Discriminator { get; set; }

Gets or sets the discriminator (used in Swagger schemas).

public string DocumentPath { get; set; }

Gets the document path (URI or file path) for resolving relative references.

public ICollection<object> Enumeration { get; }

Gets the collection of required properties.

public Collection<string> EnumerationNames { get; set; }

Gets or sets the enumeration names (optional, draft v5).

public Collection<string> EnumerationNamesRaw { get; set; }

Gets or sets the enumeration names (optional, draft v5).

public IDictionary<string, object> ExtensionData { get; set; }

Gets or sets the extension data (i.e. additional properties which are not directly defined by JSON Schema).

public string Format { get; set; }

Gets or sets the format string.

public bool HasSchemaReference { get; }

Gets a value indicating whether this is a type reference.

public string Id { get; set; }

Gets or sets the id.

Gets the list of directly inherited/parent schemas (i.e. all schemas in allOf with a type of 'Object').

public bool IsAnyType { get; }

Gets a value indicating whether this is any type (e.g. any in TypeScript or object in CSharp).

public bool IsDictionary { get; }

Gets a value indicating whether the schema represents a dictionary type (no properties and AdditionalProperties contains a schema).

public bool IsEnumeration { get; }

Gets a value indicating whether this is enumeration.

public bool IsExclusiveMaximum { get; set; }

Gets or sets a value indicating whether the maximum value is excluded.

public bool IsExclusiveMinimum { get; set; }

Gets or sets a value indicating whether the minimum value is excluded.

public JsonSchema4 Item { get; set; }

Gets or sets the schema of an array item.

public ICollection<JsonSchema4> Items { get; }

Gets or sets the schemas of the array's tuple values.

public decimal? Maximum { get; set; }

Gets or sets the maximum allowed value.

public int MaxItems { get; set; }

Gets or sets the maximum length of the array.

public int? MaxLength { get; set; }

Gets or sets the maximum length of the value string.

public int MaxProperties { get; set; }

Gets or sets the maximal number of allowed properties in an object.

public decimal? Minimum { get; set; }

Gets or sets the minimum allowed value.

public int MinItems { get; set; }

Gets or sets the minimum length of the array.

public int? MinLength { get; set; }

Gets or sets the minimum length of the value string.

public int MinProperties { get; set; }

Gets or sets the minimal number of allowed properties in an object.

public decimal? MultipleOf { get; set; }

Gets or sets the required multiple of for the number value.

public JsonSchema4 Not { get; set; }

Gets or sets the schema which must not be valid.

public ICollection<JsonSchema4> OneOf { get; }

Gets the collection of schemas where exactly one must be valid.

public virtual JsonSchema4 ParentSchema { get; }

Gets the parent schema of this schema.

public string Pattern { get; set; }

Gets or sets the validation pattern as regular expression.

public IDictionary<string, JsonSchema4> PatternProperties { get; }

Gets the pattern properties of the type.

public IDictionary<string, JsonProperty> Properties { get; }

Gets the properties of the type.

public ICollection<string> RequiredProperties { get; }

Gets the collection of required properties.

public JsonSchema4 SchemaReference { get; set; }

Gets or sets the type reference.

public string SchemaVersion { get; set; }

Gets or sets the schema.

public string Title { get; set; }

Gets or sets the title.

public JsonObjectType Type { get; set; }

Gets the object types (as enum flags).

public bool UniqueItems { get; set; }

Gets or sets a value indicating whether the items in the array must be unique.

public JsonXmlObject Xml { get; set; }

Gets the xml object of the schema (used in Swagger specifications).

public JsonSchema4()

Initializes a new instance of the JsonSchema4 class.

public static JsonSchema4 CreateAnySchema()

Creates a schema which matches any data.

public static TSchemaType CreateAnySchema<TSchemaType>() where TSchemaType : JsonSchema4

Creates a schema which matches any data.

public static JsonSchema4 FromData(string data)

Creates a JsonSchema4 from sample JSON data.

public static Task<JsonSchema4> FromFileAsync(string filePath)

Loads a JSON Schema from a given file path (only available in .NET 4.x).

public static Task<JsonSchema4> FromFileAsync(string filePath, Func<JsonSchema4, JsonReferenceResolver> referenceResolverFactory)

Loads a JSON Schema from a given file path (only available in .NET 4.x).

public static Task<JsonSchema4> FromJsonAsync(string data)

Deserializes a JSON string to a JsonSchema4.

public static Task<JsonSchema4> FromJsonAsync(string data, string documentPath)

Deserializes a JSON string to a JsonSchema4.

public static Task<JsonSchema4> FromJsonAsync(string data, string documentPath, Func<JsonSchema4, JsonReferenceResolver> referenceResolverFactory)

Deserializes a JSON string to a JsonSchema4.

public static Task<JsonSchema4> FromTypeAsync<TType>()

Creates a JsonSchema4 from a given type.

public static Task<JsonSchema4> FromTypeAsync(Type type)

Creates a JsonSchema4 from a given type.

Creates a JsonSchema4 from a given type.

Creates a JsonSchema4 from a given type.

public static Task<JsonSchema4> FromUrlAsync(string url)

Loads a JSON Schema from a given URL (only available in .NET 4.x).

public static Task<JsonSchema4> FromUrlAsync(string url, Func<JsonSchema4, JsonReferenceResolver> referenceResolverFactory)

Loads a JSON Schema from a given URL (only available in .NET 4.x).

Finds the root parent of this schema.

public bool Inherits(JsonSchema4 schema)

Determines whether the given schema is the parent schema of this schema (i.e. super/base class).

public virtual bool IsNullable(NullHandling nullHandling)

Gets a value indicating whether the validated data can be null.

public string ToJson()

Serializes the JsonSchema4 to a JSON string.

public string ToJson(JsonSchemaGeneratorSettings settings)

Serializes the JsonSchema4 to a JSON string.

public ICollection<ValidationError> Validate(string jsonData)

Validates the given JSON data against this schema.

Validates the given JSON token against this schema.