UNPKG

3.14 kBTypeScriptView Raw
1/// <reference types="lodash" />
2import { JSONSchema4, JSONSchema4Type, JSONSchema4TypeName } from 'json-schema';
3export declare type SchemaType = 'ALL_OF' | 'UNNAMED_SCHEMA' | 'ANY' | 'ANY_OF' | 'BOOLEAN' | 'NAMED_ENUM' | 'NAMED_SCHEMA' | 'NULL' | 'NUMBER' | 'STRING' | 'OBJECT' | 'ONE_OF' | 'TYPED_ARRAY' | 'REFERENCE' | 'UNION' | 'UNNAMED_ENUM' | 'UNTYPED_ARRAY' | 'CUSTOM_TYPE';
4export declare type JSONSchemaTypeName = JSONSchema4TypeName;
5export declare type JSONSchemaType = JSONSchema4Type;
6export interface JSONSchema extends JSONSchema4 {
7 /**
8 * schema extension to support numeric enums
9 */
10 tsEnumNames?: string[];
11 /**
12 * schema extension to support custom types
13 */
14 tsType?: string;
15}
16export declare const Parent: unique symbol;
17export interface LinkedJSONSchema extends JSONSchema {
18 /**
19 * A reference to this schema's parent node, for convenience.
20 * `null` when this is the root schema.
21 */
22 [Parent]: LinkedJSONSchema | null;
23 additionalItems?: boolean | LinkedJSONSchema;
24 additionalProperties: boolean | LinkedJSONSchema;
25 items?: LinkedJSONSchema | LinkedJSONSchema[];
26 definitions?: {
27 [k: string]: LinkedJSONSchema;
28 };
29 properties?: {
30 [k: string]: LinkedJSONSchema;
31 };
32 patternProperties?: {
33 [k: string]: LinkedJSONSchema;
34 };
35 dependencies?: {
36 [k: string]: LinkedJSONSchema | string[];
37 };
38 allOf?: LinkedJSONSchema[];
39 anyOf?: LinkedJSONSchema[];
40 oneOf?: LinkedJSONSchema[];
41 not?: LinkedJSONSchema;
42}
43export interface NormalizedJSONSchema extends LinkedJSONSchema {
44 additionalItems?: boolean | NormalizedJSONSchema;
45 additionalProperties: boolean | NormalizedJSONSchema;
46 extends?: string[];
47 items?: NormalizedJSONSchema | NormalizedJSONSchema[];
48 definitions?: {
49 [k: string]: NormalizedJSONSchema;
50 };
51 properties?: {
52 [k: string]: NormalizedJSONSchema;
53 };
54 patternProperties?: {
55 [k: string]: NormalizedJSONSchema;
56 };
57 dependencies?: {
58 [k: string]: NormalizedJSONSchema | string[];
59 };
60 allOf?: NormalizedJSONSchema[];
61 anyOf?: NormalizedJSONSchema[];
62 oneOf?: NormalizedJSONSchema[];
63 not?: NormalizedJSONSchema;
64 required: string[];
65}
66export interface EnumJSONSchema extends NormalizedJSONSchema {
67 enum: any[];
68}
69export interface NamedEnumJSONSchema extends NormalizedJSONSchema {
70 tsEnumNames: string[];
71}
72export interface SchemaSchema extends NormalizedJSONSchema {
73 properties: {
74 [k: string]: NormalizedJSONSchema;
75 };
76 required: string[];
77}
78export interface JSONSchemaWithDefinitions extends NormalizedJSONSchema {
79 definitions: {
80 [k: string]: NormalizedJSONSchema;
81 };
82}
83export interface CustomTypeJSONSchema extends NormalizedJSONSchema {
84 tsType: string;
85}
86export declare const getRootSchema: ((schema: LinkedJSONSchema) => LinkedJSONSchema) & import("lodash").MemoizedFunction;
87export declare function isPrimitive(schema: LinkedJSONSchema | JSONSchemaType): schema is JSONSchemaType;
88export declare function isCompound(schema: JSONSchema): boolean;
89
\No newline at end of file