-
Notifications
You must be signed in to change notification settings - Fork 208
/
JsonSchema.ts
92 lines (83 loc) · 2.61 KB
/
JsonSchema.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
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
* @module Json
*/
// adapted from https://github.com/microsoft/vscode Copyright (c) 2015 - present Microsoft Corporation
/** @public */
export type JSONSchemaTypeName = "string" | "number" | "integer" | "boolean" | "null" | "array" | "object";
/** @public */
export type JSONSchemaType = string | number | boolean | object | JSONSchemaType[];
/** @public */
export interface JSONSchema {
id?: string;
$id?: string;
$schema?: string;
type?: JSONSchemaTypeName | JSONSchemaTypeName[];
title?: string;
default?: JSONSchemaType;
definitions?: JSONSchemaMap;
description?: string;
properties?: JSONSchemaMap;
patternProperties?: JSONSchemaMap;
additionalProperties?: boolean | JSONSchema;
minProperties?: number;
maxProperties?: number;
dependencies?: JSONSchemaMap | { [prop: string]: string[] };
items?: JSONSchema | JSONSchema[];
minItems?: number;
maxItems?: number;
uniqueItems?: boolean;
additionalItems?: boolean | JSONSchema;
pattern?: string;
minLength?: number;
maxLength?: number;
minimum?: number;
maximum?: number;
exclusiveMinimum?: boolean | number;
exclusiveMaximum?: boolean | number;
multipleOf?: number;
required?: string[];
$ref?: string;
anyOf?: JSONSchema[];
allOf?: JSONSchema[];
oneOf?: JSONSchema[];
not?: JSONSchema;
enum?: JSONSchemaType[];
format?: string;
// schema draft 06
const?: any;
contains?: JSONSchema;
propertyNames?: JSONSchema;
// schema draft 07
$comment?: string;
if?: JSONSchema;
then?: JSONSchema;
else?: JSONSchema;
// VS Code extensions
defaultSnippets?: JSONSchemaSnippet[];
errorMessage?: string;
patternErrorMessage?: string;
deprecationMessage?: string;
markdownDeprecationMessage?: string;
enumDescriptions?: string[];
markdownEnumDescriptions?: string[];
markdownDescription?: string;
doNotSuggest?: boolean;
suggestSortText?: string;
allowComments?: boolean;
allowTrailingCommas?: boolean;
}
/** @public */
export interface JSONSchemaMap {
[name: string]: JSONSchema;
}
/** @public */
export interface JSONSchemaSnippet {
label?: string;
description?: string;
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)
}