# Class JsonSchema

Class
Module
import { JsonSchema } from "@tsed/schema"
Source/packages/schema/src/domain/JsonSchema.ts

# Overview

class JsonSchema extends Map<string, any> implements NestedGenerics {
    readonly $hooks: Hooks;
    readonly $required: Set<string>;
    $selfRequired: boolean;
    protected _genericLabels: string[];
    protected _nestedGenerics: Type<any>[][];
    protected _alias: AliasMap;
    protected _itemSchema: JsonSchema;
    protected _target: Type<any>;
    protected _isGeneric: boolean;
    protected _isCollection: boolean;
    protected _ref: boolean;
    protected _specs: Map<SpecTypes, any>;
    constructor(obj?: JsonSchema | Partial<JsonSchemaObject>);
    get alias(): AliasMap;
    get nestedGenerics(): any[];
    set nestedGenerics(value: any[]);
    get genericLabels(): string[];
    set genericLabels(value: string[]);
    get isClass(): boolean;
get <span class="token function">isCollection</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">boolean</span><span class="token punctuation">;</span>

get <span class="token function">isGeneric</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">boolean</span><span class="token punctuation">;</span>

get <span class="token function">hasGenerics</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">boolean</span><span class="token punctuation">;</span>
get <span class="token function">genericType</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">;</span>
get <span class="token keyword">class</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">;</span>
get <span class="token function">canRef</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">boolean</span><span class="token punctuation">;</span>
<span class="token keyword">static</span> <span class="token keyword">from</span><span class="token punctuation">(</span>obj?<span class="token punctuation">:</span> Partial&lt;<a href="/api/schema/domain/JsonSchemaObject.html"><span class="token">JsonSchemaObject</span></a>&gt;<span class="token punctuation">)</span><span class="token punctuation">:</span> JsonSchema<span class="token punctuation">;</span>
<span class="token function">itemSchema</span><span class="token punctuation">(</span>obj?<span class="token punctuation">:</span> <a href="/api/schema/domain/JsonSchemaObject.html"><span class="token">JsonSchemaObject</span></a> | JsonSchema | <span class="token keyword">any</span><span class="token punctuation">)</span><span class="token punctuation">:</span> JsonSchema<span class="token punctuation">;</span>
<span class="token function">getAliasOf</span><span class="token punctuation">(</span>property<span class="token punctuation">:</span> AliasType<span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">string</span> | <span class="token keyword">number</span> | symbol | undefined<span class="token punctuation">;</span>
<span class="token function">addAlias</span><span class="token punctuation">(</span>property<span class="token punctuation">:</span> AliasType<span class="token punctuation">,</span> alias<span class="token punctuation">:</span> AliasType<span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>
<span class="token function">removeAlias</span><span class="token punctuation">(</span>property<span class="token punctuation">:</span> AliasType<span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>
$<span class="token function">id</span><span class="token punctuation">(</span>$id<span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>
$<span class="token function">ref</span><span class="token punctuation">(</span>$ref<span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>
$<span class="token function">schema</span><span class="token punctuation">(</span>$schema<span class="token punctuation">:</span> JSONSchema6Version<span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>

<span class="token function">label</span><span class="token punctuation">(</span>name<span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>
<span class="token function">name</span><span class="token punctuation">(</span>name<span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>
<span class="token function">ignore</span><span class="token punctuation">(</span>cb<span class="token punctuation">:</span> <span class="token keyword">boolean</span> | <a href="/api/schema/interfaces/IgnoreCallback.html"><span class="token">IgnoreCallback</span></a><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>

<span class="token function">default</span><span class="token punctuation">(</span>value<span class="token punctuation">:</span> JSONSchema6Type<span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>

<span class="token keyword">const</span><span class="token punctuation">(</span>value<span class="token punctuation">:</span> JSONSchema6Type<span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>

<span class="token function">description</span><span class="token punctuation">(</span>description<span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>

<span class="token function">additionalItems</span><span class="token punctuation">(</span>additionalItems<span class="token punctuation">:</span> <span class="token keyword">boolean</span> | <a href="/api/schema/domain/JsonSchemaObject.html"><span class="token">JsonSchemaObject</span></a><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>

<span class="token function">contains</span><span class="token punctuation">(</span>contains<span class="token punctuation">:</span> JSONSchema6Definition<span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>

<span class="token function">examples</span><span class="token punctuation">(</span>examples<span class="token punctuation">:</span> JSONSchema6Type<span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>

<span class="token function">example</span><span class="token punctuation">(</span>...examples<span class="token punctuation">:</span> JSONSchema6Type<span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>

<span class="token function">items</span><span class="token punctuation">(</span>items<span class="token punctuation">:</span> JsonSchema | <a href="/api/schema/domain/JsonSchemaObject.html"><span class="token">JsonSchemaObject</span></a> | <span class="token punctuation">(</span><a href="/api/schema/domain/JsonSchemaObject.html"><span class="token">JsonSchemaObject</span></a> | JsonSchema<span class="token punctuation">)</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>

<span class="token function">maxItems</span><span class="token punctuation">(</span>maxItems<span class="token punctuation">:</span> <span class="token keyword">number</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>

<span class="token function">minItems</span><span class="token punctuation">(</span>minItems<span class="token punctuation">:</span> <span class="token keyword">number</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>

<span class="token function">uniqueItems</span><span class="token punctuation">(</span>uniqueItems<span class="token punctuation">:</span> <span class="token keyword">boolean</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>

<span class="token function">maxProperties</span><span class="token punctuation">(</span>maxProperties<span class="token punctuation">:</span> <span class="token keyword">number</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>

<span class="token function">minProperties</span><span class="token punctuation">(</span>minProperties<span class="token punctuation">:</span> <span class="token keyword">number</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>

<span class="token function">required</span><span class="token punctuation">(</span>required?<span class="token punctuation">:</span> <span class="token keyword">boolean</span> | <span class="token keyword">string</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">:</span> JsonSchema<span class="token punctuation">;</span>
<span class="token function">addRequired</span><span class="token punctuation">(</span>property<span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>
<span class="token function">removeRequired</span><span class="token punctuation">(</span>property<span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>
<span class="token function">isRequired</span><span class="token punctuation">(</span>property<span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">boolean</span><span class="token punctuation">;</span>

<span class="token function">properties</span><span class="token punctuation">(</span>properties<span class="token punctuation">:</span> JsonSchema | <span class="token punctuation">{</span>
    <span class="token punctuation">[</span>key<span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">]</span><span class="token punctuation">:</span> <a href="/api/schema/domain/JsonSchemaObject.html"><span class="token">JsonSchemaObject</span></a> | JsonSchema<span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>
<span class="token function">addProperty</span><span class="token punctuation">(</span>key<span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">,</span> schema<span class="token punctuation">:</span> <a href="/api/schema/domain/JsonSchemaObject.html"><span class="token">JsonSchemaObject</span></a> | JsonSchema<span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>

<span class="token function">patternProperties</span><span class="token punctuation">(</span>patternProperties<span class="token punctuation">:</span> <span class="token punctuation">{</span>
    <span class="token punctuation">[</span>p<span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">]</span><span class="token punctuation">:</span> <a href="/api/schema/domain/JsonSchemaObject.html"><span class="token">JsonSchemaObject</span></a> | JsonSchema<span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>

<span class="token function">additionalProperties</span><span class="token punctuation">(</span>additionalProperties<span class="token punctuation">:</span> <span class="token keyword">boolean</span> | <a href="/api/schema/domain/JsonSchemaObject.html"><span class="token">JsonSchemaObject</span></a> | JsonSchema | <a href="/api/core/interfaces/Type.html"><span class="token">Type</span></a>&lt;<span class="token keyword">any</span>&gt;<span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>

<span class="token function">unknown</span><span class="token punctuation">(</span>unknown?<span class="token punctuation">:</span> <span class="token keyword">boolean</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>

<span class="token function">dependencies</span><span class="token punctuation">(</span>dependencies<span class="token punctuation">:</span> <span class="token punctuation">{</span>
    <span class="token punctuation">[</span>p<span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">]</span><span class="token punctuation">:</span> JSONSchema6Definition | JsonSchema | <span class="token keyword">string</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>

<span class="token function">propertyNames</span><span class="token punctuation">(</span>propertyNames<span class="token punctuation">:</span> JSONSchema6Definition | JsonSchema<span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>

<span class="token keyword">enum</span><span class="token punctuation">(</span>enumValues<span class="token punctuation">:</span> JSONSchema6Type<span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>

<span class="token function">definitions</span><span class="token punctuation">(</span>definitions<span class="token punctuation">:</span> <span class="token punctuation">{</span>
    <span class="token punctuation">[</span>p<span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">]</span><span class="token punctuation">:</span> <a href="/api/schema/domain/JsonSchemaObject.html"><span class="token">JsonSchemaObject</span></a> | JsonSchema<span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>

<span class="token function">allOf</span><span class="token punctuation">(</span>allOf<span class="token punctuation">:</span> <span class="token punctuation">(</span><a href="/api/schema/domain/JsonSchemaObject.html"><span class="token">JsonSchemaObject</span></a> | JsonSchema<span class="token punctuation">)</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>

<span class="token function">anyOf</span><span class="token punctuation">(</span>anyOf<span class="token punctuation">:</span> <span class="token punctuation">(</span><a href="/api/schema/domain/JsonSchemaObject.html"><span class="token">JsonSchemaObject</span></a> | JsonSchema<span class="token punctuation">)</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>

<span class="token function">oneOf</span><span class="token punctuation">(</span>oneOf<span class="token punctuation">:</span> <span class="token punctuation">(</span><a href="/api/schema/domain/JsonSchemaObject.html"><span class="token">JsonSchemaObject</span></a> | JsonSchema | <a href="/api/schema/domain/JsonLazyRef.html"><span class="token">JsonLazyRef</span></a> | <span class="token keyword">any</span><span class="token punctuation">)</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>

<span class="token function">not</span><span class="token punctuation">(</span>not<span class="token punctuation">:</span> <a href="/api/schema/domain/JsonSchemaObject.html"><span class="token">JsonSchemaObject</span></a> | JsonSchema<span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>

<span class="token function">multipleOf</span><span class="token punctuation">(</span>multipleOf<span class="token punctuation">:</span> <span class="token keyword">number</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>

<span class="token function">maximum</span><span class="token punctuation">(</span>maximum<span class="token punctuation">:</span> <span class="token keyword">number</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>

<span class="token function">exclusiveMaximum</span><span class="token punctuation">(</span>exclusiveMaximum<span class="token punctuation">:</span> <span class="token keyword">number</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>

<span class="token function">minimum</span><span class="token punctuation">(</span>minimum<span class="token punctuation">:</span> <span class="token keyword">number</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>

<span class="token function">exclusiveMinimum</span><span class="token punctuation">(</span>exclusiveMinimum<span class="token punctuation">:</span> <span class="token keyword">number</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>

<span class="token function">maxLength</span><span class="token punctuation">(</span>maxLength<span class="token punctuation">:</span> <span class="token keyword">number</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>

<span class="token function">minLength</span><span class="token punctuation">(</span>minLength<span class="token punctuation">:</span> <span class="token keyword">number</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>

<span class="token function">pattern</span><span class="token punctuation">(</span>pattern<span class="token punctuation">:</span> <span class="token keyword">string</span> | RegExp<span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>

<span class="token function">format</span><span class="token punctuation">(</span>format<span class="token punctuation">:</span> <a href="/api/schema/domain/JsonFormatTypes.html"><span class="token">JsonFormatTypes</span></a> | <a href="/api/core/interfaces/ValueOf.html"><span class="token">ValueOf</span></a>&lt;<a href="/api/schema/domain/JsonFormatTypes.html"><span class="token">JsonFormatTypes</span></a>&gt;<span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>

<span class="token function">type</span><span class="token punctuation">(</span>type<span class="token punctuation">:</span> <span class="token keyword">any</span> | JSONSchema6TypeName | JSONSchema6TypeName<span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>
<span class="token function">addTypes</span><span class="token punctuation">(</span>...types<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">void</span><span class="token punctuation">;</span>
<span class="token keyword">any</span><span class="token punctuation">(</span>...types<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>
<span class="token function">integer</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>

<span class="token function">title</span><span class="token punctuation">(</span>title<span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>
<span class="token function">readOnly</span><span class="token punctuation">(</span>readOnly<span class="token punctuation">:</span> <span class="token keyword">boolean</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>
<span class="token function">writeOnly</span><span class="token punctuation">(</span>readOnly<span class="token punctuation">:</span> <span class="token keyword">boolean</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>
<span class="token function">customKey</span><span class="token punctuation">(</span>key<span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">,</span> value<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>
<span class="token function">toObject</span><span class="token punctuation">(</span>options?<span class="token punctuation">:</span> <a href="/api/schema/interfaces/JsonSchemaOptions.html"><span class="token">JsonSchemaOptions</span></a><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">;</span>
<span class="token function">toJSON</span><span class="token punctuation">(</span>options?<span class="token punctuation">:</span> <a href="/api/schema/interfaces/JsonSchemaOptions.html"><span class="token">JsonSchemaOptions</span></a><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">;</span>
<span class="token function">assign</span><span class="token punctuation">(</span>obj?<span class="token punctuation">:</span> JsonSchema | Partial&lt;<a href="/api/schema/domain/JsonSchemaObject.html"><span class="token">JsonSchemaObject</span></a>&gt;<span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>
<span class="token function">set</span><span class="token punctuation">(</span>key<span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">,</span> value<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">)</span><span class="token punctuation">:</span> this<span class="token punctuation">;</span>

<span class="token function">getComputedType</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">;</span>
<span class="token function">getComputedItemType</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">;</span>

<span class="token function">getJsonType</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">string</span><span class="token punctuation">;</span>

<span class="token function">getName</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">;</span>
<span class="token function">clone</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">:</span> JsonSchema<span class="token punctuation">;</span>

}

# Members

readonly $hooks: Hooks;

readonly $required: Set<string>;

$selfRequired: boolean;

protected _genericLabels: string[];

protected _nestedGenerics: Type<any>[][];

protected _alias: AliasMap;

protected _itemSchema: JsonSchema;

protected _target: Type<any>;

protected _isGeneric: boolean;

protected _isCollection: boolean;

protected _ref: boolean;

protected _specs: Map<SpecTypes, any>;

get alias(): AliasMap;

get nestedGenerics(): any[];

set nestedGenerics(value: any[]);

get genericLabels(): string[];

set genericLabels(value: string[]);

get isClass(): boolean;

get isCollection(): boolean;

Current schema is a collection


get isGeneric(): boolean;

Current schema is a generic


get hasGenerics(): boolean;

Current schema has generics items


get genericType(): string;

get class(): any;

get canRef(): boolean;

static from(obj?: Partial<JsonSchemaObject>): JsonSchema;

itemSchema(obj?: JsonSchemaObject | JsonSchema | any): JsonSchema;

getAliasOf(property: AliasType): string | number | symbol | undefined;

addAlias(property: AliasType, alias: AliasType): this;

removeAlias(property: AliasType): this;

$id($id: string): this;

$ref($ref: string): this;

$schema($schema: JSONSchema6Version): this;

label(name: string): this;

Create a ref and use name to sharing schema


name(name: string): this;

ignore(cb: boolean | IgnoreCallback): this;

default(value: JSONSchema6Type): this;

This keyword can be used to supply a default JSON value associated with a particular schema. It is RECOMMENDED that a default value be valid against the associated schema.


const(value: JSONSchema6Type): this;

More readible form of a one-element "enum"


description(description: string): this;

This attribute is a string that provides a full description of the of purpose the instance property.


additionalItems(additionalItems: boolean | JsonSchemaObject): this;

This keyword determines how child instances validate for arrays, and does not directly validate the immediate instance itself. If "items" is an array of schemas, validation succeeds if every instance element at a position greater than the size of "items" validates against "additionalItems". Otherwise, "additionalItems" MUST be ignored, as the "items" schema (possibly the default value of an empty schema) is applied to all elements. Omitting this keyword has the same behavior as an empty schema.


contains(contains: JSONSchema6Definition): this;

An array instance is valid against "contains" if at least one of its elements is valid against the given schema.


examples(examples: JSONSchema6Type[]): this;

Array of examples with no validation effect the value of "default" is usable as an example without repeating it under this keyword


example(...examples: JSONSchema6Type[]): this;

Array of examples with no validation effect the value of "default" is usable as an example without repeating it under this keyword


This keyword determines how child instances validate for arrays, and does not directly validate the immediate instance itself. Omitting this keyword has the same behavior as an empty schema.


maxItems(maxItems: number): this;

Must be a non-negative integer. An array instance is valid against "maxItems" if its size is less than, or equal to, the value of this keyword.


minItems(minItems: number): this;

Must be a non-negative integer. An array instance is valid against "maxItems" if its size is greater than, or equal to, the value of this keyword. Omitting this keyword has the same behavior as a value of 0.


uniqueItems(uniqueItems: boolean): this;

If this keyword has boolean value false, the instance validates successfully. If it has boolean value true, the instance validates successfully if all of its elements are unique. Omitting this keyword has the same behavior as a value of false.


maxProperties(maxProperties: number): this;

Must be a non-negative integer. An object instance is valid against "maxProperties" if its number of properties is less than, or equal to, the value of this keyword.


minProperties(minProperties: number): this;

Must be a non-negative integer. An object instance is valid against "maxProperties" if its number of properties is greater than, or equal to, the value of this keyword. Omitting this keyword has the same behavior as a value of 0.


required(required?: boolean | string[]): JsonSchema;

Elements of this array must be unique. An object instance is valid against this keyword if every item in the array is the name of a property in the instance. Omitting this keyword has the same behavior as an empty array.


addRequired(property: string): this;

removeRequired(property: string): this;

isRequired(property: string): boolean;

properties(properties: JsonSchema | {
     [key: string]: JsonSchemaObject | JsonSchema;
 }): this;

This keyword determines how child instances validate for objects, and does not directly validate the immediate instance itself. Validation succeeds if, for each name that appears in both the instance and as a name within this keyword's value, the child instance for that name successfully validates against the corresponding schema. Omitting this keyword has the same behavior as an empty object.


addProperty(key: string, schema: JsonSchemaObject | JsonSchema): this;

patternProperties(patternProperties: {
     [p: string]: JsonSchemaObject | JsonSchema;
 }): this;

This attribute is an object that defines the schema for a set of property names of an object instance. The name of each property of this attribute's object is a regular expression pattern in the ECMA 262, while the value is a schema. If the pattern matches the name of a property on the instance object, the value of the instance's property MUST be valid against the pattern name's schema value. Omitting this keyword has the same behavior as an empty object.


additionalProperties(additionalProperties: boolean | JsonSchemaObject | JsonSchema | Type<any>): this;

This attribute defines a schema for all properties that are not explicitly defined in an object type definition. If specified, the value MUST be a schema or a boolean. If false is provided, no additional properties are allowed beyond the properties defined in the schema. The default value is an empty schema which allows any value for additional properties.


unknown(unknown?: boolean): this;

This attribute defines a schema for all properties that are not explicitly defined in an object type definition. If specified, the value MUST be a schema or a boolean. If false is provided, no additional properties are allowed beyond the properties defined in the schema. The default value is an empty schema which allows any value for additional properties.


dependencies(dependencies: {
     [p: string]: JSONSchema6Definition | JsonSchema | string[];
 }): this;

This keyword specifies rules that are evaluated if the instance is an object and contains a certain property. Each property specifies a dependency. If the dependency value is an array, each element in the array must be unique. Omitting this keyword has the same behavior as an empty object.


propertyNames(propertyNames: JSONSchema6Definition | JsonSchema): this;

Takes a schema which validates the names of all properties rather than their values. Note the property name that the schema is testing will always be a string. Omitting this keyword has the same behavior as an empty schema.


enum(enumValues: JSONSchema6Type[]): this;

This provides an enumeration of all possible values that are valid for the instance property. This MUST be an array, and each item in the array represents a possible value for the instance value. If this attribute is defined, the instance value MUST be one of the values in the array in order for the schema to be valid.


definitions(definitions: {
     [p: string]: JsonSchemaObject | JsonSchema;
 }): this;

allOf(allOf: (JsonSchemaObject | JsonSchema)[]): this;

anyOf(anyOf: (JsonSchemaObject | JsonSchema)[]): this;

oneOf(oneOf: (JsonSchemaObject | JsonSchema | JsonLazyRef | any)[]): this;

not(not: JsonSchemaObject | JsonSchema): this;

multipleOf(multipleOf: number): this;

Must be strictly greater than 0. A numeric instance is valid only if division by this keyword's value results in an integer.


maximum(maximum: number): this;

Representing an inclusive upper limit for a numeric instance. This keyword validates only if the instance is less than or exactly equal to "maximum".


exclusiveMaximum(exclusiveMaximum: number): this;

Representing an exclusive upper limit for a numeric instance. This keyword validates only if the instance is strictly less than (not equal to) to "exclusiveMaximum".


minimum(minimum: number): this;

Representing an inclusive lower limit for a numeric instance. This keyword validates only if the instance is greater than or exactly equal to "minimum".


exclusiveMinimum(exclusiveMinimum: number): this;

Representing an exclusive lower limit for a numeric instance. This keyword validates only if the instance is strictly greater than (not equal to) to "exclusiveMinimum".


maxLength(maxLength: number): this;

Must be a non-negative integer. A string instance is valid against this keyword if its length is less than, or equal to, the value of this keyword.


minLength(minLength: number): this;

Must be a non-negative integer. A string instance is valid against this keyword if its length is greater than, or equal to, the value of this keyword. Omitting this keyword has the same behavior as a value of 0.


pattern(pattern: string | RegExp): this;

Should be a valid regular expression, according to the ECMA 262 regular expression dialect.


format(format: JsonFormatTypes | ValueOf<JsonFormatTypes>): this;

type(type: any | JSONSchema6TypeName | JSONSchema6TypeName[]): this;

A single type, or a union of simple types


addTypes(...types: any[]): void;

any(...types: any[]): this;

integer(): this;

title(title: string): this;

This attribute is a string that provides a short description of the instance property.


readOnly(readOnly: boolean): this;

writeOnly(readOnly: boolean): this;

customKey(key: string, value: any): this;

toObject(options?: JsonSchemaOptions): any;

toJSON(options?: JsonSchemaOptions): any;

assign(obj?: JsonSchema | Partial<JsonSchemaObject>): this;

set(key: string, value: any): this;

getComputedType(): any;

Return the itemSchema computed type. If the type is a function used for recursive model, the function will be called to get the right type.


getComputedItemType(): any;

getJsonType(): string;

Return the Json type as string


getName(): any;

Get the symbolic name of the entity


clone(): JsonSchema;

Other topics