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

JsonSchema4

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

Gets the NJsonSchema toolchain version.

public string ActualDiscriminator { get; }

Gets the discriminator property (Swagger only).

Gets the actual resolved discriminator of this schema (no inheritance, OpenApi only).

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 referenced schema.

public virtual JsonSchema4 ActualTypeSchema { get; }

Gets the type actual schema (e.g. the shared schema of a property, parameter, etc.).

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 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 virtual string Description { get; set; }

Gets or sets the description.

public JsonSchema4 DictionaryKey { get; set; }

Gets or sets the dictionary key schema (x-key, only enum schemas are allowed).

public string Discriminator { get; set; }

Gets or sets the discriminator property (Swagger only, should not be used in internal tooling).

Gets or sets the discriminator of this schema (OpenApi only).

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 object Example { get; set; }

Gets or sets the example (Swagger and Open API only).

public decimal? ExclusiveMaximum { get; set; }

Gets or sets the exclusive maximum value (v6).

public decimal? ExclusiveMinimum { get; set; }

Gets or sets the exclusive minimum value (v6).

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 HasAllOfSchemaReference { get; }

Gets a value indicating whether this is an allOf schema reference.

public bool HasOneOfSchemaReference { get; }

Gets a value indicating whether this is an oneOf schema reference.

public bool HasReference { get; }

Gets a value indicating whether this is a schema reference ($ref, HasAllOfSchemaReference or HasOneOfSchemaReference).

public bool HasSchemaReference { get; }

Gets a value indicating whether this is a schema reference ($ref, HasAllOfSchemaReference or HasOneOfSchemaReference).

public bool HasTypeNameTitle { get; }

Gets a value indicating whether the schema title can be used as type name.

public string Id { get; set; }

Gets or sets the id.

public JsonSchema4 InheritedSchema { get; }

Gets the inherited/parent schema (most probable base schema in allOf).

Gets the inherited/parent schema which may also be inlined (the schema itself if it is a dictionary or array, otherwise InheritedSchema).

public bool IsAbstract { get; set; }

Gets or sets a value indicating whether the type is abstract, i.e. cannot be instantiated directly (x-abstract).

public bool IsAnyType { get; }

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

public bool IsArray { get; }

Gets a value indicating whether the schema represents an array type (an array where each item has the same type).

public bool IsBinary { get; }

Gets a value indicating whether the schema is binary (file or binary format).

public bool IsDeprecated { get; set; }

Gets or sets a value indicating whether the schema is deprecated (Swagger and Open API only).

public bool IsDictionary { get; }

Gets a value indicating whether the schema represents a dictionary type (no properties and AdditionalProperties or PatternProperties contain 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 minimum value is excluded (v4).

public bool IsExclusiveMinimum { get; set; }

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

public bool IsFlagEnumerable { get; set; }

Gets or sets a value indicating this is an bit flag enum (custom extension, sets 'x-enumFlags', default: false).

public bool? IsNullableRaw { get; set; }

Gets or sets a value indicating whether the schema is nullable (Open API only).

public bool IsObject { get; }

Gets a value indicating whether the schema describes an object.

public bool IsTuple { get; }

Gets a value indicating whether the schema represents an tuple type (an array where each item may have a different type).

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 object Parent { get; set; }

Gets the parent schema of this schema.

public 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.

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

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.

Creates the serializer contract resolver based on the SchemaType.

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 JsonSchema4 FromSampleJson(string data)

Creates a JsonSchema4 from sample JSON data.

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).

public bool Inherits(JsonSchema4 schema)

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

public bool InheritsSchema(JsonSchema4 parentSchema)

Gets a value indicating whether this schema inherits from the given parent schema.

public virtual bool IsNullable(SchemaType schemaType)

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

public string ToJson()

Serializes the JsonSchema4 to a JSON string.

public string ToJson(Formatting formatting)

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.