Class JsonSchemaOptions
Defines options associated with JSON Schema.
Inheritance
Inherited Members
Namespace: Manatee.Json.Schema
Assembly: Manatee.Json.dll
Syntax
public class JsonSchemaOptions
Constructors
| Improve this Doc View SourceJsonSchemaOptions()
Creates a new instance of the JsonSchemaOptions class.
Declaration
public JsonSchemaOptions()
JsonSchemaOptions(JsonSchemaOptions)
Creates a new instance of the JsonSchemaOptions class.
Declaration
public JsonSchemaOptions(JsonSchemaOptions source)
Parameters
Type | Name | Description |
---|---|---|
JsonSchemaOptions | source |
Properties
| Improve this Doc View SourceAllowUnknownFormats
Gets or sets whether unknown string formats are permitted. If disabled and an unknown format is found, the system will throw a JsonSerializationException while loading the schema. The default is true.
Declaration
public bool AllowUnknownFormats { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Default
Default options used by schema.
Declaration
public static JsonSchemaOptions Default { get; }
Property Value
Type | Description |
---|---|
JsonSchemaOptions |
DefaultBaseUri
Defines a default base URI for root schemas that use a relative URI for their $id
. The default is manatee://json-schema/
.
Declaration
public Uri DefaultBaseUri { get; set; }
Property Value
Type | Description |
---|---|
System.Uri |
DefaultProcessingVersion
Gets or sets a default draft version to use in case a schema can be determined to support multiple drafts. Default is latest to earliest.
Declaration
public List<JsonSchemaVersion> DefaultProcessingVersion { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.List<JsonSchemaVersion> |
Download
Gets and sets a method used to download online schema.
Declaration
public static Func<string, string> Download { get; set; }
Property Value
Type | Description |
---|---|
System.Func<System.String, System.String> |
LogMetaSchemaValidation
Gets or sets whether meta-schema validation is enabled. Default is false.
Declaration
public bool LogMetaSchemaValidation { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
A schema is validated against the meta-schemas the first time it is used to validate an instance. This is done to determine the specific draft that the schema supports. Logging for this can be quite verbose, but if you want this to be logged, you can enable this feature.
OutputFormat
Gets or sets the output verbosity. The default is Flag.
Declaration
public SchemaValidationOutputFormat OutputFormat { get; set; }
Property Value
Type | Description |
---|---|
SchemaValidationOutputFormat |
RefResolution
Determines whether siblings of $ref
keywords are processed. This also affects how $ref
is resolved
when adjacent to an $id
keyword when a specific draft cannot be identified. The default is
ProcessSiblingKeywords to be consistent with the latest draft, 2019-09.
Declaration
public RefResolutionStrategy RefResolution { get; set; }
Property Value
Type | Description |
---|---|
RefResolutionStrategy |
Remarks
As of draft 2019-09, keywords are allowed to be adjacent to $ref
. This means that an
adjacent $id
keyword will now change the base URI whereas in prior drafts it would not
since adjacent keywords were to be ignored.
When Manatee.Json cannot determine the draft a particular schema is using (determined via
the $schema
keyword or the selection of keywords being used), this option will
determine the behavior for resolving URIs.
ValidateFormatKeyword
Gets or sets whether the "format" schema keyword should be validated. The default is true.
Declaration
public bool ValidateFormatKeyword { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
| Improve this Doc View SourceIgnoreErrorsForChildren(JsonPointer)
Ignores error and annotation collection for children of specific schema locations.
Declaration
public void IgnoreErrorsForChildren(JsonPointer location)
Parameters
Type | Name | Description |
---|---|---|
JsonPointer | location |
Remarks
This may help improve performance. There may be cases where it would be sufficient to only
report on the immediate error rather than all child errors. An example of this may be a keyword
like oneOf
at a specific location, where the client may only want a single error that says,
"4 of the 10 subschemas passed validation, but only 1 was expected."
IgnoreErrorsForChildren<T>()
Ignores error and annotation collection for children of specific keywords.
Declaration
public void IgnoreErrorsForChildren<T>()
where T : IJsonSchemaKeyword
Type Parameters
Name | Description |
---|---|
T | The keyword type to ignore. |
Remarks
This may help improve performance. There may be cases where it would be sufficient to only
report on the immediate error rather than all child errors. An example of this may be a keyword
like oneOf
, where the client may only want a single error that says, "4 of the 10 subschemas
passed validation, but only 1 was expected."
ShouldReportChildErrors(IJsonSchemaKeyword, SchemaValidationContext)
Checks whether child errors and annotations should be reported. Should be called during validation.
Declaration
public bool ShouldReportChildErrors(IJsonSchemaKeyword keyword, SchemaValidationContext context)
Parameters
Type | Name | Description |
---|---|---|
IJsonSchemaKeyword | keyword | The keyword currently executing validation. |
SchemaValidationContext | context | The validation context. |
Returns
Type | Description |
---|---|
System.Boolean |
|