Skip to content

Commit

Permalink
update keywords and schema for hover provider tools
Browse files Browse the repository at this point in the history
Co-Authored-By: mabagoury <wnajsksos@gmail.com>
  • Loading branch information
2 people authored and jdesrosiers committed Jul 1, 2024
1 parent 3df05e7 commit cafff20
Show file tree
Hide file tree
Showing 86 changed files with 1,179 additions and 304 deletions.
4 changes: 3 additions & 1 deletion draft-04/additionalItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@ const collectEvaluatedItems = (keywordValue, instance, ast, dynamicAnchors) => {
return evaluatedIndexes;
};

export default { id, compile, interpret, collectEvaluatedItems };
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.";

export default { id, compile, interpret, collectEvaluatedItems, description };
4 changes: 3 additions & 1 deletion draft-04/dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ const interpret = (dependencies, instance, ast, dynamicAnchors, quiet) => {
});
};

export default { id, compile, interpret };
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.";

export default { id, compile, interpret, description };
3 changes: 2 additions & 1 deletion draft-04/exclusiveMaximum.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const id = "https://json-schema.org/keyword/draft-04/exclusiveMaximum";
const compile = (schema) => schema.value;
const interpret = () => true;
const description = "Modifies the maximum keyword to succeed if the numberic instance is less than, but not equal to, the given number";

export default { id, compile, interpret };
export default { id, compile, interpret, description };
3 changes: 2 additions & 1 deletion draft-04/exclusiveMinimum.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const id = "https://json-schema.org/keyword/draft-04/exclusiveMinimum";
const compile = (schema) => schema.value;
const interpret = () => true;
const description = "Modifies the minimum keyword to succeed if the numberic instance is greater than, but not equal to, the given number";

export default { id, compile, interpret };
export default { id, compile, interpret, description };
5 changes: 4 additions & 1 deletion draft-04/id.js
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
export default { id: "https://json-schema.org/keyword/draft-04/id" };
export default {
id: "https://json-schema.org/keyword/draft-04/id",
description: "This keyword declares an identifier for the schema resource or a local anchor."
};
4 changes: 3 additions & 1 deletion draft-04/items.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ const collectEvaluatedItems = (items, instance, ast, dynamicAnchors) => {
: collectSet(range(0, items.length)));
};

export default { id, compile, interpret, collectEvaluatedItems };
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.";

export default { id, compile, interpret, collectEvaluatedItems, description };
4 changes: 3 additions & 1 deletion draft-04/maximum.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ const interpret = ([maximum, isExclusive], instance) => {
return isExclusive ? value < maximum : value <= maximum;
};

export default { id, compile, interpret };
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.";

export default { id, compile, interpret, description };
4 changes: 3 additions & 1 deletion draft-04/minimum.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ const interpret = ([minimum, isExclusive], instance) => {
return isExclusive ? value > minimum : value >= minimum;
};

export default { id, compile, interpret };
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.";

export default { id, compile, interpret, description };
5 changes: 4 additions & 1 deletion draft-04/ref.js
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
export default { id: "https://json-schema.org/keyword/draft-04/ref" };
export default {
id: "https://json-schema.org/keyword/draft-04/ref",
description: "This keyword is used to reference a statically identified schema."
};
160 changes: 127 additions & 33 deletions draft-04/schema.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
import id from "../draft-04/id.js";
import title from "../lib/keywords/title.js";
import description from "../lib/keywords/description.js";
import _default from "../lib/keywords/default.js";
import multipleOf from "../lib/keywords/multipleOf.js";
import maximum from "./maximum.js";
import exclusiveMaximum from "./exclusiveMaximum.js";
import minimum from "./minimum.js";
import exclusiveMinimum from "./exclusiveMinimum.js";
import maxLength from "../lib/keywords/maxLength.js";
import minLength from "../lib/keywords/minLength.js";
import pattern from "../lib/keywords/pattern.js";
import additionalItems from "./additionalItems.js";
import items from "./items.js";
import maxItems from "../lib/keywords/maxItems.js";
import minItems from "../lib/keywords/minItems.js";
import uniqueItems from "../lib/keywords/uniqueItems.js";
import maxProperties from "../lib/keywords/maxProperties.js";
import minProperties from "../lib/keywords/minProperties.js";
import required from "../lib/keywords/required.js";
import additionalProperties from "../lib/keywords/additionalProperties.js";
import definitions from "../lib/keywords/definitions.js";
import properties from "../lib/keywords/properties.js";
import patternProperties from "../lib/keywords/patternProperties.js";
import dependencies from "./dependencies.js";
import _enum from "../lib/keywords/enum.js";
import type from "../lib/keywords/type.js";
import format from "../lib/keywords/format.js";
import allOf from "../lib/keywords/allOf.js";
import anyOf from "../lib/keywords/anyOf.js";
import oneOf from "../lib/keywords/oneOf.js";
import not from "../lib/keywords/not.js";


