forked from metaphacts/typescript-json-schema
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypescript-json-schema.d.ts
92 lines (92 loc) · 3.37 KB
/
typescript-json-schema.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import * as ts from "typescript";
export declare function getDefaultArgs(): Args;
export declare type ValidationKeywords = {
[prop: string]: boolean;
};
export declare type Args = {
useRef: boolean;
useTypeAliasRef: boolean;
useRootRef: boolean;
useTitle: boolean;
useDefaultProperties: boolean;
disableExtraProperties: boolean;
usePropertyOrder: boolean;
useTypeOfKeyword: boolean;
generateRequired: boolean;
strictNullChecks: boolean;
ignoreErrors: boolean;
out: string;
validationKeywords: string[];
};
export declare type PartialArgs = Partial<Args>;
export declare type PrimitiveType = number | boolean | string | null;
export declare type Definition = {
$ref?: string;
description?: string;
allOf?: Definition[];
oneOf?: Definition[];
anyOf?: Definition[];
title?: string;
type?: string | string[];
definitions?: {
[key: string]: any;
};
format?: string;
items?: Definition;
minItems?: number;
additionalItems?: {
anyOf: Definition;
};
enum?: PrimitiveType[] | Definition[];
default?: PrimitiveType | Object;
additionalProperties?: Definition;
required?: string[];
propertyOrder?: string[];
properties?: {};
defaultProperties?: string[];
typeof?: "function";
};
export declare class JsonSchemaGenerator {
private args;
private static validationKeywords;
private allSymbols;
private userSymbols;
private inheritingTypes;
private tc;
private reffedDefinitions;
private userValidationKeywords;
constructor(allSymbols: {
[name: string]: ts.Type;
}, userSymbols: {
[name: string]: ts.Type;
}, inheritingTypes: {
[baseName: string]: string[];
}, tc: ts.TypeChecker, args?: Args);
readonly ReffedDefinitions: {
[key: string]: Definition;
};
private parseValue(value);
private parseCommentsIntoDefinition(symbol, definition, otherAnnotations);
private extractLiteralValue(typ);
private resolveTupleType(propertyType);
private getDefinitionForRootType(propertyType, tc, reffedType, definition);
private getReferencedTypeSymbol(prop, tc);
private getDefinitionForProperty(prop, tc, node);
private getEnumDefinition(clazzType, tc, definition);
private getUnionDefinition(unionType, prop, tc, unionModifier, definition);
private getClassDefinition(clazzType, tc, definition);
private simpleTypesAllowedProperties;
private addSimpleType(def, type);
private makeNullable(def);
private getTypeDefinition(typ, tc, asRef?, unionModifier?, prop?, reffedType?);
setSchemaOverride(symbolName: string, schema: Definition): void;
getSchemaForSymbol(symbolName: string, includeReffedDefinitions?: boolean): Definition;
getSchemaForSymbols(symbols: string[]): Definition;
getUserSymbols(): string[];
}
export declare function getProgramFromFiles(files: string[], compilerOptions?: ts.CompilerOptions): ts.Program;
export declare function buildGenerator(program: ts.Program, args?: PartialArgs): JsonSchemaGenerator | null;
export declare function generateSchema(program: ts.Program, fullTypeName: string, args?: PartialArgs): Definition | null;
export declare function programFromConfig(configFileName: string): ts.Program;
export declare function exec(filePattern: string, fullTypeName: string, args?: Args): void;
export declare function run(): void;