Skip to content

Commit 6f13bd4

Browse files
DarhkVoydmabagoury
authored andcommitted
update keywords and schema for hover provider tools
Co-Authored-By: mabagoury <[email protected]>
1 parent a214996 commit 6f13bd4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+1179
-304
lines changed

draft-04/additionalItems.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,6 @@ const collectEvaluatedItems = (keywordValue, instance, ast, dynamicAnchors) => {
3939
return evaluatedIndexes;
4040
};
4141

42-
export default { id, compile, interpret, collectEvaluatedItems };
42+
const description = "If items is set to an array of schemas, validation succeeds if each element of the instance not covered by it validates against this schema.";
43+
44+
export default { id, compile, interpret, collectEvaluatedItems, description };

draft-04/dependencies.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,6 @@ const interpret = (dependencies, instance, ast, dynamicAnchors, quiet) => {
3131
});
3232
};
3333

34-
export default { id, compile, interpret };
34+
const description = "If the object values are objects, this keyword specifies subschemas that are evaluated if the instance is an object and contains a certain property. If the object values are arrays, validation succeeds if, for each name that appears in both the instance and as a name within this keyword’s value, every item in the corresponding array is also the name of a property in the instance.";
35+
36+
export default { id, compile, interpret, description };

draft-04/exclusiveMaximum.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const id = "https://json-schema.org/keyword/draft-04/exclusiveMaximum";
22
const compile = (schema) => schema.value;
33
const interpret = () => true;
4+
const description = "Modifies the maximum keyword to succeed if the numberic instance is less than, but not equal to, the given number";
45

5-
export default { id, compile, interpret };
6+
export default { id, compile, interpret, description };

draft-04/exclusiveMinimum.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const id = "https://json-schema.org/keyword/draft-04/exclusiveMinimum";
22
const compile = (schema) => schema.value;
33
const interpret = () => true;
4+
const description = "Modifies the minimum keyword to succeed if the numberic instance is greater than, but not equal to, the given number";
45

5-
export default { id, compile, interpret };
6+
export default { id, compile, interpret, description };

draft-04/id.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
export default { id: "https://json-schema.org/keyword/draft-04/id" };
1+
export default {
2+
id: "https://json-schema.org/keyword/draft-04/id",
3+
description: "This keyword declares an identifier for the schema resource or a local anchor."
4+
};

draft-04/items.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,6 @@ const collectEvaluatedItems = (items, instance, ast, dynamicAnchors) => {
4040
: collectSet(range(0, items.length)));
4141
};
4242

43-
export default { id, compile, interpret, collectEvaluatedItems };
43+
const description = "If set to a schema, validation succeeds if each element of the instance validates against it, otherwise validation succeeds if each element of the instance validates against the schema at the same position, if any.";
44+
45+
export default { id, compile, interpret, collectEvaluatedItems, description };

draft-04/maximum.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@ const interpret = ([maximum, isExclusive], instance) => {
2222
return isExclusive ? value < maximum : value <= maximum;
2323
};
2424

25-
export default { id, compile, interpret };
25+
const description = "Validation succeeds if the numeric instance is less than or equal to the given number. The behavior of this keyword is modified by the exclusiveMaximum keyword.";
26+
27+
export default { id, compile, interpret, description };

draft-04/minimum.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@ const interpret = ([minimum, isExclusive], instance) => {
2222
return isExclusive ? value > minimum : value >= minimum;
2323
};
2424

25-
export default { id, compile, interpret };
25+
const description = "Validation succeeds if the numeric instance is greater than or equal to the given number. The behavior of this keyword is modified by the exclusiveMinimum keyword.";
26+
27+
export default { id, compile, interpret, description };

draft-04/ref.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
export default { id: "https://json-schema.org/keyword/draft-04/ref" };
1+
export default {
2+
id: "https://json-schema.org/keyword/draft-04/ref",
3+
description: "This keyword is used to reference a statically identified schema."
4+
};

draft-04/schema.js

