@tsed/schema
Version:
JsonSchema module for Ts.ED Framework
57 lines (56 loc) • 1.95 kB
TypeScript
import type { JsonSchema } from "../domain/JsonSchema.js";
/**
* Declare a new array model. If an item schema is provided, it will be set as `items` and its type will be inferred.
*
* ```json
* { "type": "array" }
* ```
*
* See @@JsonSchema@@ to discover available methods.
*
* @schemaFunctional
*/
export declare function array(): JsonSchema<any[]>;
export declare function array<I>(item: JsonSchema<I>): JsonSchema<I[]>;
/**
* Declare a new object model with `additionalProperties: true` (map-like). If a value schema is provided, it is used
* as `additionalProperties` and its type will be inferred.
*
* ```json
* { "type": "object", "additionalProperties": true }
* ```
*
* See @@JsonSchema@@ to discover available methods.
*
* @schemaFunctional
*/
export declare function map(): JsonSchema<Record<string, any>>;
export declare function map<V>(value: JsonSchema<V>): JsonSchema<Map<string, V>>;
/**
* Declare a new array model representing a Set with `uniqueItems: true`. If an item schema is provided, it will be set
* as `items` and its type will be inferred as `Set<I>`.
*
* ```json
* { "type": "array", "uniqueItems": true }
* ```
*
* See @@JsonSchema@@ to discover available methods.
*
* @schemaFunctional
*/
export declare function set(): JsonSchema<Set<any>>;
export declare function set<I>(item: JsonSchema<I>): JsonSchema<Set<I>>;
/**
* Declare a new object model with `additionalProperties: true` (record-like). If a value schema is provided, it is used
* as `additionalProperties` and its type will be inferred as `Record<string, V>`.
*
* ```json
* { "type": "object", "additionalProperties": true }
* ```
*
* See @@JsonSchema@@ to discover available methods.
*
* @schemaFunctional
*/
export declare function record<K extends string | number | symbol = string, V = any>(): JsonSchema<Record<K, V>>;
export declare function record<V>(value: JsonSchema<V>): JsonSchema<Record<string, V>>;