Class Schema
Class Schema represents a JSON Type Definition schema.
Inheritance
Namespace: Jtd.Jtd
Assembly: Jtd.Jtd.dll
Syntax
public class Schema : object
Remarks
This class is designed to be usable as a serializable (and deserializable) class for use with Newtonsoft.Json.JsonConvert or System.Text.Json.JsonSerializer.
The correctness of a JSON Type Definition schema cannot be expressed
entirely within CSharp's type system. To that end, consider using Verify() to ensure that a Schema represents a correct
JSON Type Definition schema.
Properties
| Improve this Doc View SourceAdditionalProperties
Declaration
public bool? AdditionalProperties { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Nullable<System.Boolean> | Corresponds to the |
Definitions
Declaration
public IDictionary<string, Schema> Definitions { get; set; }
Property Value
| Type | Description |
|---|---|
| IDictionary<System.String, Schema> | Corresponds to the |
Discriminator
Declaration
public string Discriminator { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String | Corresponds to the |
Elements
Declaration
public Schema Elements { get; set; }
Property Value
| Type | Description |
|---|---|
| Schema | Corresponds to the |
Enum
Declaration
public ISet<string> Enum { get; set; }
Property Value
| Type | Description |
|---|---|
| ISet<System.String> | Corresponds to the |
Mapping
Declaration
public IDictionary<string, Schema> Mapping { get; set; }
Property Value
| Type | Description |
|---|---|
| IDictionary<System.String, Schema> | Corresponds to the |
Metadata
Declaration
public IDictionary<string, object> Metadata { get; set; }
Property Value
| Type | Description |
|---|---|
| IDictionary<System.String, System.Object> | Corresponds to the |
Nullable
Declaration
public bool? Nullable { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Nullable<System.Boolean> | Corresponds to the |
OptionalProperties
Declaration
public IDictionary<string, Schema> OptionalProperties { get; set; }
Property Value
| Type | Description |
|---|---|
| IDictionary<System.String, Schema> | Corresponds to the |
Properties
Declaration
public IDictionary<string, Schema> Properties { get; set; }
Property Value
| Type | Description |
|---|---|
| IDictionary<System.String, Schema> | Corresponds to the |
Ref
Declaration
public string Ref { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String | Corresponds to the |
Type
Declaration
public Type? Type { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Nullable<Type> | Corresponds to the |
Values
Declaration
public Schema Values { get; set; }
Property Value
| Type | Description |
|---|---|
| Schema | Corresponds to the |
Methods
| Improve this Doc View SourceForm()
Determines the form the Schema takes on.
Declaration
public Form Form()
Returns
| Type | Description |
|---|---|
| Form | The form the schema takes on, assuming it is a correct schema. |
Remarks
The JSON Type Definition specification requires that all schemas take on a particular "form", which is essentially a particular combination of keywords. This method determines which form a schema is using.
The return value of this method is meaningful only if the schema is, or is a sub-schema of, a correct schema. In other words, calling Verify() on this schema's root schema must not have raised an exception.
Verify()
Verifies that the Schema represents a correct JSON Type
Definition schema.
Declaration
public void Verify()
Remarks
The JSON Type Definition specification has certain requirements on
correct schemas that cannot be represented in CSharp's type system,
such as requiring that all ref keywords have a corresponding
definition. This method will check each of these requirements.
Exceptions
| Type | Condition |
|---|---|
| InvalidSchemaException | If the schema is not correct. |