jsonSchema.ts 2.3 KB
Newer Older
E
Erich Gamma 已提交
1 2 3 4 5 6
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

export interface IJSONSchema {
7
	id?: string;
8
	$id?: string;
E
Erich Gamma 已提交
9
	$schema?: string;
10 11 12 13 14
	type?: string | string[];
	title?: string;
	default?: any;
	definitions?: IJSONSchemaMap;
	description?: string;
E
Erich Gamma 已提交
15
	properties?: IJSONSchemaMap;
16 17 18 19
	patternProperties?: IJSONSchemaMap;
	additionalProperties?: boolean | IJSONSchema;
	minProperties?: number;
	maxProperties?: number;
20
	dependencies?: IJSONSchemaMap | { [prop: string]: string[] };
21 22 23 24
	items?: IJSONSchema | IJSONSchema[];
	minItems?: number;
	maxItems?: number;
	uniqueItems?: boolean;
25
	additionalItems?: boolean | IJSONSchema;
26 27 28 29 30
	pattern?: string;
	minLength?: number;
	maxLength?: number;
	minimum?: number;
	maximum?: number;
31 32
	exclusiveMinimum?: boolean | number;
	exclusiveMaximum?: boolean | number;
33 34 35 36 37 38 39 40
	multipleOf?: number;
	required?: string[];
	$ref?: string;
	anyOf?: IJSONSchema[];
	allOf?: IJSONSchema[];
	oneOf?: IJSONSchema[];
	not?: IJSONSchema;
	enum?: any[];
E
Erich Gamma 已提交
41
	format?: string;
42

43 44 45 46 47
	// schema draft 06
	const?: any;
	contains?: IJSONSchema;
	propertyNames?: IJSONSchema;

48 49 50 51 52 53
	// schema draft 07
	$comment?: string;
	if?: IJSONSchema;
	then?: IJSONSchema;
	else?: IJSONSchema;

54
	// VSCode extensions
I
isidor 已提交
55
	defaultSnippets?: IJSONSchemaSnippet[]; // VSCode extension
56
	errorMessage?: string; // VSCode extension
57
	patternErrorMessage?: string; // VSCode extension
58 59
	deprecationMessage?: string; // VSCode extension
	enumDescriptions?: string[]; // VSCode extension
60 61
	markdownEnumDescriptions?: string[]; // VSCode extension
	markdownDescription?: string; // VSCode extension
62
	doNotSuggest?: boolean; // VSCode extension
63
	allowComments?: boolean; // VSCode extension
64
	allowsTrailingCommas?: boolean; // VSCode extension
E
Erich Gamma 已提交
65 66 67
}

export interface IJSONSchemaMap {
J
Johannes Rieken 已提交
68
	[name: string]: IJSONSchema;
E
Erich Gamma 已提交
69
}
I
isidor 已提交
70 71 72 73

export interface IJSONSchemaSnippet {
	label?: string;
	description?: string;
74 75
	body?: any; // a object that will be JSON stringified
	bodyText?: string; // an already stringified JSON object that can contain new lines (\n) and tabs (\t)
I
isidor 已提交
76
}