# JsonSchema Class

Module
import { JsonSchema } from "@tsed/common"
Source/packages/common/src/jsonschema/class/JsonSchema.ts

# Overview

class JsonSchema implements JSONSchema6 {
    /**
     *
     * @type {string}
     */
    $id: string;
    id: string;
    $ref: string;
    $schema: any;
    title: string;
    description: string;
    default: JSONSchema6Type;
    additionalItems: boolean | JSONSchema6;
    items: JsonSchema;
    maxItems: number;
    minItems: number;
    uniqueItems: boolean;
    maxProperties: number;
    minProperties: number;
    required: any | string[];
    properties: {
        [key: string]: JsonSchema;
    };
    additionalProperties: JsonSchema;
    definitions: {
        [p: string]: JSONSchema6;
    };
    patternProperties: {
        [p: string]: JSONSchema6;
    };
    dependencies: {
        [p: string]: JSONSchema6 | string[];
    };
    allOf: JSONSchema6[];
    anyOf: JSONSchema6[];
    oneOf: JSONSchema6[];
    not: JSONSchema6;
    extends: string | string[];
    multipleOf: number;
    maximum: number;
    exclusiveMaximum: number;
    minimum: number;
    exclusiveMinimum: number;
    maxLength: number;
    minLength: number;
    pattern: string;
    format: string;
    enum: JSONSchema6Type[];
<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> <span class="token keyword">any</span><span class="token punctuation">;</span>
<span class="token keyword">constructor</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
/**
 *
 * @returns <span class="token punctuation">{</span>JSONSchema6<span class="token punctuation">}</span>
 */
get <span class="token function">mapper</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">:</span> JSONSchema6<span class="token punctuation">;</span>
/**
 *
 * @returns <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>
 */
get <span class="token function">type</span><span class="token punctuation">(</span><span class="token punctuation">)</span><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>
/**
 *
 * @param <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> value
 */
set <span class="token function">type</span><span class="token punctuation">(</span>value<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>
/**
 *
 * @returns <span class="token punctuation">{</span><span class="token keyword">string</span><span class="token punctuation">}</span>
 */
get <span class="token function">refName</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>
/**
 *
 * @returns <span class="token punctuation">{</span><span class="token keyword">boolean</span><span class="token punctuation">}</span>
 */
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>
/**
 *
 * @returns <span class="token punctuation">{</span><span class="token keyword">boolean</span><span class="token punctuation">}</span>
 */
get <span class="token function">isArray</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>
/**
 *
 * @returns <span class="token punctuation">{</span>"collection" | JSONSchema6TypeName | JSONSchema6TypeName<span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">}</span>
 */
get <span class="token function">schemaType</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token string">"collection"</span> | JSONSchema6TypeName | JSONSchema6TypeName<span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
/**
 *
 * @param value
 * @deprecated
 * @returns <span class="token punctuation">{</span>JSONSchema6TypeName | JSONSchema6TypeName<span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">}</span>
 */
<span class="token keyword">static</span> <span class="token function">getJsonType</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> JSONSchema6TypeName | JSONSchema6TypeName<span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
/**
 *
 * @param type
 * @returns <span class="token punctuation">{</span>JSONSchema6<span class="token punctuation">}</span>
 */
<span class="token keyword">static</span> <span class="token function">ref</span><span class="token punctuation">(</span>type<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">)</span><span class="token punctuation">:</span> JsonSchema<span class="token punctuation">;</span>
/**
 * Write value on the right place according to the schema type
 */
<span class="token function">mapValue</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> <span class="token keyword">void</span><span class="token punctuation">;</span>
/**
 *
 * @param collectionType
 */
<span class="token function">toCollection</span><span class="token punctuation">(</span>collectionType<span class="token punctuation">:</span> <span class="token keyword">any</span><span class="token punctuation">)</span><span class="token punctuation">:</span> <span class="token keyword">void</span><span class="token punctuation">;</span>
/**
 *
 * @returns <span class="token punctuation">{</span><span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token punctuation">}</span>
 */
<span class="token function">toJSON</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">toObject</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>
/**
 *
 * @param obj
 */
<span class="token function">merge</span><span class="token punctuation">(</span>obj<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>
/**
 *
 * @param instance
 * @param <span class="token punctuation">{</span><span class="token keyword">string</span><span class="token punctuation">}</span> property
 */

}

# Description

Class to store JsonSchema metadata

WARNING

This class will be removed in v6. Don't use this class to manipulate the json schema.

:::