Home JsonSchemaBuilder Class
JsonSchemaBuilder Class
Cancel

JsonSchemaBuilder Class

Namespace: Json.Schema

Inheritance: JsonSchemaBuilder 🡒 object

A fluent-style builder for Json.Schema.JsonSchema.

Properties

NameTypeSummary
EmptyJsonSchemaBuilderGets an instance of Json.Schema.JsonSchemaBuilder that represents an empty JSON schema.
FalseJsonSchemaBuilderGets a schema builder that always evaluates to false, representing a schema that does not match any JSON value.
TrueJsonSchemaBuilderGets a schema builder that creates a schema which always validates as <see langword=”true” />.

Constructors

JsonSchemaBuilder(BuildOptions buildOptions)

Initializes a new instance of the JsonSchemaBuilder class.

Declaration

1
public JsonSchemaBuilder(BuildOptions buildOptions)

Remarks

Use this constructor to create a new JsonSchemaBuilder for defining and constructing JSON schema objects. The builder can be configured with various schema properties and constraints before generating the final

Methods

Add(string keyword, JsonNode value)

Adds a new keyword with a value.

Declaration

1
public void Add(string keyword, JsonNode value)
ParameterTypeDescription
keywordstringThe keyword to add.
valueJsonNodeThe value.

Add(string keyword, JsonSchemaBuilder builder)

Adds a new keyword with a nested schema.

Declaration

1
public void Add(string keyword, JsonSchemaBuilder builder)
ParameterTypeDescription
keywordstringThe keyword to add.
builderJsonSchemaBuilderAnother builder.

Add(string keyword, IEnumerable<JsonSchemaBuilder> builders)

Adds a new keyword with a nested schema.

Declaration

1
public void Add(string keyword, IEnumerable<JsonSchemaBuilder> builders)
ParameterTypeDescription
keywordstringThe keyword to add.
buildersIEnumerable<JsonSchemaBuilder>Another builder.

Add(string keyword, IEnumerable<(string, JsonSchemaBuilder)> builders)

Adds a new keyword with a nested schema.

Declaration

1
public void Add(string keyword, IEnumerable<(string, JsonSchemaBuilder)> builders)
ParameterTypeDescription
keywordstringThe keyword to add.
buildersIEnumerable<(string, JsonSchemaBuilder)>Another builder.

Add(string keyword, IEnumerable<KeyValuePair<string, JsonSchemaBuilder>> builders)

Adds a new keyword with a nested schema.

Declaration

1
public void Add(string keyword, IEnumerable<KeyValuePair<string, JsonSchemaBuilder>> builders)
ParameterTypeDescription
keywordstringThe keyword to add.
buildersIEnumerable<KeyValuePair<string, JsonSchemaBuilder>>Another builder.

Build(BuildOptions options, Uri baseUri)

Builds a JSON schema from the configured keywords and returns a corresponding Json.Schema.JsonSchema instance.

Declaration

1
public JsonSchema Build(BuildOptions options, Uri baseUri)
ParameterTypeDescription
optionsBuildOptions(Optional) Build options that control schema generation behavior. Overrides build options
baseUriUri(Optional) A base URI to associate with the generated schema. If specified, it is used to resolve relative

Returns

A Json.Schema.JsonSchema instance representing the constructed schema based on the provided options and base URI.

RecursiveRefRoot()

Creates a new Json.Schema.JsonSchema.

Declaration

1
public static JsonSchemaBuilder RecursiveRefRoot()

Returns

A JSON Schema that simply refers back to the recursive root schema.

RefRoot()

Creates a new Json.Schema.JsonSchema.

Declaration

1
public static JsonSchemaBuilder RefRoot()

Returns

A JSON Schema that simply refers back to the root schema.

Contents