Lines changed: 127 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,37 @@
1+
import id from "../draft-04/id.js";
2+
import title from "../lib/keywords/title.js";
3+
import description from "../lib/keywords/description.js";
4+
import _default from "../lib/keywords/default.js";
5+
import multipleOf from "../lib/keywords/multipleOf.js";
6+
import maximum from "./maximum.js";
7+
import exclusiveMaximum from "./exclusiveMaximum.js";
8+
import minimum from "./minimum.js";
9+
import exclusiveMinimum from "./exclusiveMinimum.js";
10+
import maxLength from "../lib/keywords/maxLength.js";
11+
import minLength from "../lib/keywords/minLength.js";
12+
import pattern from "../lib/keywords/pattern.js";
13+
import additionalItems from "./additionalItems.js";
14+
import items from "./items.js";
15+
import maxItems from "../lib/keywords/maxItems.js";
16+
import minItems from "../lib/keywords/minItems.js";
17+
import uniqueItems from "../lib/keywords/uniqueItems.js";
18+
import maxProperties from "../lib/keywords/maxProperties.js";
19+
import minProperties from "../lib/keywords/minProperties.js";
20+
import required from "../lib/keywords/required.js";
21+
import additionalProperties from "../lib/keywords/additionalProperties.js";
22+
import definitions from "../lib/keywords/definitions.js";
23+
import properties from "../lib/keywords/properties.js";
24+
import patternProperties from "../lib/keywords/patternProperties.js";
25+
import dependencies from "./dependencies.js";
26+
import _enum from "../lib/keywords/enum.js";
27+
import type from "../lib/keywords/type.js";
28+
import format from "../lib/keywords/format.js";
29+
import allOf from "../lib/keywords/allOf.js";
30+
import anyOf from "../lib/keywords/anyOf.js";
31+
import oneOf from "../lib/keywords/oneOf.js";
32+
import not from "../lib/keywords/not.js";
33+
34+
135
export default {
236
"id": "http://json-schema.org/draft-04/schema#",
337
"$schema": "http://json-schema.org/draft-04/schema#",
@@ -28,87 +62,132 @@ export default {
2862
"type": "object",
2963
"properties": {
3064
"id": {
31-
"type": "string"
65+
"type": "string",
66+
"description": id.description
3267
},
3368
"$schema": {
34-
"type": "string"
69+
"type": "string",
70+
"description": `This keyword is both used as a JSON Schema dialect \
71+
identifier and as a reference to a JSON Schema which describes the set \
72+
of valid schemas written for this particular dialect.`
3573
},
3674
"title": {
37-
"type": "string"
75+
"type": "string",
76+
"description": title.description
3877
},
3978
"description": {
40-
"type": "string"
79+
"type": "string",
80+
"description": description.description
81+
},
82+
"default": {
83+
"description": _default.description
4184
},
42-
"default": {},
4385
"multipleOf": {
4486
"type": "number",
4587
"minimum": 0,
46-
"exclusiveMinimum": true
88+
"exclusiveMinimum": true,
89+
"description": multipleOf.description
4790
},
4891
"maximum": {
49-
"type": "number"
92+
"type": "number",
93+
"description": maximum.description
5094
},
5195
"exclusiveMaximum": {
5296
"type": "boolean",
53-
"default": false
97+
"default": false,
98+
"description": exclusiveMaximum.description
5499
},
55100
"minimum": {
56-
"type": "number"
101+
"type": "number",
102+
"description": minimum.description
57103
},
58104
"exclusiveMinimum": {
59105
"type": "boolean",
60-
"default": false
106+
"default": false,
107+
"description": exclusiveMinimum.description
108+
},
109+
"maxLength": {
110+
"allOf": [{ "$ref": "#/definitions/positiveInteger" }],
111+
"description": maxLength.description
112+
},
113+
"minLength": {
114+
"allOf": [{ "$ref": "#/definitions/positiveIntegerDefault0" }],
115+
"description": minLength.description
61116
},
62-
"maxLength": { "$ref": "#/definitions/positiveInteger" },
63-
"minLength": { "$ref": "#/definitions/positiveIntegerDefault0" },
64117
"pattern": {
65118
"type": "string",
66-
"format": "regex"
119+
"format": "regex",
120+
"description": pattern.description
67121
},
68122
"additionalItems": {
69123
"anyOf": [
70124
{ "type": "boolean" },
71125
{ "$ref": "#" }
72126
],
73-
"default": {}
127+
"default": {},
128+
"description": additionalItems.description
74129
},
75130
"items": {
76131
"anyOf": [
77132
{ "$ref": "#" },
78133
{ "$ref": "#/definitions/schemaArray" }
79134
],
80-
"default": {}
135+
"default": {},
136+
"description": items.description
137+
},
138+
"maxItems": {
139+
"allOf": [{ "$ref": "#/definitions/positiveInteger" }],
140+
"description": maxItems.description
141+
},
142+
"minItems": {
143+
"allOf": [{ "$ref": "#/definitions/positiveIntegerDefault0" }],
144+
"description": minItems.description
81145
},
82-
"maxItems": { "$ref": "#/definitions/positiveInteger" },
83-
"minItems": { "$ref": "#/definitions/positiveIntegerDefault0" },
84146
"uniqueItems": {
85147
"type": "boolean",
86-
"default": false
148+
"default": false,
149+
"description": uniqueItems.description
150+
},
151+
"maxProperties": {
152+
"allOf": [
153+
{ "$ref": "#/definitions/positiveIntegerDefault0" },
154+
{ "$ref": "#/definitions/positiveInteger" }
155+
],
156+
"description": maxProperties.description
157+
},
158+
"minProperties": {
159+
"allOf": [{ "$ref": "#/definitions/positiveIntegerDefault0" }],
160+
"description": minProperties.description
161+
},
162+
"required": {
163+
"allOf": [{ "$ref": "#/definitions/stringArray" }],
164+
"description": required.description
87165
},
88-
"maxProperties": { "$ref": "#/definitions/positiveInteger" },
89-
"minProperties": { "$ref": "#/definitions/positiveIntegerDefault0" },
90-
"required": { "$ref": "#/definitions/stringArray" },
91166
"additionalProperties": {
92167
"anyOf": [
93168
{ "type": "boolean" },
94169
{ "$ref": "#" }
95170
],
96-
"default": {}
171+
"default": {},
172+
"description": additionalProperties.description
97173
},
98174
"definitions": {
99175
"type": "object",
100176
"additionalProperties": { "$ref": "#" },
101-
"default": {}
177+
"default": {},
178+
"description": definitions.description
102179
},
103180
"properties": {
104181
"type": "object",
105182
"additionalProperties": { "$ref": "#" },
106-
"default": {}
183+
"default": {},
184+
"description": properties.description
107185
},
108186
"patternProperties": {
109187
"type": "object",
110188
"additionalProperties": { "$ref": "#" },
111-
"default": {}
189+
"default": {},
190+
"description": patternProperties.description
112191
},
113192
"dependencies": {
114193
"type": "object",
@@ -117,12 +196,14 @@ export default {
117196
{ "$ref": "#" },
118197
{ "$ref": "#/definitions/stringArray" }
119198
]
120-
}
199+
},
200+
"description": dependencies.description
121201
},
122202
"enum": {
123203
"type": "array",
124204
"minItems": 1,
125-
"uniqueItems": true
205+
"uniqueItems": true,
206+
"description": _enum.description
126207
},
127208
"type": {
128209
"anyOf": [
@@ -133,13 +214,26 @@ export default {
133214
"minItems": 1,
134215
"uniqueItems": true
135216
}
136-
]
217+
],
218+
"description": type.description
219+
},
220+
"format": { "type": "string", "description": format.description },
221+
"allOf": {
222+
"allOf": [{ "$ref": "#/definitions/schemaArray" }],
223+
"description": allOf.description
224+
},
225+
"anyOf": {
226+
"allOf": [{ "$ref": "#/definitions/schemaArray" }],
227+
"description": anyOf.description
137228
},
138-
"format": { "type": "string" },
139-
"allOf": { "$ref": "#/definitions/schemaArray" },
140-
"anyOf": { "$ref": "#/definitions/schemaArray" },
141-
"oneOf": { "$ref": "#/definitions/schemaArray" },
142-
"not": { "$ref": "#" }
229+
"oneOf": {
230+
"allOf": [{ "$ref": "#/definitions/schemaArray" }],
231+
"description": oneOf.description
232+
},
233+
"not": {
234+
"allOf": [{ "$ref": "#" }],
235+
"description": not.description
236+
}
143237
},
144238
"dependencies": {
145239
"exclusiveMaximum": ["maximum"],

draft-06/contains.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ const interpret = (contains, instance, ast, dynamicAnchors, quiet) => {
1111
return Instance.typeOf(instance) !== "array" || some((item) => Validation.interpret(contains, item, ast, dynamicAnchors, quiet), Instance.iter(instance));
1212
};
1313

14-
export default { id, compile, interpret };
14+
const description = "Validation succeeds if the instance contains an element that validates against this schema.";
15+
16+
export default { id, compile, interpret, description };

0 commit comments

Comments
 (0)