@tsed/schema
Version:
JsonSchema module for Ts.ED Framework
822 lines (821 loc) • 35.3 kB
TypeScript
import { Type, ValueOf } from "@tsed/core";
import { Hooks } from "@tsed/hooks";
import type { JSONSchema7, JSONSchema7Definition, JSONSchema7Type, JSONSchema7TypeName, JSONSchema7Version } from "json-schema";
import { VendorKeys } from "../constants/VendorKeys.js";
import { IgnoreCallback } from "../interfaces/IgnoreCallback.js";
import { JsonSchemaOptions } from "../interfaces/JsonSchemaOptions.js";
import { type GenericsMap, GenericValue } from "../utils/generics.js";
import { AliasMap, AliasType } from "./JsonAliasMap.js";
import { Discriminator } from "./JsonDiscriminator.js";
import { JsonFormatTypes } from "./JsonFormatTypes.js";
import { JsonLazyRef } from "./JsonLazyRef.js";
import type { Infer, PropsToShape, SchemaKey, SchemaMerge, SchemaOmit, SchemaPartial, SchemaPick, UnionToIntersection } from "./types.js";
/**
* Extended JSON Schema object supporting TypeScript types and Ts.ED enhancements.
*
* This interface extends the standard JSON Schema 7 specification with additional
* type flexibility, allowing TypeScript classes and types to be used directly
* in schema definitions.
*
* @public
*/
export interface JsonSchemaObject extends Omit<JSONSchema7, "type" | "additionalProperties" | "items" | "pattern"> {
type?: JSONSchema7["type"] | Type | null | (String | null | Date | Number | Object | Boolean)[];
additionalProperties?: JsonSchemaObject | boolean | Type | JsonSchema;
items?: JsonSchemaObject | boolean | Type | JsonSchema | (JsonSchemaObject | Type | JsonSchema)[];
pattern?: string | RegExp;
}
/**
* Union type representing any valid JSON schema representation.
*
* This type accepts various schema formats including standard JSON Schema objects,
* Ts.ED JsonSchema instances, lazy references, TypeScript classes, and label objects.
* It provides maximum flexibility for schema definition across the framework.
*
* @typeParam T - The TypeScript type this schema represents
*
* @public
*/
export type AnyJsonSchema<T = any> = JsonSchemaObject | JSONSchema7 | JsonSchema<T> | JsonLazyRef | {
label?: string;
} | Type;
/**
* Core class representing a JSON Schema with TypeScript type integration.
*
* JsonSchema is the central class in Ts.ED's schema system, providing a Map-based
* interface for building and manipulating JSON Schema definitions. It extends the
* standard JSON Schema 7 specification with Ts.ED-specific features including:
*
* - TypeScript class and type integration
* - Property aliasing and naming strategies
* - Group-based conditional schemas
* - Discriminator support for polymorphic types
* - Generic type parameter handling
* - Schema composition (oneOf, allOf, anyOf)
* - Hook-based transformation pipeline
* - Vendor extension support
*
* ### Usage
*
* ```typescript
* // Create a basic schema
* const schema = new JsonSchema({
* type: "string",
* minLength: 1,
* maxLength: 100
* });
*
* // Create schema from TypeScript class
* class User {
* name: string;
* email: string;
* }
*
* const userSchema = JsonSchema.from(User);
*
* // Generate JSON Schema output
* const jsonSchema = userSchema.toJSON();
* ```
*
* ### Key Features
*
* - **Type Safety**: Generic type parameter `T` represents the TypeScript type
* - **Composition**: Support for allOf, oneOf, anyOf schema composition
* - **Validation**: Full JSON Schema validation keyword support
* - **Transformation**: Hook system for custom schema transformations
* - **Groups**: Conditional property inclusion based on groups
* - **Generics**: Support for generic type parameters in classes
*
* @typeParam T - The TypeScript type this schema represents
*
* @public
*/
export declare class JsonSchema<T = JSONSchema7Type> extends Map<string, any> {
#private;
readonly $kind: string;
readonly $isJsonDocument = true;
readonly $hooks: Hooks;
readonly $allow: any[];
$selfRequired: boolean;
$ignore: boolean | IgnoreCallback;
isDiscriminatorKey: boolean;
isDiscriminator: boolean;
constructor(obj?: Partial<JSONSchema7> | JsonSchema | Record<string, unknown>);
/**
* Get the alias map for property name aliases.
*
* The alias map allows bidirectional property name mapping, useful for
* serialization/deserialization with different naming conventions.
*
* @returns The alias map containing property-to-alias and alias-to-property mappings
*/
get alias(): AliasMap;
/**
* Check if this schema represents a TypeScript class (not a primitive or collection).
*
* @returns `true` if the schema represents a class, `false` otherwise
*/
get isClass(): boolean;
/**
* Check if this schema represents a collection (array, Set, Map, etc.).
*
* Collections have an associated item schema that defines the type of elements
* they contain.
*
* @returns `true` if the schema is a collection, `false` otherwise
*/
get isCollection(): boolean;
/**
* Check if this is a local schema reference.
*
* A local schema acts as a reference to link a property or parameter to a class schema.
* This is used for type resolution and avoids schema duplication.
*
* @returns `true` if this is a local schema reference, `false` otherwise
*/
get isLocalSchema(): boolean;
/**
* Check if this schema represents a generic type.
*
* Generic schemas have a generic label vendor key and are used for parameterized types.
*
* @returns `true` if the schema is a generic type, `false` otherwise
*/
get isGeneric(): boolean;
/**
* Get the ancestor schema that defines a discriminator.
*
* Searches through the class hierarchy to find a parent class with a discriminator
* configuration. This is used for polymorphic type resolution.
*
* @returns The ancestor schema with discriminator, or undefined if none found
*/
get discriminatorAncestor(): any;
/**
* Get the computed TypeScript class or type for this schema.
*
* For local schemas, returns the item schema's target.
* For recursive models using functions, resolves the function to get the actual type.
*
* @returns The TypeScript class or type this schema represents
*/
get class(): Type<any>;
/**
* Get the TypeScript class for collection items.
*
* For collection schemas, returns the type of elements in the collection.
* For non-collection schemas, returns the schema's own class.
*
* @returns The item class for collections, or the schema's class otherwise
*/
get collectionClass(): Type<any>;
/**
* Check if this schema can use a $ref reference.
*
* Schemas with labels can be referenced by $ref to avoid duplication
* in generated OpenAPI specifications.
*
* @returns `true` if the schema can be referenced via $ref, `false` otherwise
*/
get canRef(): boolean;
/**
* Check if this schema allows null values.
*
* @returns `true` if the schema is nullable, `false` otherwise
*/
get isNullable(): boolean;
/**
* Check if this property is read-only.
*
* Read-only properties are included in responses but not accepted in requests.
*
* @returns `true` if the property is read-only, `false` otherwise
*/
get isReadOnly(): any;
/**
* Check if this property is write-only.
*
* Write-only properties are accepted in requests but not included in responses.
* Useful for sensitive data like passwords.
*
* @returns `true` if the property is write-only, `false` otherwise
*/
get isWriteOnly(): any;
/**
* Check if this schema has a discriminator configuration.
*
* Discriminators enable polymorphic type resolution based on a property value.
*
* @returns `true` if a discriminator is configured, `false` otherwise
*/
get hasDiscriminator(): boolean;
/**
* Create a JsonSchema from various input types.
*
* This factory method intelligently converts different input types into JsonSchema instances:
* - Existing JsonSchema: returned as-is
* - TypeScript classes: retrieves the schema from JsonEntityStore
* - Primitive classes (String, Number, etc.) and Date: creates type schema
* - Plain objects: creates schema from JSON Schema definition
*
* ### Usage
*
* ```typescript
* // From a class
* const schema1 = JsonSchema.from(User);
*
* // From a primitive
* const schema2 = JsonSchema.from(String);
*
* // From a schema object
* const schema3 = JsonSchema.from({type: "string", minLength: 1});
*
* // From existing schema (no-op)
* const schema4 = JsonSchema.from(schema1);
* ```
*
* @param item - The input to convert to a JsonSchema
* @returns A JsonSchema instance representing the input
*/
static from(item: Partial<JsonSchemaObject> | Type<any> | JsonSchema | undefined): JsonSchema<JSONSchema7Type>;
static add<Keys extends keyof JsonSchema>(property: Keys, method: JsonSchema[Keys]): typeof JsonSchema;
/**
* Check if the schema has a property.
*
* Checks multiple locations in order:
* 1. Standard Map keys
* 2. Internal keys (prefixed with #)
* 3. Vendor extension keys
*
* @param key - The property key to check
* @returns `true` if the property exists, `false` otherwise
*/
has(key: string): boolean;
/**
* Get a property value from the schema.
*
* Retrieves values from multiple locations in order:
* 1. Vendor extension keys
* 2. Standard Map keys
* 3. Internal keys (prefixed with #)
* 4. Default value if not found
*
* ### Usage
*
* ```typescript
* const minLength = schema.get("minLength", 0);
* const customKey = schema.get("x-custom");
* ```
*
* @param key - The property key to retrieve
* @param defaultValue - Optional default value if key not found
* @returns The property value or default value
*/
get<T = any>(key: string, defaultValue: T): T;
get<T = any>(key: string, defaultValue?: T): T | undefined;
/**
* Enable group forwarding to nested properties.
*
* When enabled, groups specified at the parent level are forwarded to nested
* object properties, allowing hierarchical group filtering.
*
* @param bool - Whether to enable group forwarding (default: true)
* @returns This schema instance for method chaining
*/
forwardGroups(bool?: boolean): this;
/**
* Assign groups to this property or schema.
*
* Groups enable conditional inclusion of properties based on serialization context.
* For example, you might have "admin" and "public" groups to control visibility.
*
* ### Usage
*
* ```typescript
* schema.groups(["admin", "internal"]);
* ```
*
* @param groups - Array of group names this property belongs to
* @param isProperty - Whether this is a property schema (enables group matching hooks)
* @returns This schema instance for method chaining
*/
groups(groups?: string[], isProperty?: boolean): this;
/**
* Set a custom name suffix for group-specific schema variations.
*
* This is used to generate unique schema names when the same model is used
* with different groups, avoiding conflicts in OpenAPI components.
*
* @param groupsName - The groups name suffix
* @returns This schema instance for method chaining
*/
groupsName(groupsName?: string): this;
/**
* Specify which groups are allowed access to this schema.
*
* @param groups - Array of group names allowed to access this schema
* @returns This schema instance for method chaining
*/
allowedGroups(groups?: string[]): this;
/**
* Assign generic type parameter labels to a class or schema.
*
* Used for classes with generic type parameters (e.g., `Paginated<T>`)
* to track the parameter names for proper schema generation.
*
* ### Usage
*
* ```typescript
* schema.genericLabels(["T", "U"]);
* ```
*
* @param genericLabels - Array of generic type parameter names
* @returns This schema instance for method chaining
*/
genericLabels(genericLabels: string[]): this;
/**
* Assign a single generic type label to this schema.
*
* Marks this schema as representing a generic type parameter.
*
* @param genericLabel - The generic type parameter name
* @returns This schema instance for method chaining
*/
genericLabel(genericLabel: string): this;
/**
* Specify the concrete types for generic parameters.
*
* When using a generic class, this method assigns the actual types that should
* replace the generic parameters for this specific instance.
*
* ### Usage
*
* ```typescript
* // For Paginated<User>
* schema.genericOf([User]);
* ```
*
* @param generics - Arrays of generic type values to apply
* @returns This schema instance for method chaining
*/
genericOf(...generics: GenericValue[][]): this;
/**
* Mark this schema as nullable or non-nullable.
*
* Nullable schemas can accept `null` values in addition to their base type.
* The type parameter is updated to reflect the nullability.
*
* ### Usage
*
* ```typescript
* // Make nullable
* schema.nullable(); // or schema.nullable(true)
*
* // Make non-nullable
* schema.nullable(false);
* ```
*
* @param value - Whether the schema is nullable (default: true)
* @returns This schema instance with updated type
*/
nullable(): JsonSchema<T | null>;
nullable(value: true): JsonSchema<T | null>;
nullable(value: false): JsonSchema<Exclude<T, null>>;
/**
* Get or create the item schema for collections.
*
* For array/collection types, this defines the schema for individual items.
* If the schema already has an item schema, it returns the existing one;
* otherwise, it creates a new one from the provided definition.
*
* ### Usage
*
* ```typescript
* // Define array items
* const arraySchema = new JsonSchema({type: "array"});
* arraySchema.itemSchema({type: "string", minLength: 1});
*
* // For class-based items
* arraySchema.itemSchema(User);
* ```
*
* @param obj - Schema definition for items
* @returns The item schema instance
*/
itemSchema(obj?: AnyJsonSchema): JsonSchema<JSONSchema7Type>;
/**
* Get the alias for a property name.
*
* @param property - The property name to look up
* @returns The alias for the property, or undefined if none exists
*/
getAliasOf(property: AliasType): AliasType | undefined;
/**
* Add a bidirectional alias mapping between property names.
*
* Aliases allow properties to be accessed by alternative names, useful for
* supporting different naming conventions (camelCase vs snake_case, etc.).
*
* ### Usage
*
* ```typescript
* schema.addAlias("userId", "user_id");
* // Both "userId" and "user_id" now map to each other
* ```
*
* @param property - The original property name
* @param alias - The alias name
* @returns This schema instance for method chaining
*/
addAlias(property: AliasType, alias: AliasType): this;
/**
* Remove an alias mapping for a property.
*
* @param property - The property name to remove aliases for
* @returns This schema instance for method chaining
*/
removeAlias(property: AliasType): this;
/**
* Set the `$id` keyword for this schema.
*
* The `$id` keyword is used to identify the schema and establish a base URI
* for resolving relative references.
*
* @param $id - The schema identifier URI
* @returns This schema instance for method chaining
*/
$id($id: string): this;
/**
* Set a `$ref` reference to another schema.
*
* The `$ref` keyword creates a reference to a schema defined elsewhere,
* enabling schema reuse and avoiding duplication.
*
* @param $ref - The reference URI (e.g., "#/components/schemas/User")
* @returns This schema instance for method chaining
*/
$ref($ref: string): this;
/**
* Set the JSON Schema version.
*
* @param $schema - The JSON Schema version URI
* @returns This schema instance for method chaining
*/
$schema($schema: JSONSchema7Version): this;
/**
* Assign a label to enable schema referencing.
*
* Labeled schemas can be referenced using `$ref` in OpenAPI specifications,
* reducing duplication by sharing schema definitions across endpoints.
*
* ### Usage
*
* ```typescript
* schema.label("User");
* // Can now be referenced as #/components/schemas/User
* ```
*
* @param name - The label name for the schema
* @returns This schema instance for method chaining
*/
label(name: string): this;
/**
* Set the name of this schema.
*
* Unlike `label()`, this sets the name without enabling referencing.
*
* @param name - The schema name
* @returns This schema instance for method chaining
*/
name(name: string): this;
/**
* Mark this property as ignored during serialization.
*
* Ignored properties are excluded from generated schemas and serialization.
* Can be a boolean or a callback function for conditional ignoring.
*
* ### Usage
*
* ```typescript
* // Always ignore
* schema.ignore(true);
*
* // Conditionally ignore based on context
* schema.ignore((value, ctx) => {
* return ctx.groups?.includes("public");
* });
* ```
*
* @param cb - Boolean flag or callback function to determine if property should be ignored
* @returns This schema instance for method chaining
*/
ignore(cb: boolean | IgnoreCallback): 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.
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.3
*/
default(value: T | undefined | (() => T)): JsonSchema<T>;
/**
* More readable form of a one-element "enum"
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.24
*/
const<V extends T>(value: V): JsonSchema<V>;
/**
* This attribute is a string that provides a full description of the purpose of the instance property.
*
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.2
*/
description(description: string): this;
discriminator(): Discriminator;
discriminatorKey(propertyName: string): this;
discriminatorValue(...values: string[]): 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.
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.10
*/
additionalItems(additionalItems: boolean | AnyJsonSchema): this;
/**
* An array instance is valid against "contains" if at least one of its elements is valid against the given schema.
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.14
*/
contains(contains: JSONSchema7Definition): this;
/**
* Array of examples with no validation effect the value of "default" is usable as an example without repeating it under this keyword
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.4
*/
examples(examples: JSONSchema7Type[]): this;
/**
* Array of examples with no validation effect the value of "default" is usable as an example without repeating it under this keyword
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.4
*/
example(...examples: JSONSchema7Type[]): this;
/**
* 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.
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.9
*/
/**
* Set the items' schema for array/set collections
* @param items The schema for array/set items
*/
items<I = JSONSchema7Type>(items: JsonSchema<I> | AnyJsonSchema | AnyJsonSchema[]): JsonSchema<T extends Array<any> ? I[] : T extends Set<any> ? Set<I> : I>;
$comment(comment: string): 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.
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.11
*/
maxItems(maxItems: 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.
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.12
*/
minItems(minItems: number): this;
/**
* If this keyword has a 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.
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.13
*/
uniqueItems(uniqueItems: boolean): 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.
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.15
*/
maxProperties(maxProperties: 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.
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.16
*/
minProperties(minProperties: number): this;
allow(...allow: any[]): this;
optional(): JsonSchema<T | undefined>;
/**
* 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.
*
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.17
*/
required(): JsonSchema<Exclude<T, undefined>>;
required(required: true): JsonSchema<Exclude<T, undefined>>;
required(required: false): JsonSchema<T | undefined>;
addRequired(property: string): this;
removeRequired(property: string): this;
isRequired(property: string): boolean;
getRequiredFields(): string[];
/**
* 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.
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.18
*/
properties<P extends Record<string, JsonSchema<any>> = Record<string, JsonSchema<any>>>(properties: P): JsonSchema<PropsToShape<P>>;
pick<K extends SchemaKey<T>>(...keys: K[]): JsonSchema<SchemaPick<T, K>>;
omit<K extends SchemaKey<T>>(...keys: K[]): JsonSchema<SchemaOmit<T, K>>;
partial(): JsonSchema<SchemaPartial<T>>;
merge<S extends JsonSchema<any>>(schema: S): JsonSchema<SchemaMerge<T, Infer<S>>>;
addProperty(key: string, schema: AnyJsonSchema): 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.
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.19
*/
patternProperties<P extends Record<string, JsonSchema<any>> = Record<string, JsonSchema<any>>>(patternProperties: P): JsonSchema<PropsToShape<P>>;
/**
* 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 that allows any value for additional properties.
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.20
*/
additionalProperties<V>(additionalProperties: boolean | AnyJsonSchema | JsonSchema<V>): JsonSchema<Map<string, V>>;
/**
* 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 that allows any value for additional properties.
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.20
* @alias additionalProperties
* @param unknown
*/
unknown(unknown?: boolean): JsonSchema<T & Record<string, unknown>>;
/**
* 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.
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.21
*/
dependencies(dependencies: {
[p: string]: JSONSchema7Definition | JsonSchema | string[];
}): 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.
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.22
*/
propertyNames(propertyNames: JSONSchema7Definition | JsonSchema): 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.
*
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.23
*/
enum<E extends Record<string, string | number>>(e: E): JsonSchema<E[keyof E]>;
enum<E extends readonly T[]>(...e: E): JsonSchema<E[number]>;
enum<E extends readonly T[]>(e: E): JsonSchema<E[number]>;
/**
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.1
*/
definitions(definitions: Record<string, AnyJsonSchema>): this;
/**
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.26
*/
allOf<S extends Array<AnyJsonSchema | null>>(allOf: S): JsonSchema<UnionToIntersection<Infer<S[number]>>>;
/**
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.27
*/
anyOf<S extends Array<AnyJsonSchema | null>>(anyOf: S): JsonSchema<Infer<S[number]>>;
oneOf<S extends Array<AnyJsonSchema | null>>(oneOf: S): JsonSchema<Infer<S[number]>>;
/**
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.29
*/
not(not: AnyJsonSchema): this;
/**
* Must be strictly greater than 0.
* A numeric instance is valid only if division by this keyword's value results in an integer.
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.1
*/
multipleOf(multipleOf: 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".
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.2
*/
max(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".
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.2
*/
maximum(maximum: 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".
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.3
*/
exclusiveMaximum(exclusiveMaximum: 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".
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.4
*/
min(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".
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.4
*/
minimum(minimum: 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".
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.5
*/
exclusiveMinimum(exclusiveMinimum: 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.
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.6
*/
maxLength(maxLength: 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.
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.7
*/
minLength(minLength: number): this;
/**
* Should be a valid regular expression, according to the ECMA 262 regular expression dialect.
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.8
*/
pattern(pattern: string | RegExp): this;
/**
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-8
*/
format(format: JsonFormatTypes | ValueOf<JsonFormatTypes>): this;
/**
* A single type, or a union of simple types
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-6.25
*/
type(type: any | JSONSchema7TypeName | JSONSchema7TypeName[]): this;
any(...types: any[]): this;
integer(): this;
/**
* This attribute is a string that provides a short description of the instance property.
*
* @see https://tools.ietf.org/html/draft-wright-json-schema-validation-01#section-7.2
*/
title(title: string): this;
readOnly(readOnly: boolean): this;
writeOnly(readOnly: boolean): this;
customKey(key: string, value: any): this;
vendorKey(key: VendorKeys, value: any): this;
toObject(options?: JsonSchemaOptions): any;
toJSON(options?: JsonSchemaOptions): any;
assign(obj: Partial<JSONSchema7> | JsonSchema | Record<string, unknown>): this;
set(key: string, value: any): this;
/**
* Return the JSON type as string
*/
getJsonType(): string | string[];
getTarget(): Type<any>;
getAllowedGroups(): Set<string> | undefined;
getAllowedRequiredValues(): any[];
getGroups(): string[] | undefined;
getGroupsName(): string | undefined;
/**
* Get the symbolic name of the entity
*/
getName(): any;
clone(): JsonSchema<JSONSchema7Type>;
getGenericLabels(): string[] | undefined;
getGenericOf(): GenericsMap | undefined;
/**
* Returns the reference schema for class-based schemas.
* Used to get the original schema definition when this schema is a local reference.
* @returns The reference schema or undefined if not applicable
*/
getRefSchema(): JsonSchema<JSONSchema7Type> | undefined;
propertyKey(s: string): this;
getPropertyKey(): string | symbol | undefined;
target(target: any): void;
isRequiredValue(property: string, value: any): boolean;
protected setManyOf(keyword: "oneOf" | "anyOf" | "allOf", value: (AnyJsonSchema | null)[]): this | undefined;
protected mapToJsonSchema(item: any[]): JsonSchema[];
protected mapToJsonSchema(item: any): JsonSchema;
protected mapGenerics(jsonSchema: JsonSchema, generics: GenericValue[][]): GenericsMap;
protected mapProperties(properties: Record<string, any>): any;
}