export default {
"id": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-04/schema#",
Expand Down Expand Up @@ -28,87 +62,132 @@ export default {
"type": "object",
"properties": {
"id": {
"type": "string"
"type": "string",
"description": id.description
},
"$schema": {
"type": "string"
"type": "string",
"description": `This keyword is both used as a JSON Schema dialect \
identifier and as a reference to a JSON Schema which describes the set \
of valid schemas written for this particular dialect.`
},
"title": {
"type": "string"
"type": "string",
"description": title.description
},
"description": {
"type": "string"
"type": "string",
"description": description.description
},
"default": {
"description": _default.description
},
"default": {},
"multipleOf": {
"type": "number",
"minimum": 0,
"exclusiveMinimum": true
"exclusiveMinimum": true,
"description": multipleOf.description
},
"maximum": {
"type": "number"
"type": "number",
"description": maximum.description
},
"exclusiveMaximum": {
"type": "boolean",
"default": false
"default": false,
"description": exclusiveMaximum.description
},
"minimum": {
"type": "number"
"type": "number",
"description": minimum.description
},
"exclusiveMinimum": {
"type": "boolean",
"default": false
"default": false,
"description": exclusiveMinimum.description
},
"maxLength": {
"allOf": [{ "$ref": "#/definitions/positiveInteger" }],
"description": maxLength.description
},
"minLength": {
"allOf": [{ "$ref": "#/definitions/positiveIntegerDefault0" }],
"description": minLength.description
},
"maxLength": { "$ref": "#/definitions/positiveInteger" },
"minLength": { "$ref": "#/definitions/positiveIntegerDefault0" },
"pattern": {
"type": "string",
"format": "regex"
"format": "regex",
"description": pattern.description
},
"additionalItems": {
"anyOf": [
{ "type": "boolean" },
{ "$ref": "#" }
],
"default": {}
"default": {},
"description": additionalItems.description
},
"items": {
"anyOf": [
{ "$ref": "#" },
{ "$ref": "#/definitions/schemaArray" }
],
"default": {}
"default": {},
"description": items.description
},
"maxItems": {
"allOf": [{ "$ref": "#/definitions/positiveInteger" }],
"description": maxItems.description
},
"minItems": {
"allOf": [{ "$ref": "#/definitions/positiveIntegerDefault0" }],
"description": minItems.description
},
"maxItems": { "$ref": "#/definitions/positiveInteger" },
"minItems": { "$ref": "#/definitions/positiveIntegerDefault0" },
"uniqueItems": {
"type": "boolean",
"default": false
"default": false,
"description": uniqueItems.description
},
"maxProperties": {
"allOf": [
{ "$ref": "#/definitions/positiveIntegerDefault0" },
{ "$ref": "#/definitions/positiveInteger" }
],
"description": maxProperties.description
},
"minProperties": {
"allOf": [{ "$ref": "#/definitions/positiveIntegerDefault0" }],
"description": minProperties.description
},
"required": {
"allOf": [{ "$ref": "#/definitions/stringArray" }],
"description": required.description
},
"maxProperties": { "$ref": "#/definitions/positiveInteger" },
"minProperties": { "$ref": "#/definitions/positiveIntegerDefault0" },
"required": { "$ref": "#/definitions/stringArray" },
"additionalProperties": {
"anyOf": [
{ "type": "boolean" },
{ "$ref": "#" }
],
"default": {}
"default": {},
"description": additionalProperties.description
},
"definitions": {
"type": "object",
"additionalProperties": { "$ref": "#" },
"default": {}
"default": {},
"description": definitions.description
},
"properties": {
"type": "object",
"additionalProperties": { "$ref": "#" },
"default": {}
"default": {},
"description": properties.description
},
"patternProperties": {
"type": "object",
"additionalProperties": { "$ref": "#" },
"default": {}
"default": {},
"description": patternProperties.description
},
"dependencies": {
"type": "object",
Expand All @@ -117,12 +196,14 @@ export default {
{ "$ref": "#" },
{ "$ref": "#/definitions/stringArray" }
]
}
},
"description": dependencies.description
},
"enum": {
"type": "array",
"minItems": 1,
"uniqueItems": true
"uniqueItems": true,
"description": _enum.description
},
"type": {
"anyOf": [
Expand All @@ -133,13 +214,26 @@ export default {
"minItems": 1,
"uniqueItems": true
}
]
],
"description": type.description
},
"format": { "type": "string", "description": format.description },
"allOf": {
"allOf": [{ "$ref": "#/definitions/schemaArray" }],
"description": allOf.description
},
"anyOf": {
"allOf": [{ "$ref": "#/definitions/schemaArray" }],
"description": anyOf.description
},
"format": { "type": "string" },
"allOf": { "$ref": "#/definitions/schemaArray" },
"anyOf": { "$ref": "#/definitions/schemaArray" },
"oneOf": { "$ref": "#/definitions/schemaArray" },
"not": { "$ref": "#" }
"oneOf": {
"allOf": [{ "$ref": "#/definitions/schemaArray" }],
"description": oneOf.description
},
"not": {
"allOf": [{ "$ref": "#" }],
"description": not.description
}
},
"dependencies": {
"exclusiveMaximum": ["maximum"],
Expand Down
4 changes: 3 additions & 1 deletion draft-06/contains.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ const interpret = (contains, instance, ast, dynamicAnchors, quiet) => {
return Instance.typeOf(instance) !== "array" || some((item) => Validation.interpret(contains, item, ast, dynamicAnchors, quiet), Instance.iter(instance));
};

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

export default { id, compile, interpret, description };
Loading

0 comments on commit cafff20

Please sign in to comment.