From cafff201c7ef2934484dd63e2ef7e89157ddff1e Mon Sep 17 00:00:00 2001 From: D V Date: Mon, 8 Apr 2024 18:11:52 +0530 Subject: [PATCH] update keywords and schema for hover provider tools Co-Authored-By: mabagoury --- draft-04/additionalItems.js | 4 +- draft-04/dependencies.js | 4 +- draft-04/exclusiveMaximum.js | 3 +- draft-04/exclusiveMinimum.js | 3 +- draft-04/id.js | 5 +- draft-04/items.js | 4 +- draft-04/maximum.js | 4 +- draft-04/minimum.js | 4 +- draft-04/ref.js | 5 +- draft-04/schema.js | 160 ++++++++++++---- draft-06/contains.js | 4 +- draft-06/schema.js | 189 +++++++++++++++---- draft-07/schema.js | 231 +++++++++++++++++++----- draft-2019-09/meta/applicator.js | 98 ++++++++-- draft-2019-09/meta/content.js | 20 +- draft-2019-09/meta/core.js | 39 +++- draft-2019-09/meta/format.js | 8 +- draft-2019-09/meta/meta-data.js | 31 +++- draft-2019-09/meta/validation.js | 101 ++++++++--- draft-2019-09/recursiveAnchor.js | 5 +- draft-2020-12/dynamicAnchor.js | 9 +- draft-2020-12/dynamicRef.js | 8 +- draft-2020-12/meta/applicator.js | 88 +++++++-- draft-2020-12/meta/content.js | 20 +- draft-2020-12/meta/core.js | 35 +++- draft-2020-12/meta/format-annotation.js | 8 +- draft-2020-12/meta/format-assertion.js | 8 +- draft-2020-12/meta/meta-data.js | 31 +++- draft-2020-12/meta/unevaluated.js | 14 +- draft-2020-12/meta/validation.js | 99 ++++++++-- lib/keywords/additionalProperties.js | 4 +- lib/keywords/allOf.js | 4 +- lib/keywords/anchor.js | 6 +- lib/keywords/anyOf.js | 4 +- lib/keywords/comment.js | 6 +- lib/keywords/const.js | 4 +- lib/keywords/contains.js | 4 +- lib/keywords/contentEncoding.js | 4 +- lib/keywords/contentMediaType.js | 4 +- lib/keywords/contentSchema.js | 4 +- lib/keywords/default.js | 4 +- lib/keywords/definitions.js | 7 +- lib/keywords/dependentRequired.js | 4 +- lib/keywords/dependentSchemas.js | 4 +- lib/keywords/deprecated.js | 4 +- lib/keywords/description.js | 4 +- lib/keywords/dynamicAnchor.js | 7 +- lib/keywords/dynamicRef.js | 4 +- lib/keywords/else.js | 5 +- lib/keywords/enum.js | 4 +- lib/keywords/examples.js | 4 +- lib/keywords/exclusiveMaximum.js | 4 +- lib/keywords/exclusiveMinimum.js | 4 +- lib/keywords/format.js | 4 +- lib/keywords/id.js | 5 +- lib/keywords/if.js | 3 +- lib/keywords/items.js | 4 +- lib/keywords/maxContains.js | 5 +- lib/keywords/maxItems.js | 4 +- lib/keywords/maxLength.js | 4 +- lib/keywords/maxProperties.js | 4 +- lib/keywords/maximum.js | 4 +- lib/keywords/minContains.js | 5 +- lib/keywords/minItems.js | 4 +- lib/keywords/minLength.js | 4 +- lib/keywords/minProperties.js | 4 +- lib/keywords/minimum.js | 4 +- lib/keywords/multipleOf.js | 4 +- lib/keywords/not.js | 4 +- lib/keywords/oneOf.js | 4 +- lib/keywords/pattern.js | 4 +- lib/keywords/patternProperties.js | 6 +- lib/keywords/prefixItems.js | 4 +- lib/keywords/properties.js | 5 +- lib/keywords/propertyNames.js | 3 +- lib/keywords/readOnly.js | 4 +- lib/keywords/ref.js | 3 +- lib/keywords/required.js | 4 +- lib/keywords/then.js | 5 +- lib/keywords/title.js | 4 +- lib/keywords/type.js | 4 +- lib/keywords/unevaluatedItems.js | 4 +- lib/keywords/unevaluatedProperties.js | 4 +- lib/keywords/uniqueItems.js | 4 +- lib/keywords/vocabulary.js | 6 +- lib/keywords/writeOnly.js | 4 +- 86 files changed, 1179 insertions(+), 304 deletions(-) diff --git a/draft-04/additionalItems.js b/draft-04/additionalItems.js index e852ef0c..29baabff 100644 --- a/draft-04/additionalItems.js +++ b/draft-04/additionalItems.js @@ -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 }; diff --git a/draft-04/dependencies.js b/draft-04/dependencies.js index 73f8c4d8..a743a5f9 100644 --- a/draft-04/dependencies.js +++ b/draft-04/dependencies.js @@ -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 }; diff --git a/draft-04/exclusiveMaximum.js b/draft-04/exclusiveMaximum.js index 5acd1aa0..762cf1c0 100644 --- a/draft-04/exclusiveMaximum.js +++ b/draft-04/exclusiveMaximum.js @@ -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 }; diff --git a/draft-04/exclusiveMinimum.js b/draft-04/exclusiveMinimum.js index 26e00941..31c54767 100644 --- a/draft-04/exclusiveMinimum.js +++ b/draft-04/exclusiveMinimum.js @@ -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 }; diff --git a/draft-04/id.js b/draft-04/id.js index b5f6df1b..92b23a6f 100644 --- a/draft-04/id.js +++ b/draft-04/id.js @@ -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." +}; diff --git a/draft-04/items.js b/draft-04/items.js index 5d9e366d..e10c858e 100644 --- a/draft-04/items.js +++ b/draft-04/items.js @@ -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 }; diff --git a/draft-04/maximum.js b/draft-04/maximum.js index a2a889ce..693688c1 100644 --- a/draft-04/maximum.js +++ b/draft-04/maximum.js @@ -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 }; diff --git a/draft-04/minimum.js b/draft-04/minimum.js index c0146aba..66fd0a6c 100644 --- a/draft-04/minimum.js +++ b/draft-04/minimum.js @@ -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 }; diff --git a/draft-04/ref.js b/draft-04/ref.js index 5e714c50..c3371420 100644 --- a/draft-04/ref.js +++ b/draft-04/ref.js @@ -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." +}; diff --git a/draft-04/schema.js b/draft-04/schema.js index 130d72f4..deb4994d 100644 --- a/draft-04/schema.js +++ b/draft-04/schema.js @@ -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#", @@ -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", @@ -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": [ @@ -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"], diff --git a/draft-06/contains.js b/draft-06/contains.js index bb185808..1677aeef 100644 --- a/draft-06/contains.js +++ b/draft-06/contains.js @@ -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 }; diff --git a/draft-06/schema.js b/draft-06/schema.js index 3ebf9910..216f8c6c 100644 --- a/draft-06/schema.js +++ b/draft-06/schema.js @@ -1,3 +1,42 @@ +import id from "../lib/keywords/id.js"; +import ref from "../draft-04/ref.js"; +import title from "../lib/keywords/title.js"; +import description from "../lib/keywords/description.js"; +import _default from "../lib/keywords/default.js"; +import examples from "../lib/keywords/examples.js"; +import multipleOf from "../lib/keywords/multipleOf.js"; +import maximum from "../lib/keywords/maximum.js"; +import exclusiveMaximum from "../lib/keywords/exclusiveMaximum.js"; +import minimum from "../lib/keywords/minimum.js"; +import exclusiveMinimum from "../lib/keywords/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 "../draft-04/additionalItems.js"; +import items from "../draft-04/items.js"; +import maxItems from "../lib/keywords/maxItems.js"; +import minItems from "../lib/keywords/minItems.js"; +import uniqueItems from "../lib/keywords/uniqueItems.js"; +import contains from "./contains.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 "../draft-04/dependencies.js"; +import propertyNames from "../lib/keywords/propertyNames.js"; +import _const from "../lib/keywords/const.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 { "$schema": "http://json-schema.org/draft-06/schema#", "$id": "http://json-schema.org/draft-06/schema#", @@ -40,82 +79,133 @@ export default { "properties": { "$id": { "type": "string", - "format": "uri-reference" + "format": "uri-reference", + "description": id.description }, "$schema": { "type": "string", - "format": "uri" + "format": "uri", + "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.` }, "$ref": { "type": "string", - "format": "uri-reference" + "format": "uri-reference", + "description": ref.description }, "title": { - "type": "string" + "type": "string", + "description": title.description }, "description": { - "type": "string" + "type": "string", + "description": description.description + }, + "default": { + "description": _default.description }, - "default": {}, "examples": { "type": "array", - "items": {} + "items": {}, + "description": examples.description }, "multipleOf": { "type": "number", - "exclusiveMinimum": 0 + "exclusiveMinimum": 0, + "description": multipleOf.description }, "maximum": { - "type": "number" + "type": "number", + "description": maximum.description }, "exclusiveMaximum": { - "type": "number" + "type": "number", + "description": exclusiveMaximum.description }, "minimum": { - "type": "number" + "type": "number", + "description": minimum.description }, "exclusiveMinimum": { - "type": "number" + "type": "number", + "description": exclusiveMinimum.description + }, + "maxLength": { + "allOf": [{ "$ref": "#/definitions/nonNegativeInteger" }], + "description": maxLength.description + }, + "minLength": { + "allOf": [{ "$ref": "#/definitions/nonNegativeIntegerDefault0" }], + "description": minLength.description }, - "maxLength": { "$ref": "#/definitions/nonNegativeInteger" }, - "minLength": { "$ref": "#/definitions/nonNegativeIntegerDefault0" }, "pattern": { "type": "string", - "format": "regex" + "format": "regex", + "description": pattern.description + }, + "additionalItems": { + "allOf": [{ "$ref": "#" }], + "description": additionalItems.description }, - "additionalItems": { "$ref": "#" }, "items": { "anyOf": [ { "$ref": "#" }, { "$ref": "#/definitions/schemaArray" } ], - "default": {} + "default": {}, + "description": items.description + }, + "maxItems": { + "allOf": [{ "$ref": "#/definitions/nonNegativeInteger" }], + "description": maxItems.description + }, + "minItems": { + "allOf": [{ "$ref": "#/definitions/nonNegativeIntegerDefault0" }], + "description": minItems.description }, - "maxItems": { "$ref": "#/definitions/nonNegativeInteger" }, - "minItems": { "$ref": "#/definitions/nonNegativeIntegerDefault0" }, "uniqueItems": { "type": "boolean", - "default": false + "default": false, + "description": uniqueItems.description + }, + "contains": { + "allOf": [{ "$ref": "#" }], + "description": contains.description + }, + "maxProperties": { + "allOf": [{ "$ref": "#/definitions/nonNegativeInteger" }], + "description": maxProperties.description + }, + "minProperties": { + "allOf": [{ "$ref": "#/definitions/nonNegativeIntegerDefault0" }], + "description": minProperties.description + }, + "required": { + "allOf": [{ "$ref": "#/definitions/stringArray" }], + "description": required.description + }, + "additionalProperties": { + "allOf": [{ "$ref": "#" }], + "description": additionalProperties.description }, - "contains": { "$ref": "#" }, - "maxProperties": { "$ref": "#/definitions/nonNegativeInteger" }, - "minProperties": { "$ref": "#/definitions/nonNegativeIntegerDefault0" }, - "required": { "$ref": "#/definitions/stringArray" }, - "additionalProperties": { "$ref": "#" }, "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", @@ -124,14 +214,21 @@ export default { { "$ref": "#" }, { "$ref": "#/definitions/stringArray" } ] - } + }, + "description": dependencies.description + }, + "propertyNames": { + "allOf": [{ "$ref": "#" }], + "description": propertyNames.description + }, + "const": { + "description": _const.description }, - "propertyNames": { "$ref": "#" }, - "const": {}, "enum": { "type": "array", "minItems": 1, - "uniqueItems": true + "uniqueItems": true, + "description": _enum.description }, "type": { "anyOf": [ @@ -142,13 +239,29 @@ export default { "minItems": 1, "uniqueItems": true } - ] + ], + "description": type.description + }, + "format": { + "type": "string", + "description": format.description + }, + "allOf": { + "allOf": [{ "$ref": "#/definitions/schemaArray" }], + "description": allOf.description }, - "format": { "type": "string" }, - "allOf": { "$ref": "#/definitions/schemaArray" }, - "anyOf": { "$ref": "#/definitions/schemaArray" }, - "oneOf": { "$ref": "#/definitions/schemaArray" }, - "not": { "$ref": "#" } + "anyOf": { + "allOf": [{ "$ref": "#/definitions/schemaArray" }], + "description": anyOf.description + }, + "oneOf": { + "allOf": [{ "$ref": "#/definitions/schemaArray" }], + "description": oneOf.description + }, + "not": { + "allOf": [{ "$ref": "#" }], + "description": not.description + } }, "default": {} }; diff --git a/draft-07/schema.js b/draft-07/schema.js index 83aa3de6..4241a266 100644 --- a/draft-07/schema.js +++ b/draft-07/schema.js @@ -1,3 +1,50 @@ +import id from "../draft-04/id.js"; +import ref from "../draft-04/ref.js"; +import comment from "../lib/keywords/comment.js"; +import title from "../lib/keywords/title.js"; +import description from "../lib/keywords/description.js"; +import _default from "../lib/keywords/default.js"; +import readOnly from "../lib/keywords/readOnly.js"; +import writeOnly from "../lib/keywords/writeOnly.js"; +import examples from "../lib/keywords/examples.js"; +import multipleOf from "../lib/keywords/multipleOf.js"; +import maximum from "../lib/keywords/maximum.js"; +import exclusiveMaximum from "../lib/keywords/exclusiveMaximum.js"; +import minimum from "../lib/keywords/minimum.js"; +import exclusiveMinimum from "../lib/keywords/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 "../draft-04/additionalItems.js"; +import items from "../draft-04/items.js"; +import maxItems from "../lib/keywords/maxItems.js"; +import minItems from "../lib/keywords/minItems.js"; +import uniqueItems from "../lib/keywords/uniqueItems.js"; +import contains from "../draft-06/contains.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 "../draft-04/dependencies.js"; +import propertyNames from "../lib/keywords/propertyNames.js"; +import _const from "../lib/keywords/const.js"; +import _enum from "../lib/keywords/enum.js"; +import type from "../lib/keywords/type.js"; +import format from "../lib/keywords/format.js"; +import contentMediaType from "../lib/keywords/contentMediaType.js"; +import contentEncoding from "../lib/keywords/contentEncoding.js"; +import _if from "../lib/keywords/if.js"; +import then from "../lib/keywords/then.js"; +import _else from "../lib/keywords/else.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 { "$schema": "http://json-schema.org/draft-07/schema#", "$id": "http://json-schema.org/draft-07/schema#", @@ -40,94 +87,148 @@ export default { "properties": { "$id": { "type": "string", - "format": "uri-reference" + "format": "uri-reference", + "description": id.description }, "$schema": { "type": "string", - "format": "uri" + "format": "uri", + "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.` }, "$ref": { "type": "string", - "format": "uri-reference" + "format": "uri-reference", + "description": ref.description }, "$comment": { - "type": "string" + "type": "string", + "description": comment.description }, "title": { - "type": "string" + "type": "string", + "description": title.description }, "description": { - "type": "string" + "type": "string", + "description": description.description + }, + "default": { + "description": _default.description }, - "default": true, "readOnly": { "type": "boolean", - "default": false + "default": false, + "description": readOnly.description }, "writeOnly": { "type": "boolean", - "default": false + "default": false, + "description": writeOnly.description }, "examples": { "type": "array", - "items": true + "items": true, + "description": examples.description }, "multipleOf": { "type": "number", - "exclusiveMinimum": 0 + "exclusiveMinimum": 0, + "description": multipleOf.description }, "maximum": { - "type": "number" + "type": "number", + "description": maximum.description }, "exclusiveMaximum": { - "type": "number" + "type": "number", + "description": exclusiveMaximum.description }, "minimum": { - "type": "number" + "type": "number", + "description": minimum.description }, "exclusiveMinimum": { - "type": "number" + "type": "number", + "description": exclusiveMinimum.description + }, + "maxLength": { + "allOf": [{ "$ref": "#/definitions/nonNegativeInteger" }], + "description": maxLength.description + }, + "minLength": { + "allOf": [{ "$ref": "#/definitions/nonNegativeIntegerDefault0" }], + "description": minLength.description }, - "maxLength": { "$ref": "#/definitions/nonNegativeInteger" }, - "minLength": { "$ref": "#/definitions/nonNegativeIntegerDefault0" }, "pattern": { "type": "string", - "format": "regex" + "format": "regex", + "description": pattern.description + }, + "additionalItems": { + "allOf": [{ "$ref": "#" }], + "description": additionalItems.description }, - "additionalItems": { "$ref": "#" }, "items": { "anyOf": [ { "$ref": "#" }, { "$ref": "#/definitions/schemaArray" } ], - "default": true + "default": true, + "description": items.description + }, + "maxItems": { + "allOf": [{ "$ref": "#/definitions/nonNegativeInteger" }], + "description": maxItems.description + }, + "minItems": { + "allOf": [{ "$ref": "#/definitions/nonNegativeIntegerDefault0" }], + "description": minItems.description }, - "maxItems": { "$ref": "#/definitions/nonNegativeInteger" }, - "minItems": { "$ref": "#/definitions/nonNegativeIntegerDefault0" }, "uniqueItems": { "type": "boolean", - "default": false + "default": false, + "description": uniqueItems.description + }, + "contains": { + "allOf": [{ "$ref": "#" }], + "description": contains.description + }, + "maxProperties": { + "allOf": [{ "$ref": "#/definitions/nonNegativeInteger" }], + "description": maxProperties.description + }, + "minProperties": { + "allOf": [{ "$ref": "#/definitions/nonNegativeIntegerDefault0" }], + "description": minProperties.description + }, + "required": { + "allOf": [{ "$ref": "#/definitions/stringArray" }], + "description": required.description + }, + "additionalProperties": { + "allOf": [{ "$ref": "#" }], + "description": additionalProperties.description }, - "contains": { "$ref": "#" }, - "maxProperties": { "$ref": "#/definitions/nonNegativeInteger" }, - "minProperties": { "$ref": "#/definitions/nonNegativeIntegerDefault0" }, - "required": { "$ref": "#/definitions/stringArray" }, - "additionalProperties": { "$ref": "#" }, "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": "#" }, "propertyNames": { "format": "regex" }, - "default": {} + "default": {}, + "description": patternProperties.description }, "dependencies": { "type": "object", @@ -136,15 +237,22 @@ export default { { "$ref": "#" }, { "$ref": "#/definitions/stringArray" } ] - } + }, + "description": dependencies.description + }, + "propertyNames": { + "allOf": [{ "$ref": "#" }], + "description": propertyNames.description + }, + "const": { + "description": _const.description }, - "propertyNames": { "$ref": "#" }, - "const": true, "enum": { "type": "array", "items": true, "minItems": 1, - "uniqueItems": true + "uniqueItems": true, + "description": _enum.description }, "type": { "anyOf": [ @@ -155,18 +263,49 @@ export default { "minItems": 1, "uniqueItems": true } - ] + ], + "description": type.description + }, + "format": { + "type": "string", + "description": format.description + }, + "contentMediaType": { + "type": "string", + "description": contentMediaType.description }, - "format": { "type": "string" }, - "contentMediaType": { "type": "string" }, - "contentEncoding": { "type": "string" }, - "if": { "$ref": "#" }, - "then": { "$ref": "#" }, - "else": { "$ref": "#" }, - "allOf": { "$ref": "#/definitions/schemaArray" }, - "anyOf": { "$ref": "#/definitions/schemaArray" }, - "oneOf": { "$ref": "#/definitions/schemaArray" }, - "not": { "$ref": "#" } + "contentEncoding": { + "type": "string", + "description": contentEncoding.description + }, + "if": { + "allOf": [{ "$ref": "#" }], + "description": _if.description + }, + "then": { + "allOf": [{ "$ref": "#" }], + "description": then.description + }, + "else": { + "allOf": [{ "$ref": "#" }], + "description": _else.description + }, + "allOf": { + "allOf": [{ "$ref": "#/definitions/schemaArray" }], + "description": allOf.description + }, + "anyOf": { + "allOf": [{ "$ref": "#/definitions/schemaArray" }], + "description": anyOf.description + }, + "oneOf": { + "allOf": [{ "$ref": "#/definitions/schemaArray" }], + "description": oneOf.description + }, + "not": { + "allOf": [{ "$ref": "#" }], + "description": not.description + } }, "default": true }; diff --git a/draft-2019-09/meta/applicator.js b/draft-2019-09/meta/applicator.js index 5e6430bd..60149c56 100644 --- a/draft-2019-09/meta/applicator.js +++ b/draft-2019-09/meta/applicator.js @@ -1,3 +1,22 @@ +import additionalItems from "../../draft-04/additionalItems.js"; +import unevaluatedItems from "../../lib/keywords/unevaluatedItems.js"; +import items from "../../draft-04/items.js"; +import contains from "../../lib/keywords/contains.js"; +import additionalProperties from "../../lib/keywords/additionalProperties.js"; +import unevaluatedProperties from "../../lib/keywords/unevaluatedProperties.js"; +import properties from "../../lib/keywords/properties.js"; +import patternProperties from "../../lib/keywords/patternProperties.js"; +import dependentSchemas from "../../lib/keywords/dependentSchemas.js"; +import propertyNames from "../../lib/keywords/propertyNames.js"; +import _if from "../../lib/keywords/if.js"; +import then from "../../lib/keywords/then.js"; +import _else from "../../lib/keywords/else.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": "https://json-schema.org/draft/2019-09/meta/applicator", "$schema": "https://json-schema.org/draft/2019-09/schema", @@ -5,42 +24,85 @@ export default { "title": "Applicator vocabulary meta-schema", "properties": { - "additionalItems": { "$recursiveRef": "#" }, - "unevaluatedItems": { "$recursiveRef": "#" }, + "additionalItems": { + "$recursiveRef": "#", + "description": additionalItems.description + }, + "unevaluatedItems": { + "$recursiveRef": "#", + "description": unevaluatedItems.description + }, "items": { "anyOf": [ { "$recursiveRef": "#" }, { "$ref": "#/$defs/schemaArray" } - ] + ], + "description": items.description + }, + "contains": { + "$recursiveRef": "#", + "description": contains.description + }, + "additionalProperties": { + "$recursiveRef": "#", + "description": additionalProperties.description + }, + "unevaluatedProperties": { + "$recursiveRef": "#", + "description": unevaluatedProperties.description }, - "contains": { "$recursiveRef": "#" }, - "additionalProperties": { "$recursiveRef": "#" }, - "unevaluatedProperties": { "$recursiveRef": "#" }, "properties": { "type": "object", "additionalProperties": { "$recursiveRef": "#" }, - "default": {} + "default": {}, + "description": properties.description }, "patternProperties": { "type": "object", "additionalProperties": { "$recursiveRef": "#" }, "propertyNames": { "format": "regex" }, - "default": {} + "default": {}, + "description": patternProperties.description }, "dependentSchemas": { "type": "object", "additionalProperties": { "$recursiveRef": "#" - } - }, - "propertyNames": { "$recursiveRef": "#" }, - "if": { "$recursiveRef": "#" }, - "then": { "$recursiveRef": "#" }, - "else": { "$recursiveRef": "#" }, - "allOf": { "$ref": "#/$defs/schemaArray" }, - "anyOf": { "$ref": "#/$defs/schemaArray" }, - "oneOf": { "$ref": "#/$defs/schemaArray" }, - "not": { "$recursiveRef": "#" } + }, + "description": dependentSchemas.description + }, + "propertyNames": { + "$recursiveRef": "#", + "description": propertyNames.description + }, + "if": { + "$recursiveRef": "#", + "description": _if.description + }, + "then": { + "$recursiveRef": "#", + "description": then.description + }, + "else": { + "$recursiveRef": "#", + "description": _else.description + }, + "allOf": { + "$ref": "#/$defs/schemaArray", + "description": allOf.description + }, + "anyOf": { + "$ref": "#/$defs/schemaArray", + "description": anyOf.description + }, + "oneOf": { + "$ref": "#/$defs/schemaArray", + "description": oneOf.description + }, + "not": { + "$recursiveRef": "#", + "description": not.description + } }, "$defs": { "schemaArray": { diff --git a/draft-2019-09/meta/content.js b/draft-2019-09/meta/content.js index e8a66767..0320b6ea 100644 --- a/draft-2019-09/meta/content.js +++ b/draft-2019-09/meta/content.js @@ -1,3 +1,8 @@ +import contentMediaType from "../../lib/keywords/contentMediaType.js"; +import contentEncoding from "../../lib/keywords/contentEncoding.js"; +import contentSchema from "../../lib/keywords/contentSchema.js"; + + export default { "$id": "https://json-schema.org/draft/2019-09/meta/content", "$schema": "https://json-schema.org/draft/2019-09/schema", @@ -6,8 +11,17 @@ export default { "title": "Content vocabulary meta-schema", "properties": { - "contentMediaType": { "type": "string" }, - "contentEncoding": { "type": "string" }, - "contentSchema": { "$recursiveRef": "#" } + "contentMediaType": { + "type": "string", + "description": contentMediaType.description + }, + "contentEncoding": { + "type": "string", + "description": contentEncoding.description + }, + "contentSchema": { + "$recursiveRef": "#", + "description": contentSchema.description + } } }; diff --git a/draft-2019-09/meta/core.js b/draft-2019-09/meta/core.js index a01d8c05..651d9cfc 100644 --- a/draft-2019-09/meta/core.js +++ b/draft-2019-09/meta/core.js @@ -1,3 +1,13 @@ +import id from "../../lib/keywords/id.js"; +import anchor from "../../lib/keywords/anchor.js"; +import ref from "../../lib/keywords/ref.js"; +import recursiveRef from "../../draft-2020-12/dynamicRef.js"; +import recursiveAnchor from "../recursiveAnchor.js"; +import vocabulary from "../../lib/keywords/vocabulary.js"; +import comment from "../../lib/keywords/comment.js"; +import definitions from "../../lib/keywords/definitions.js"; + + export default { "$id": "https://json-schema.org/draft/2019-09/meta/core", "$schema": "https://json-schema.org/draft/2019-09/schema", @@ -9,27 +19,35 @@ export default { "type": "string", "format": "uri-reference", "$comment": "Non-empty fragments not allowed.", - "pattern": "^[^#]*#?$" + "pattern": "^[^#]*#?$", + "description": id.description }, "$schema": { "type": "string", - "format": "uri" + "format": "uri", + "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.` }, "$anchor": { "type": "string", - "pattern": "^[A-Za-z][-A-Za-z0-9.:_]*$" + "pattern": "^[A-Za-z][-A-Za-z0-9.:_]*$", + "description": anchor.description }, "$ref": { "type": "string", - "format": "uri-reference" + "format": "uri-reference", + "description": ref.description }, "$recursiveRef": { "type": "string", - "format": "uri-reference" + "format": "uri-reference", + "description": recursiveRef.description }, "$recursiveAnchor": { "type": "boolean", - "default": false + "default": false, + "description": recursiveAnchor.description }, "$vocabulary": { "type": "object", @@ -39,15 +57,18 @@ export default { }, "additionalProperties": { "type": "boolean" - } + }, + "description": vocabulary.description }, "$comment": { - "type": "string" + "type": "string", + "description": comment.description }, "$defs": { "type": "object", "additionalProperties": { "$recursiveRef": "#" }, - "default": {} + "default": {}, + "description": definitions.description } } }; diff --git a/draft-2019-09/meta/format.js b/draft-2019-09/meta/format.js index faa5fdfc..71cfebd7 100644 --- a/draft-2019-09/meta/format.js +++ b/draft-2019-09/meta/format.js @@ -1,3 +1,6 @@ +import format from "../../lib/keywords/format.js"; + + export default { "$id": "https://json-schema.org/draft/2019-09/meta/format", "$schema": "https://json-schema.org/draft/2019-09/schema", @@ -5,6 +8,9 @@ export default { "title": "Format vocabulary meta-schema", "properties": { - "format": { "type": "string" } + "format": { + "type": "string", + "description": format.description + } } }; diff --git a/draft-2019-09/meta/meta-data.js b/draft-2019-09/meta/meta-data.js index ff5ac181..d1835a28 100644 --- a/draft-2019-09/meta/meta-data.js +++ b/draft-2019-09/meta/meta-data.js @@ -1,3 +1,12 @@ +import title from "../../lib/keywords/title.js"; +import description from "../../lib/keywords/description.js"; +import _default from "../../lib/keywords/default.js"; +import deprecated from "../../lib/keywords/deprecated.js"; +import readOnly from "../../lib/keywords/readOnly.js"; +import writeOnly from "../../lib/keywords/writeOnly.js"; +import examples from "../../lib/keywords/examples.js"; + + export default { "$id": "https://json-schema.org/draft/2019-09/meta/meta-data", "$schema": "https://json-schema.org/draft/2019-09/schema", @@ -7,27 +16,35 @@ export default { "properties": { "title": { - "type": "string" + "type": "string", + "description": title.description }, "description": { - "type": "string" + "type": "string", + "description": description.description + }, + "default": { + "description": _default.description }, - "default": true, "deprecated": { "type": "boolean", - "default": false + "default": false, + "description": deprecated.description }, "readOnly": { "type": "boolean", - "default": false + "default": false, + "description": readOnly.description }, "writeOnly": { "type": "boolean", - "default": false + "default": false, + "description": writeOnly.description }, "examples": { "type": "array", - "items": true + "items": true, + "description": examples.description } } }; diff --git a/draft-2019-09/meta/validation.js b/draft-2019-09/meta/validation.js index 94f7f8c6..e6178db0 100644 --- a/draft-2019-09/meta/validation.js +++ b/draft-2019-09/meta/validation.js @@ -1,3 +1,25 @@ +import multipleOf from "../../lib/keywords/multipleOf.js"; +import maximum from "../../lib/keywords/maximum.js"; +import exclusiveMaximum from "../../lib/keywords/exclusiveMaximum.js"; +import minimum from "../../lib/keywords/minimum.js"; +import exclusiveMinimum from "../../lib/keywords/exclusiveMinimum.js"; +import maxLength from "../../lib/keywords/maxLength.js"; +import minLength from "../../lib/keywords/minLength.js"; +import pattern from "../../lib/keywords/pattern.js"; +import maxItems from "../../lib/keywords/maxItems.js"; +import minItems from "../../lib/keywords/minItems.js"; +import uniqueItems from "../../lib/keywords/uniqueItems.js"; +import maxContains from "../../lib/keywords/maxContains.js"; +import minContains from "../../lib/keywords/minContains.js"; +import maxProperties from "../../lib/keywords/maxProperties.js"; +import minProperties from "../../lib/keywords/minProperties.js"; +import required from "../../lib/keywords/required.js"; +import dependentRequired from "../../lib/keywords/dependentRequired.js"; +import _const from "../../lib/keywords/const.js"; +import _enum from "../../lib/keywords/enum.js"; +import type from "../../lib/keywords/type.js"; + + export default { "$id": "https://json-schema.org/draft/2019-09/meta/validation", "$schema": "https://json-schema.org/draft/2019-09/schema", @@ -7,50 +29,84 @@ export default { "properties": { "multipleOf": { "type": "number", - "exclusiveMinimum": 0 + "exclusiveMinimum": 0, + "description": multipleOf.description }, "maximum": { - "type": "number" + "type": "number", + "description": maximum.description }, "exclusiveMaximum": { - "type": "number" + "type": "number", + "description": exclusiveMaximum.description }, "minimum": { - "type": "number" + "type": "number", + "description": minimum.description }, "exclusiveMinimum": { - "type": "number" + "type": "number", + "description": exclusiveMinimum.description + }, + "maxLength": { + "$ref": "#/$defs/nonNegativeInteger", + "description": maxLength.description + }, + "minLength": { + "$ref": "#/$defs/nonNegativeIntegerDefault0", + "description": minLength.description }, - "maxLength": { "$ref": "#/$defs/nonNegativeInteger" }, - "minLength": { "$ref": "#/$defs/nonNegativeIntegerDefault0" }, "pattern": { "type": "string", - "format": "regex" + "format": "regex", + "description": pattern.description + }, + "maxItems": { + "$ref": "#/$defs/nonNegativeInteger", + "description": maxItems.description + }, + "minItems": { + "$ref": "#/$defs/nonNegativeIntegerDefault0", + "description": minItems.description }, - "maxItems": { "$ref": "#/$defs/nonNegativeInteger" }, - "minItems": { "$ref": "#/$defs/nonNegativeIntegerDefault0" }, "uniqueItems": { "type": "boolean", - "default": false + "default": false, + "description": uniqueItems.description + }, + "maxContains": { + "$ref": "#/$defs/nonNegativeInteger", + "description": maxContains.description }, - "maxContains": { "$ref": "#/$defs/nonNegativeInteger" }, "minContains": { "$ref": "#/$defs/nonNegativeInteger", - "default": 1 + "default": 1, + "description": minContains.description + }, + "maxProperties": { + "$ref": "#/$defs/nonNegativeInteger", + "description": maxProperties.description + }, + "minProperties": { + "$ref": "#/$defs/nonNegativeIntegerDefault0", + "description": minProperties.description + }, + "required": { + "$ref": "#/$defs/stringArray", + "description": required.description }, - "maxProperties": { "$ref": "#/$defs/nonNegativeInteger" }, - "minProperties": { "$ref": "#/$defs/nonNegativeIntegerDefault0" }, - "required": { "$ref": "#/$defs/stringArray" }, "dependentRequired": { "type": "object", - "additionalProperties": { - "$ref": "#/$defs/stringArray" - } + "additionalProperties": { "$ref": "#/$defs/stringArray" }, + "description": dependentRequired.description + }, + "const": { + "description": _const.description }, - "const": true, "enum": { "type": "array", - "items": true + "items": true, + "description": _enum.description }, "type": { "anyOf": [ @@ -61,7 +117,8 @@ export default { "minItems": 1, "uniqueItems": true } - ] + ], + "description": type.description } }, "$defs": { diff --git a/draft-2019-09/recursiveAnchor.js b/draft-2019-09/recursiveAnchor.js index c2e74085..345f949d 100644 --- a/draft-2019-09/recursiveAnchor.js +++ b/draft-2019-09/recursiveAnchor.js @@ -1 +1,4 @@ -export default { id: "https://json-schema.org/keyword/draft-2019-09/recursiveAnchor" }; +export default { + id: "https://json-schema.org/keyword/draft-2019-09/recursiveAnchor", + description: "This keyword is used to dynamically identify a base URI at runtime by marking where such a calculation can start, and where it stops. Read more: https://www.learnjsonschema.com/2019-09/core/recursiveanchor/" +}; diff --git a/draft-2020-12/dynamicAnchor.js b/draft-2020-12/dynamicAnchor.js index 0e49b934..49168e72 100644 --- a/draft-2020-12/dynamicAnchor.js +++ b/draft-2020-12/dynamicAnchor.js @@ -1 +1,8 @@ -export default { id: "https://json-schema.org/keyword/draft-2020-12/dynamicAnchor" }; +export default { + id: "https://json-schema.org/keyword/draft-2020-12/dynamicAnchor", + description: `This keyword is used to create plain name fragments that are \ +not tied to any particular structural location for referencing purposes, which are \ +taken into consideration for dynamic referencing.\\ +\\ +For examples and more information visit https://www.learnjsonschema.com/2020-12/core/dynamicanchor/` +}; diff --git a/draft-2020-12/dynamicRef.js b/draft-2020-12/dynamicRef.js index 849112f1..caad54de 100644 --- a/draft-2020-12/dynamicRef.js +++ b/draft-2020-12/dynamicRef.js @@ -25,4 +25,10 @@ const interpret = evaluate(Validation.interpret); const collectEvaluatedProperties = evaluate(Validation.collectEvaluatedProperties); const collectEvaluatedItems = evaluate(Validation.collectEvaluatedItems); -export default { id, compile, interpret, collectEvaluatedProperties, collectEvaluatedItems }; +const description = `This keyword is used to reference an identified schema, \ +deferring the full resolution until runtime, at which point it is resolved each \ +time it is encountered while evaluating an instance.\\ +\\ +For examples and more information visit https://www.learnjsonschema.com/2020-12/core/dynamicref/`; + +export default { id, compile, interpret, collectEvaluatedProperties, collectEvaluatedItems, description }; diff --git a/draft-2020-12/meta/applicator.js b/draft-2020-12/meta/applicator.js index 754ab73b..1b7c0a29 100644 --- a/draft-2020-12/meta/applicator.js +++ b/draft-2020-12/meta/applicator.js @@ -1,3 +1,20 @@ +import prefixItems from "../../lib/keywords/prefixItems.js"; +import items from "../../lib/keywords/items.js"; +import contains from "../../lib/keywords/contains.js"; +import additionalProperties from "../../lib/keywords/additionalProperties.js"; +import properties from "../../lib/keywords/properties.js"; +import patternProperties from "../../lib/keywords/patternProperties.js"; +import dependentSchemas from "../../lib/keywords/dependentSchemas.js"; +import propertyNames from "../../lib/keywords/propertyNames.js"; +import _if from "../../lib/keywords/if.js"; +import then from "../../lib/keywords/then.js"; +import _else from "../../lib/keywords/else.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": "https://json-schema.org/draft/2020-12/meta/applicator", "$schema": "https://json-schema.org/draft/2020-12/schema", @@ -5,35 +22,74 @@ export default { "title": "Applicator vocabulary meta-schema", "properties": { - "prefixItems": { "$ref": "#/$defs/schemaArray" }, - "items": { "$dynamicRef": "#meta" }, - "contains": { "$dynamicRef": "#meta" }, - "additionalProperties": { "$dynamicRef": "#meta" }, + "prefixItems": { + "$ref": "#/$defs/schemaArray", + "description": prefixItems.description + }, + "items": { + "$dynamicRef": "#meta", + "description": items.description + }, + "contains": { + "$dynamicRef": "#meta", + "description": contains.description + }, + "additionalProperties": { + "$dynamicRef": "#meta", + "description": additionalProperties.description + }, "properties": { "type": "object", "additionalProperties": { "$dynamicRef": "#meta" }, - "default": {} + "default": {}, + "description": properties.description }, "patternProperties": { "type": "object", "additionalProperties": { "$dynamicRef": "#meta" }, "propertyNames": { "format": "regex" }, - "default": {} + "default": {}, + "description": patternProperties.description }, "dependentSchemas": { "type": "object", "additionalProperties": { "$dynamicRef": "#meta" - } - }, - "propertyNames": { "$dynamicRef": "#meta" }, - "if": { "$dynamicRef": "#meta" }, - "then": { "$dynamicRef": "#meta" }, - "else": { "$dynamicRef": "#meta" }, - "allOf": { "$ref": "#/$defs/schemaArray" }, - "anyOf": { "$ref": "#/$defs/schemaArray" }, - "oneOf": { "$ref": "#/$defs/schemaArray" }, - "not": { "$dynamicRef": "#meta" } + }, + "description": dependentSchemas.description + }, + "propertyNames": { + "$dynamicRef": "#meta", + "description": propertyNames.description + }, + "if": { + "$dynamicRef": "#meta", + "description": _if.description + }, + "then": { + "$dynamicRef": "#meta", + "description": then.description + }, + "else": { + "$dynamicRef": "#meta", + "description": _else.description + }, + "allOf": { + "$ref": "#/$defs/schemaArray", + "description": allOf.description + }, + "anyOf": { + "$ref": "#/$defs/schemaArray", + "description": anyOf.description + }, + "oneOf": { + "$ref": "#/$defs/schemaArray", + "description": oneOf.description + }, + "not": { + "$dynamicRef": "#meta", + "description": not.description + } }, "$defs": { "schemaArray": { diff --git a/draft-2020-12/meta/content.js b/draft-2020-12/meta/content.js index 8c542eb2..8e43c31a 100644 --- a/draft-2020-12/meta/content.js +++ b/draft-2020-12/meta/content.js @@ -1,3 +1,8 @@ +import contentMediaType from "../../lib/keywords/contentMediaType.js"; +import contentEncoding from "../../lib/keywords/contentEncoding.js"; +import contentSchema from "../../lib/keywords/contentSchema.js"; + + export default { "$id": "https://json-schema.org/draft/2020-12/meta/content", "$schema": "https://json-schema.org/draft/2020-12/schema", @@ -6,8 +11,17 @@ export default { "title": "Content vocabulary meta-schema", "properties": { - "contentMediaType": { "type": "string" }, - "contentEncoding": { "type": "string" }, - "contentSchema": { "$dynamicRef": "#meta" } + "contentMediaType": { + "type": "string", + "description": contentMediaType.description + }, + "contentEncoding": { + "type": "string", + "description": contentEncoding.description + }, + "contentSchema": { + "$dynamicRef": "#meta", + "description": contentSchema.description + } } }; diff --git a/draft-2020-12/meta/core.js b/draft-2020-12/meta/core.js index 80dd8f17..605506a7 100644 --- a/draft-2020-12/meta/core.js +++ b/draft-2020-12/meta/core.js @@ -1,3 +1,13 @@ +import id from "../../lib/keywords/id.js"; +import anchor from "../../lib/keywords/anchor.js"; +import ref from "../../lib/keywords/ref.js"; +import dynamicRef from "../../lib/keywords/dynamicRef.js"; +import dynamicAnchor from "../../lib/keywords/dynamicAnchor.js"; +import vocabulary from "../../lib/keywords/vocabulary.js"; +import comment from "../../lib/keywords/comment.js"; +import definitions from "../../lib/keywords/definitions.js"; + + export default { "$id": "https://json-schema.org/draft/2020-12/meta/core", "$schema": "https://json-schema.org/draft/2020-12/schema", @@ -9,30 +19,37 @@ export default { "type": "string", "format": "uri-reference", "$comment": "Non-empty fragments not allowed.", - "pattern": "^[^#]*#?$" + "pattern": "^[^#]*#?$", + "description": id.description }, "$schema": { "type": "string", - "format": "uri" + "format": "uri", + "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." }, "$anchor": { "type": "string", - "pattern": "^[A-Za-z_][-A-Za-z0-9._]*$" + "pattern": "^[A-Za-z_][-A-Za-z0-9._]*$", + "description": anchor.description }, "$ref": { "type": "string", - "format": "uri-reference" + "format": "uri-reference", + "description": ref.description }, "$dynamicRef": { "type": "string", - "format": "uri-reference" + "format": "uri-reference", + "description": dynamicRef.description }, "$dynamicAnchor": { "type": "string", - "pattern": "^[A-Za-z_][-A-Za-z0-9._]*$" + "pattern": "^[A-Za-z_][-A-Za-z0-9._]*$", + "description": dynamicAnchor.description }, "$vocabulary": { "type": "object", + "description": vocabulary.description, "propertyNames": { "type": "string", "format": "uri" @@ -42,12 +59,14 @@ export default { } }, "$comment": { - "type": "string" + "type": "string", + "description": comment.description }, "$defs": { "type": "object", "additionalProperties": { "$dynamicRef": "#meta" }, - "default": {} + "default": {}, + "description": definitions.description } } }; diff --git a/draft-2020-12/meta/format-annotation.js b/draft-2020-12/meta/format-annotation.js index f20e1ec3..46bf25b8 100644 --- a/draft-2020-12/meta/format-annotation.js +++ b/draft-2020-12/meta/format-annotation.js @@ -1,3 +1,6 @@ +import format from "../../lib/keywords/format.js"; + + export default { "$id": "https://json-schema.org/draft/2020-12/meta/format-annotation", "$schema": "https://json-schema.org/draft/2020-12/schema", @@ -5,6 +8,9 @@ export default { "title": "Format vocabulary meta-schema for annotation results", "properties": { - "format": { "type": "string" } + "format": { + "type": "string", + "description": format.description + } } }; diff --git a/draft-2020-12/meta/format-assertion.js b/draft-2020-12/meta/format-assertion.js index b253ec71..7fd3e9c2 100644 --- a/draft-2020-12/meta/format-assertion.js +++ b/draft-2020-12/meta/format-assertion.js @@ -1,3 +1,6 @@ +import format from "../../lib/keywords/format.js"; + + export default { "$id": "https://json-schema.org/draft/2020-12/meta/format-assertion", "$schema": "https://json-schema.org/draft/2020-12/schema", @@ -5,6 +8,9 @@ export default { "title": "Format vocabulary meta-schema for assertion results", "properties": { - "format": { "type": "string" } + "format": { + "type": "string", + "description": format.description + } } }; diff --git a/draft-2020-12/meta/meta-data.js b/draft-2020-12/meta/meta-data.js index 8c0afcbe..5766cfbb 100644 --- a/draft-2020-12/meta/meta-data.js +++ b/draft-2020-12/meta/meta-data.js @@ -1,3 +1,12 @@ +import title from "../../lib/keywords/title.js"; +import description from "../../lib/keywords/description.js"; +import _default from "../../lib/keywords/default.js"; +import deprecated from "../../lib/keywords/deprecated.js"; +import readOnly from "../../lib/keywords/readOnly.js"; +import writeOnly from "../../lib/keywords/writeOnly.js"; +import examples from "../../lib/keywords/examples.js"; + + export default { "$id": "https://json-schema.org/draft/2020-12/meta/meta-data", "$schema": "https://json-schema.org/draft/2020-12/schema", @@ -7,27 +16,35 @@ export default { "properties": { "title": { - "type": "string" + "type": "string", + "description": title.description }, "description": { - "type": "string" + "type": "string", + "description": description.description + }, + "default": { + "description": _default.description }, - "default": true, "deprecated": { "type": "boolean", - "default": false + "default": false, + "description": deprecated.description }, "readOnly": { "type": "boolean", - "default": false + "default": false, + "description": readOnly.description }, "writeOnly": { "type": "boolean", - "default": false + "default": false, + "description": writeOnly.description }, "examples": { "type": "array", - "items": true + "items": true, + "description": examples.description } } }; diff --git a/draft-2020-12/meta/unevaluated.js b/draft-2020-12/meta/unevaluated.js index 289a3e81..854c1baf 100644 --- a/draft-2020-12/meta/unevaluated.js +++ b/draft-2020-12/meta/unevaluated.js @@ -1,3 +1,7 @@ +import unevaluatedItems from "../../lib/keywords/unevaluatedItems.js"; +import unevaluatedProperties from "../../lib/keywords/unevaluatedProperties.js"; + + export default { "$id": "https://json-schema.org/draft/2020-12/meta/unevaluated", "$schema": "https://json-schema.org/draft/2020-12/schema", @@ -5,7 +9,13 @@ export default { "title": "Unevaluated applicator vocabulary meta-schema", "properties": { - "unevaluatedItems": { "$dynamicRef": "#meta" }, - "unevaluatedProperties": { "$dynamicRef": "#meta" } + "unevaluatedItems": { + "$dynamicRef": "#meta", + "description": unevaluatedItems.description + }, + "unevaluatedProperties": { + "$dynamicRef": "#meta", + "description": unevaluatedProperties.description + } } }; diff --git a/draft-2020-12/meta/validation.js b/draft-2020-12/meta/validation.js index 2214307b..219cea34 100644 --- a/draft-2020-12/meta/validation.js +++ b/draft-2020-12/meta/validation.js @@ -1,3 +1,25 @@ +import multipleOf from "../../lib/keywords/multipleOf.js"; +import maximum from "../../lib/keywords/maximum.js"; +import exclusiveMaximum from "../../lib/keywords/exclusiveMaximum.js"; +import minimum from "../../lib/keywords/minimum.js"; +import exclusiveMinimum from "../../lib/keywords/exclusiveMinimum.js"; +import maxLength from "../../lib/keywords/maxLength.js"; +import minLength from "../../lib/keywords/minLength.js"; +import pattern from "../../lib/keywords/pattern.js"; +import maxItems from "../../lib/keywords/maxItems.js"; +import minItems from "../../lib/keywords/minItems.js"; +import uniqueItems from "../../lib/keywords/uniqueItems.js"; +import maxContains from "../../lib/keywords/maxContains.js"; +import minContains from "../../lib/keywords/minContains.js"; +import maxProperties from "../../lib/keywords/maxProperties.js"; +import minProperties from "../../lib/keywords/minProperties.js"; +import required from "../../lib/keywords/required.js"; +import dependentRequired from "../../lib/keywords/dependentRequired.js"; +import _const from "../../lib/keywords/const.js"; +import _enum from "../../lib/keywords/enum.js"; +import type from "../../lib/keywords/type.js"; + + export default { "$id": "https://json-schema.org/draft/2020-12/meta/validation", "$schema": "https://json-schema.org/draft/2020-12/schema", @@ -7,50 +29,86 @@ export default { "properties": { "multipleOf": { "type": "number", - "exclusiveMinimum": 0 + "exclusiveMinimum": 0, + "description": multipleOf.description }, "maximum": { - "type": "number" + "type": "number", + "description": maximum.description }, "exclusiveMaximum": { - "type": "number" + "type": "number", + "description": exclusiveMaximum.description }, "minimum": { - "type": "number" + "type": "number", + "description": minimum.description }, "exclusiveMinimum": { - "type": "number" + "type": "number", + "description": exclusiveMinimum.description + }, + "maxLength": { + "$ref": "#/$defs/nonNegativeInteger", + "description": maxLength.description + }, + "minLength": { + "$ref": "#/$defs/nonNegativeIntegerDefault0", + "description": minLength.description }, - "maxLength": { "$ref": "#/$defs/nonNegativeInteger" }, - "minLength": { "$ref": "#/$defs/nonNegativeIntegerDefault0" }, "pattern": { "type": "string", - "format": "regex" + "format": "regex", + "description": pattern.description + }, + "maxItems": { + "$ref": "#/$defs/nonNegativeInteger", + "description": maxItems.description + }, + "minItems": { + "$ref": "#/$defs/nonNegativeIntegerDefault0", + "description": minItems.description }, - "maxItems": { "$ref": "#/$defs/nonNegativeInteger" }, - "minItems": { "$ref": "#/$defs/nonNegativeIntegerDefault0" }, "uniqueItems": { "type": "boolean", - "default": false + "default": false, + "description": uniqueItems.description + }, + "maxContains": { + "$ref": "#/$defs/nonNegativeInteger", + "description": maxContains.description }, - "maxContains": { "$ref": "#/$defs/nonNegativeInteger" }, "minContains": { "$ref": "#/$defs/nonNegativeInteger", - "default": 1 + "default": 1, + "description": minContains.description + }, + "maxProperties": { + "$ref": "#/$defs/nonNegativeInteger", + "description": maxProperties.description + }, + "minProperties": { + "$ref": "#/$defs/nonNegativeIntegerDefault0", + "description": minProperties.description + }, + "required": { + "$ref": "#/$defs/stringArray", + "description": required.description }, - "maxProperties": { "$ref": "#/$defs/nonNegativeInteger" }, - "minProperties": { "$ref": "#/$defs/nonNegativeIntegerDefault0" }, - "required": { "$ref": "#/$defs/stringArray" }, "dependentRequired": { "type": "object", "additionalProperties": { "$ref": "#/$defs/stringArray" - } + }, + "description": dependentRequired.description + }, + "const": { + "description": _const.description }, - "const": true, "enum": { "type": "array", - "items": true + "items": true, + "description": _enum.description }, "type": { "anyOf": [ @@ -61,7 +119,8 @@ export default { "minItems": 1, "uniqueItems": true } - ] + ], + "description": type.description } }, "$defs": { diff --git a/lib/keywords/additionalProperties.js b/lib/keywords/additionalProperties.js index f42a6096..6f6781f1 100644 --- a/lib/keywords/additionalProperties.js +++ b/lib/keywords/additionalProperties.js @@ -5,6 +5,8 @@ import { getKeywordName, Validation } from "../experimental.js"; const id = "https://json-schema.org/keyword/additionalProperties"; +const description = `addtionalProperties validates against properties not matched by properties \ +or patternProperties in the same sub-schema as additionalProperties.`; const compile = async (schema, ast, parentSchema) => { const propertiesKeyword = getKeywordName(schema.document.dialectId, "https://json-schema.org/keyword/properties"); @@ -67,4 +69,4 @@ const collectEvaluatedProperties = ([isDefinedProperty, additionalProperties], i return evaluatedPropertyNames; }; -export default { id, compile, interpret, collectEvaluatedProperties }; +export default { id, compile, interpret, collectEvaluatedProperties, description }; diff --git a/lib/keywords/allOf.js b/lib/keywords/allOf.js index c1170024..ab7f3910 100644 --- a/lib/keywords/allOf.js +++ b/lib/keywords/allOf.js @@ -4,6 +4,8 @@ import { Validation } from "../experimental.js"; const id = "https://json-schema.org/keyword/allOf"; +const description = `An instance validates successfully against this keyword if it validates successfully \ +against all schemas defined by this keyword’s value.`; const compile = (schema, ast) => pipe( Browser.iter(schema), @@ -49,4 +51,4 @@ const collectEvaluatedItems = (allOf, instance, ast, dynamicAnchors) => { return evaluatedItemIndexes; }; -export default { id, compile, interpret, collectEvaluatedProperties, collectEvaluatedItems }; +export default { id, compile, interpret, collectEvaluatedProperties, collectEvaluatedItems, description }; diff --git a/lib/keywords/anchor.js b/lib/keywords/anchor.js index 790a8248..b470e495 100644 --- a/lib/keywords/anchor.js +++ b/lib/keywords/anchor.js @@ -1 +1,5 @@ -export default { id: "https://json-schema.org/keyword/anchor" }; +export default { + id: "https://json-schema.org/keyword/anchor", + description: `This keyword is used to create plain name fragments that are not tied to any particular \ +structural location for referencing purposes, which are taken into consideration for static referencing.` +}; diff --git a/lib/keywords/anyOf.js b/lib/keywords/anyOf.js index fc759273..6cdab052 100644 --- a/lib/keywords/anyOf.js +++ b/lib/keywords/anyOf.js @@ -4,6 +4,8 @@ import { Validation } from "../experimental.js"; const id = "https://json-schema.org/keyword/anyOf"; +const description = `An instance validates successfully against this keyword if it \ +validates successfully against at least one schema defined by this keyword’s value.`; const compile = (schema, ast) => pipe( Browser.iter(schema), @@ -42,4 +44,4 @@ const collectEvaluatedItems = (anyOf, instance, ast, dynamicAnchors) => { return evaluatedItemIndexes; }; -export default { id, compile, interpret, collectEvaluatedProperties, collectEvaluatedItems }; +export default { id, compile, interpret, collectEvaluatedProperties, collectEvaluatedItems, description }; diff --git a/lib/keywords/comment.js b/lib/keywords/comment.js index 9a368fd6..d038c6c9 100644 --- a/lib/keywords/comment.js +++ b/lib/keywords/comment.js @@ -1,5 +1,9 @@ const id = "https://json-schema.org/keyword/comment"; + +const description = `This keyword reserves a location for comments \ +from schema authors to readers or maintainers of the schema.`; + const compile = () => undefined; const interpret = () => true; -export default { id, compile, interpret }; +export default { id, description, compile, interpret }; diff --git a/lib/keywords/const.js b/lib/keywords/const.js index ef9a21e1..6a273eb2 100644 --- a/lib/keywords/const.js +++ b/lib/keywords/const.js @@ -8,4 +8,6 @@ const id = "https://json-schema.org/keyword/const"; const compile = (schema) => jsonStringify(Browser.value(schema)); const interpret = (const_, instance) => jsonStringify(Instance.value(instance)) === const_; -export default { id, compile, interpret }; +const description = "The const keyword in restricts an instance to a specific value. Read more: https://www.learnjsonschema.com/2020-12/validation/const/"; + +export default { id, compile, interpret, description }; diff --git a/lib/keywords/contains.js b/lib/keywords/contains.js index a317f5c1..6a87e13e 100644 --- a/lib/keywords/contains.js +++ b/lib/keywords/contains.js @@ -5,6 +5,8 @@ import { getKeywordName, Validation } from "../experimental.js"; const id = "https://json-schema.org/keyword/contains"; +const description = `Validation succeeds if the instance \ +contains an element that validates against this schema.`; const compile = async (schema, ast, parentSchema) => { const contains = await Validation.compile(schema, ast); @@ -40,4 +42,4 @@ const collectEvaluatedItems = (keywordValue, instance, ast, dynamicAnchors) => { ); }; -export default { id, compile, interpret, collectEvaluatedItems }; +export default { id, compile, interpret, collectEvaluatedItems, description }; diff --git a/lib/keywords/contentEncoding.js b/lib/keywords/contentEncoding.js index 4e111020..2693e424 100644 --- a/lib/keywords/contentEncoding.js +++ b/lib/keywords/contentEncoding.js @@ -4,6 +4,8 @@ import * as Instance from "../../annotations/annotated-instance.js"; const id = "https://json-schema.org/keyword/contentEncoding"; +const description = "The string instance should be interpreted as encoded binary data and decoded using the encoding named by this property. Read more: https://www.learnjsonschema.com/2020-12/content/contentencoding/"; + const compile = (schema) => Browser.value(schema); const interpret = (contentEncoding, instance, _ast, _dynamicAnchors, _quiet, schemaLocation) => { @@ -11,4 +13,4 @@ const interpret = (contentEncoding, instance, _ast, _dynamicAnchors, _quiet, sch return true; }; -export default { id, compile, interpret }; +export default { id, description, compile, interpret }; diff --git a/lib/keywords/contentMediaType.js b/lib/keywords/contentMediaType.js index 778a8e17..feaed8fc 100644 --- a/lib/keywords/contentMediaType.js +++ b/lib/keywords/contentMediaType.js @@ -4,6 +4,8 @@ import * as Instance from "../../annotations/annotated-instance.js"; const id = "https://json-schema.org/keyword/contentMediaType"; +const description = "This keyword declares the media type of the string instance. Read more: https://www.learnjsonschema.com/2020-12/content/contentmediatype/"; + const compile = (schema) => Browser.value(schema); const interpret = (contentMediaType, instance, _ast, _dynamicAnchors, _quiet, schemaLocation) => { @@ -11,4 +13,4 @@ const interpret = (contentMediaType, instance, _ast, _dynamicAnchors, _quiet, sc return true; }; -export default { id, compile, interpret }; +export default { id, description, compile, interpret }; diff --git a/lib/keywords/contentSchema.js b/lib/keywords/contentSchema.js index d0b314af..15a5ef8d 100644 --- a/lib/keywords/contentSchema.js +++ b/lib/keywords/contentSchema.js @@ -4,6 +4,8 @@ import * as Instance from "../../annotations/annotated-instance.js"; const id = "https://json-schema.org/keyword/contentSchema"; +const description = "This keyword declares a schema which describes the structure of the string. Read more: https://www.learnjsonschema.com/2020-12/content/contentschema/"; + const compile = (contentSchema) => canonicalUri(contentSchema); const interpret = (contentSchema, instance, _ast, _dynamicAnchors, _quiet, schemaLocation) => { @@ -11,4 +13,4 @@ const interpret = (contentSchema, instance, _ast, _dynamicAnchors, _quiet, schem return true; }; -export default { id, compile, interpret }; +export default { id, description, compile, interpret }; diff --git a/lib/keywords/default.js b/lib/keywords/default.js index f6ccf742..02a4afdf 100644 --- a/lib/keywords/default.js +++ b/lib/keywords/default.js @@ -4,6 +4,8 @@ import * as Instance from "../../annotations/annotated-instance.js"; const id = "https://json-schema.org/keyword/default"; +const description = "This keyword can be used to supply a default JSON value associated with a particular schema. Read more: https://www.learnjsonschema.com/2020-12/meta-data/default/"; + const compile = (schema) => Browser.value(schema); const interpret = (value, instance, _ast, _dynamicAnchors, _quiet, schemaLocation) => { @@ -11,4 +13,4 @@ const interpret = (value, instance, _ast, _dynamicAnchors, _quiet, schemaLocatio return true; }; -export default { id, compile, interpret }; +export default { id, description, compile, interpret }; diff --git a/lib/keywords/definitions.js b/lib/keywords/definitions.js index d4c25e2e..be3cdd47 100644 --- a/lib/keywords/definitions.js +++ b/lib/keywords/definitions.js @@ -4,6 +4,11 @@ import Validation from "./validation.js"; const id = "https://json-schema.org/keyword/definitions"; +const description = `The \`$defs\` keyword provides a standardized way to define \ +reusable subschemas within a single schema document, promoting modularity, reducing \ +code duplication, and improving schema organization. Each subschema within $defs has a \ +unique name, acting as a location for referencing, without directly affecting validation; \ +its value must be a valid JSON Schema.`; const compile = (schema, ast) => pipe( Browser.values(schema), @@ -13,4 +18,4 @@ const compile = (schema, ast) => pipe( const interpret = () => true; -export default { id, compile, interpret }; +export default { id, compile, interpret, description }; diff --git a/lib/keywords/dependentRequired.js b/lib/keywords/dependentRequired.js index c35d58b1..03bc5b49 100644 --- a/lib/keywords/dependentRequired.js +++ b/lib/keywords/dependentRequired.js @@ -26,4 +26,6 @@ const interpret = (dependentRequired, instance) => { return isValid; }; -export default { id, compile, interpret }; +const description = "The dependentRequired keyword specifies a conditional dependency between properties within an instance. Read more: https://www.learnjsonschema.com/2020-12/validation/dependentrequired/"; + +export default { id, compile, interpret, description }; diff --git a/lib/keywords/dependentSchemas.js b/lib/keywords/dependentSchemas.js index 535d34fd..ab8ccb91 100644 --- a/lib/keywords/dependentSchemas.js +++ b/lib/keywords/dependentSchemas.js @@ -5,6 +5,8 @@ import { Validation } from "../experimental.js"; const id = "https://json-schema.org/keyword/dependentSchemas"; +const description = `This keyword specifies subschemas that are \ +evaluated if the instance is an object and contains a certain property.`; const compile = (schema, ast) => pipe( Browser.entries(schema), @@ -47,4 +49,4 @@ const collectEvaluatedProperties = (dependentSchemas, instance, ast, dynamicAnch return evaluatedPropertyNames; }; -export default { id, compile, interpret, collectEvaluatedProperties }; +export default { id, compile, interpret, collectEvaluatedProperties, description }; diff --git a/lib/keywords/deprecated.js b/lib/keywords/deprecated.js index df81cef7..ec5e3e01 100644 --- a/lib/keywords/deprecated.js +++ b/lib/keywords/deprecated.js @@ -4,6 +4,8 @@ import * as Instance from "../../annotations/annotated-instance.js"; const id = "https://json-schema.org/keyword/deprecated"; +const description = "This keyword indicates that applications should refrain from using the declared property. Read more: https://www.learnjsonschema.com/2020-12/meta-data/deprecated/"; + const compile = (schema) => Browser.value(schema); const interpret = (deprecated, instance, _ast, _dynamicAnchors, _quiet, schemaLocation) => { @@ -11,4 +13,4 @@ const interpret = (deprecated, instance, _ast, _dynamicAnchors, _quiet, schemaLo return true; }; -export default { id, compile, interpret }; +export default { id, description, compile, interpret }; diff --git a/lib/keywords/description.js b/lib/keywords/description.js index 34eb4dd7..aa549dd8 100644 --- a/lib/keywords/description.js +++ b/lib/keywords/description.js @@ -4,6 +4,8 @@ import * as Instance from "../../annotations/annotated-instance.js"; const id = "https://json-schema.org/keyword/description"; +const description = "An explanation about the purpose of the instance described by the schema. Read more: https://www.learnjsonschema.com/2020-12/meta-data/description/"; + const compile = (schema) => Browser.value(schema); const interpret = (description, instance, _ast, _dynamicAnchors, _quiet, schemaLocation) => { @@ -11,4 +13,4 @@ const interpret = (description, instance, _ast, _dynamicAnchors, _quiet, schemaL return true; }; -export default { id, compile, interpret }; +export default { id, description, compile, interpret }; diff --git a/lib/keywords/dynamicAnchor.js b/lib/keywords/dynamicAnchor.js index 7fbea750..157dbb84 100644 --- a/lib/keywords/dynamicAnchor.js +++ b/lib/keywords/dynamicAnchor.js @@ -1 +1,6 @@ -export default { id: "https://json-schema.org/keyword/dynamicAnchor" }; +export default { + id: "https://json-schema.org/keyword/dynamicAnchor", + description: `This keyword is used to create plain name fragments that are \ +not tied to any particular structural location for referencing purposes, which are \ +taken into consideration for dynamic referencing.` +}; diff --git a/lib/keywords/dynamicRef.js b/lib/keywords/dynamicRef.js index c2d9c053..aacbbb5a 100644 --- a/lib/keywords/dynamicRef.js +++ b/lib/keywords/dynamicRef.js @@ -3,6 +3,8 @@ import { Validation } from "../experimental.js"; const id = "https://json-schema.org/keyword/dynamicRef"; +const description = `This keyword is used to reference an identified schema, deferring the full \ +resolution until runtime, at which point it is resolved each time it is encountered while evaluating an instance.`; const compile = async (schema, ast) => { const reference = Browser.value(schema); @@ -23,4 +25,4 @@ const interpret = evaluate(Validation.interpret); const collectEvaluatedProperties = evaluate(Validation.collectEvaluatedProperties); const collectEvaluatedItems = evaluate(Validation.collectEvaluatedItems); -export default { id, compile, interpret, collectEvaluatedProperties, collectEvaluatedItems }; +export default { id, compile, interpret, collectEvaluatedProperties, collectEvaluatedItems, description }; diff --git a/lib/keywords/else.js b/lib/keywords/else.js index e0bf42d3..b70a53cf 100644 --- a/lib/keywords/else.js +++ b/lib/keywords/else.js @@ -3,6 +3,9 @@ import { getKeywordName, Validation } from "../experimental.js"; const id = "https://json-schema.org/keyword/else"; +const description = `When if is present, and the instance fails to validate against \ +its subschema, then validation succeeds against this keyword if the instance successfully \ +validates against this keyword’s subschema.`; const compile = async (schema, ast, parentSchema) => { const ifKeyword = getKeywordName(schema.document.dialectId, "https://json-schema.org/keyword/if"); @@ -36,4 +39,4 @@ const collectEvaluatedItems = ([ifSchema, elseSchema], instance, ast, dynamicAnc return Validation.collectEvaluatedItems(elseSchema, instance, ast, dynamicAnchors); }; -export default { id, compile, interpret, collectEvaluatedProperties, collectEvaluatedItems }; +export default { id, compile, interpret, collectEvaluatedProperties, collectEvaluatedItems, description }; diff --git a/lib/keywords/enum.js b/lib/keywords/enum.js index 8c32e9fc..3c1bf0df 100644 --- a/lib/keywords/enum.js +++ b/lib/keywords/enum.js @@ -18,4 +18,6 @@ const interpret = (enum_, instance) => { return enum_.some((enumValue) => instanceValue === enumValue); }; -export default { id, compile, interpret }; +const description = "Validation succeeds if the instance is equal to one of the elements in this keyword’s array value. Read more: https://www.learnjsonschema.com/2020-12/validation/enum/"; + +export default { id, compile, interpret, description }; diff --git a/lib/keywords/examples.js b/lib/keywords/examples.js index 1f90e1b7..68e89e98 100644 --- a/lib/keywords/examples.js +++ b/lib/keywords/examples.js @@ -4,6 +4,8 @@ import * as Instance from "../../annotations/annotated-instance.js"; const id = "https://json-schema.org/keyword/examples"; +const description = "This keyword is used to provide sample JSON values associated with a particular schema, for the purpose of illustrating usage. Read more: https://www.learnjsonschema.com/2020-12/meta-data/examples/"; + const compile = (schema) => Browser.value(schema); const interpret = (examples, instance, _ast, _dynamicAnchors, _quiet, schemaLocation) => { @@ -11,4 +13,4 @@ const interpret = (examples, instance, _ast, _dynamicAnchors, _quiet, schemaLoca return true; }; -export default { id, compile, interpret }; +export default { id, description, compile, interpret }; diff --git a/lib/keywords/exclusiveMaximum.js b/lib/keywords/exclusiveMaximum.js index c893e7ee..210d2c0f 100644 --- a/lib/keywords/exclusiveMaximum.js +++ b/lib/keywords/exclusiveMaximum.js @@ -7,4 +7,6 @@ const id = "https://json-schema.org/keyword/exclusiveMaximum"; const compile = (schema) => Browser.value(schema); const interpret = (exclusiveMaximum, instance) => Instance.typeOf(instance) !== "number" || Instance.value(instance) < exclusiveMaximum; -export default { id, compile, interpret }; +const description = "The exclusiveMaximum keyword is used to set an exclusive upper limit on numeric instances. Read more: https://www.learnjsonschema.com/2020-12/validation/exclusivemaximum/"; + +export default { id, compile, interpret, description }; diff --git a/lib/keywords/exclusiveMinimum.js b/lib/keywords/exclusiveMinimum.js index 403b3957..b45f91ab 100644 --- a/lib/keywords/exclusiveMinimum.js +++ b/lib/keywords/exclusiveMinimum.js @@ -7,4 +7,6 @@ const id = "https://json-schema.org/keyword/exclusiveMinimum"; const compile = (schema) => Browser.value(schema); const interpret = (exclusiveMinimum, instance) => Instance.typeOf(instance) !== "number" || Instance.value(instance) > exclusiveMinimum; -export default { id, compile, interpret }; +const description = "The exclusiveMinimum keyword is used to set an exclusive lower limit on numeric instances. Read more: https://www.learnjsonschema.com/2020-12/validation/exclusiveminimum/"; + +export default { id, compile, interpret, description }; diff --git a/lib/keywords/format.js b/lib/keywords/format.js index a48bb1fa..b705cbc3 100644 --- a/lib/keywords/format.js +++ b/lib/keywords/format.js @@ -4,6 +4,8 @@ import * as Instance from "../../annotations/annotated-instance.js"; const id = "https://json-schema.org/keyword/format"; +const description = "Define and assert semantic information about a string instance. Read more: https://www.learnjsonschema.com/2020-12/format-assertion/format/"; + const compile = (schema) => Browser.value(schema); const interpret = (format, instance, _ast, _dynamicAnchors, _quiet, schemaLocation) => { @@ -11,4 +13,4 @@ const interpret = (format, instance, _ast, _dynamicAnchors, _quiet, schemaLocati return true; }; -export default { id, compile, interpret }; +export default { id, description, compile, interpret }; diff --git a/lib/keywords/id.js b/lib/keywords/id.js index c50c6c01..9fcd66bd 100644 --- a/lib/keywords/id.js +++ b/lib/keywords/id.js @@ -1 +1,4 @@ -export default { id: "https://json-schema.org/keyword/id" }; +export default { + id: "https://json-schema.org/keyword/id", + description: `This keyword declares an identifier for the schema resource.` +}; diff --git a/lib/keywords/if.js b/lib/keywords/if.js index 1b7b6e05..a2030a64 100644 --- a/lib/keywords/if.js +++ b/lib/keywords/if.js @@ -2,6 +2,7 @@ import { Validation } from "../experimental.js"; const id = "https://json-schema.org/keyword/if"; +const description = `This keyword declares a condition based on the validation result of the given schema.`; const compile = (schema, ast) => Validation.compile(schema, ast); @@ -18,4 +19,4 @@ const collectEvaluatedItems = (ifSchema, instance, ast, dynamicAnchors) => { return Validation.collectEvaluatedItems(ifSchema, instance, ast, dynamicAnchors) || new Set(); }; -export default { id, compile, interpret, collectEvaluatedProperties, collectEvaluatedItems }; +export default { id, compile, interpret, collectEvaluatedProperties, collectEvaluatedItems, description }; diff --git a/lib/keywords/items.js b/lib/keywords/items.js index cd6b3ddc..6e5f3317 100644 --- a/lib/keywords/items.js +++ b/lib/keywords/items.js @@ -5,6 +5,8 @@ import { getKeywordName, Validation } from "../experimental.js"; const id = "https://json-schema.org/keyword/items"; +const description = `Validation succeeds if each element of the instance \ +not covered by prefixItems validates against this schema.`; const compile = async (schema, ast, parentSchema) => { const prefixItemKeyword = getKeywordName(schema.document.dialectId, "https://json-schema.org/keyword/prefixItems"); @@ -42,4 +44,4 @@ const collectEvaluatedItems = (keywordValue, instance, ast, dynamicAnchors) => { return evaluatedIndexes; }; -export default { id, compile, interpret, collectEvaluatedItems }; +export default { id, compile, interpret, collectEvaluatedItems, description }; diff --git a/lib/keywords/maxContains.js b/lib/keywords/maxContains.js index 7c9f5c91..f7fcdf96 100644 --- a/lib/keywords/maxContains.js +++ b/lib/keywords/maxContains.js @@ -2,7 +2,10 @@ import * as Browser from "@hyperjump/browser"; const id = "https://json-schema.org/keyword/maxContains"; + +const description = "The maxContains keyword is used in conjunction with the contains keyword to specify the maximum number of items in an array instance that must validate against the contains subschema. Read more: https://www.learnjsonschema.com/2020-12/validation/maxcontains/"; + const compile = (schema) => Browser.value(schema); const interpret = () => true; -export default { id, compile, interpret }; +export default { id, description, compile, interpret }; diff --git a/lib/keywords/maxItems.js b/lib/keywords/maxItems.js index 04f2a933..752cb2c4 100644 --- a/lib/keywords/maxItems.js +++ b/lib/keywords/maxItems.js @@ -9,4 +9,6 @@ const interpret = (maxItems, instance) => { return Instance.typeOf(instance) !== "array" || Instance.length(instance) <= maxItems; }; -export default { id, compile, interpret }; +const description = "The maxItems keyword is used to specify the maximum number of items allowed in an array. Read more: https://www.learnjsonschema.com/2020-12/validation/maxitems/"; + +export default { id, compile, interpret, description }; diff --git a/lib/keywords/maxLength.js b/lib/keywords/maxLength.js index 4dd8c3da..82f63152 100644 --- a/lib/keywords/maxLength.js +++ b/lib/keywords/maxLength.js @@ -9,4 +9,6 @@ const interpret = (maxLength, instance) => { return Instance.typeOf(instance) !== "string" || [...Instance.value(instance)].length <= maxLength; }; -export default { id, compile, interpret }; +const description = "The maxLength keyword is used to specify the maximum length of a string instance. Read more: https://www.learnjsonschema.com/2020-12/validation/maxlength/"; + +export default { id, compile, interpret, description }; diff --git a/lib/keywords/maxProperties.js b/lib/keywords/maxProperties.js index 54f5b153..a6474b1d 100644 --- a/lib/keywords/maxProperties.js +++ b/lib/keywords/maxProperties.js @@ -9,4 +9,6 @@ const interpret = (maxProperties, instance) => { return Instance.typeOf(instance) !== "object" || [...Instance.keys(instance)].length <= maxProperties; }; -export default { id, compile, interpret }; +const description = "The maxProperties keyword is used to specify the maximum number of properties allowed in an object instnace. Read more: https://www.learnjsonschema.com/2020-12/validation/maxproperties/"; + +export default { id, compile, interpret, description }; diff --git a/lib/keywords/maximum.js b/lib/keywords/maximum.js index 7eab9a2d..f29b35f8 100644 --- a/lib/keywords/maximum.js +++ b/lib/keywords/maximum.js @@ -7,4 +7,6 @@ const id = "https://json-schema.org/keyword/maximum"; const compile = (schema) => Browser.value(schema); const interpret = (maximum, instance) => Instance.typeOf(instance) !== "number" || Instance.value(instance) <= maximum; -export default { id, compile, interpret }; +const description = "The maximum keyword is used to set the upper limit on numeric instances. Read more: https://www.learnjsonschema.com/2020-12/validation/maximum/"; + +export default { id, compile, interpret, description }; diff --git a/lib/keywords/minContains.js b/lib/keywords/minContains.js index 81d2e95d..b96f35ea 100644 --- a/lib/keywords/minContains.js +++ b/lib/keywords/minContains.js @@ -2,7 +2,10 @@ import * as Browser from "@hyperjump/browser"; const id = "https://json-schema.org/keyword/minContains"; + +const description = "The minContains keyword is used in conjunction with the contains keyword to specify the minimum number of items in an array instance that must validate against the contains subschema. Read more: https://www.learnjsonschema.com/2020-12/validation/mincontains/"; + const compile = (schema) => Browser.value(schema); const interpret = () => true; -export default { id, compile, interpret }; +export default { id, description, compile, interpret }; diff --git a/lib/keywords/minItems.js b/lib/keywords/minItems.js index 8cceb338..060f32e7 100644 --- a/lib/keywords/minItems.js +++ b/lib/keywords/minItems.js @@ -9,4 +9,6 @@ const interpret = (minItems, instance) => { return Instance.typeOf(instance) !== "array" || Instance.length(instance) >= minItems; }; -export default { id, compile, interpret }; +const description = "The minItems keyword specifies the minimum number of items that must be present in an array. Read more: https://www.learnjsonschema.com/2020-12/validation/minitems/"; + +export default { id, compile, interpret, description }; diff --git a/lib/keywords/minLength.js b/lib/keywords/minLength.js index 5e85a409..62b902d5 100644 --- a/lib/keywords/minLength.js +++ b/lib/keywords/minLength.js @@ -9,4 +9,6 @@ const interpret = (minLength, instance) => { return Instance.typeOf(instance) !== "string" || [...Instance.value(instance)].length >= minLength; }; -export default { id, compile, interpret }; +const description = "The minLength keyword is used to specify the minimum length of a string instance. Read more: https://www.learnjsonschema.com/2020-12/validation/minlength/"; + +export default { id, compile, interpret, description }; diff --git a/lib/keywords/minProperties.js b/lib/keywords/minProperties.js index 83abb137..6b66faa1 100644 --- a/lib/keywords/minProperties.js +++ b/lib/keywords/minProperties.js @@ -9,4 +9,6 @@ const interpret = (minProperties, instance) => { return Instance.typeOf(instance) !== "object" || [...Instance.keys(instance)].length >= minProperties; }; -export default { id, compile, interpret }; +const description = "The minProperties keyword is used to specify the inclusive minimum number of properties allowed in an object instnace. Read more: https://www.learnjsonschema.com/2020-12/validation/minproperties/"; + +export default { id, compile, interpret, description }; diff --git a/lib/keywords/minimum.js b/lib/keywords/minimum.js index c0c2a0a6..6afc8526 100644 --- a/lib/keywords/minimum.js +++ b/lib/keywords/minimum.js @@ -7,4 +7,6 @@ const id = "https://json-schema.org/keyword/minimum"; const compile = (schema) => Browser.value(schema); const interpret = (minimum, instance) => Instance.typeOf(instance) !== "number" || Instance.value(instance) >= minimum; -export default { id, compile, interpret }; +const description = "The minimum keyword is used to set the lower limit on numeric instances. Read more: https://www.learnjsonschema.com/2020-12/validation/minimum/"; + +export default { id, compile, interpret, description }; diff --git a/lib/keywords/multipleOf.js b/lib/keywords/multipleOf.js index dd80f381..9b2e9257 100644 --- a/lib/keywords/multipleOf.js +++ b/lib/keywords/multipleOf.js @@ -17,4 +17,6 @@ const interpret = (multipleOf, instance) => { const numberEqual = (a, b) => Math.abs(a - b) < 1.19209290e-7; -export default { id, compile, interpret }; +const description = "The multipleOf keyword is used to specify that an instance must be a multiple of a given number. Read more: https://www.learnjsonschema.com/2020-12/validation/multipleof/"; + +export default { id, compile, interpret, description }; diff --git a/lib/keywords/not.js b/lib/keywords/not.js index 7ee8fc55..abf5f860 100644 --- a/lib/keywords/not.js +++ b/lib/keywords/not.js @@ -2,8 +2,10 @@ import { Validation } from "../experimental.js"; const id = "https://json-schema.org/keyword/not"; +const description = `An instance is valid against this keyword if it fails to validate \ +successfully against the schema defined by this keyword.`; const compile = Validation.compile; const interpret = (not, instance, ast, dynamicAnchors, quiet) => !Validation.interpret(not, instance, ast, dynamicAnchors, quiet); -export default { id, compile, interpret }; +export default { id, compile, interpret, description }; diff --git a/lib/keywords/oneOf.js b/lib/keywords/oneOf.js index a4b8f21f..fd67e5f2 100644 --- a/lib/keywords/oneOf.js +++ b/lib/keywords/oneOf.js @@ -4,6 +4,8 @@ import { Validation } from "../experimental.js"; const id = "https://json-schema.org/keyword/oneOf"; +const description = `An instance validates successfully against this keyword if it \ +validates successfully against exactly one schema defined by this keyword’s value.`; const compile = (schema, ast) => pipe( Browser.iter(schema), @@ -54,4 +56,4 @@ const collectEvaluatedItems = (oneOf, instance, ast, dynamicAnchors) => { return evaluatedItemIndexes; }; -export default { id, compile, interpret, collectEvaluatedProperties, collectEvaluatedItems }; +export default { id, compile, interpret, collectEvaluatedProperties, collectEvaluatedItems, description }; diff --git a/lib/keywords/pattern.js b/lib/keywords/pattern.js index 5bd5436e..bb2e969b 100644 --- a/lib/keywords/pattern.js +++ b/lib/keywords/pattern.js @@ -9,4 +9,6 @@ const interpret = (pattern, instance) => { return Instance.typeOf(instance) !== "string" || pattern.test(Instance.value(instance)); }; -export default { id, compile, interpret }; +const description = "The pattern keyword in JSON Schema is designed to define a regular expression pattern that a string value within an instance must adhere to. Read more: https://www.learnjsonschema.com/2020-12/validation/pattern/"; + +export default { id, compile, interpret, description }; diff --git a/lib/keywords/patternProperties.js b/lib/keywords/patternProperties.js index 798229cb..830170ce 100644 --- a/lib/keywords/patternProperties.js +++ b/lib/keywords/patternProperties.js @@ -5,6 +5,10 @@ import { Validation } from "../experimental.js"; const id = "https://json-schema.org/keyword/patternProperties"; +const description = `Validation succeeds if, for each instance name that \ +matches any regular expressions that appear as a property name in this keyword’s \ +value, the child instance for that name successfully validates against each schema \ +that corresponds to a matching regular expression.`; const compile = (schema, ast) => pipe( Browser.entries(schema), @@ -55,4 +59,4 @@ const collectEvaluatedProperties = (patternProperties, instance, ast, dynamicAnc return evaluatedPropertyNames; }; -export default { id, compile, interpret, collectEvaluatedProperties }; +export default { id, compile, interpret, collectEvaluatedProperties, description }; diff --git a/lib/keywords/prefixItems.js b/lib/keywords/prefixItems.js index 4ceda4ce..c294fb0a 100644 --- a/lib/keywords/prefixItems.js +++ b/lib/keywords/prefixItems.js @@ -5,6 +5,8 @@ import { Validation } from "../experimental.js"; const id = "https://json-schema.org/keyword/prefixItems"; +const description = `Validation succeeds if each element of the \ +instance validates against the schema at the same position, if any.`; const compile = (schema, ast) => pipe( Browser.iter(schema), @@ -39,4 +41,4 @@ const collectEvaluatedItems = (items, instance, ast, dynamicAnchors) => { return interpret(items, instance, ast, dynamicAnchors, true) && new Set(items.map((_item, ndx) => ndx)); }; -export default { id, compile, interpret, collectEvaluatedItems }; +export default { id, compile, interpret, collectEvaluatedItems, description }; diff --git a/lib/keywords/properties.js b/lib/keywords/properties.js index 5060e16e..bae30d2e 100644 --- a/lib/keywords/properties.js +++ b/lib/keywords/properties.js @@ -5,6 +5,9 @@ import { Validation } from "../experimental.js"; const id = "https://json-schema.org/keyword/properties"; +const description = `Validation succeeds if, for each name that appears in both the \ +instance and as a name within this keyword’s value, the child instance for that name \ +successfully validates against the corresponding schema.`; const compile = (schema, ast) => pipe( Browser.entries(schema), @@ -48,4 +51,4 @@ const collectEvaluatedProperties = (properties, instance, ast, dynamicAnchors) = return evaluatedPropertyNames; }; -export default { id, compile, interpret, collectEvaluatedProperties }; +export default { id, compile, interpret, collectEvaluatedProperties, description }; diff --git a/lib/keywords/propertyNames.js b/lib/keywords/propertyNames.js index 24ff71b0..9650ece2 100644 --- a/lib/keywords/propertyNames.js +++ b/lib/keywords/propertyNames.js @@ -3,6 +3,7 @@ import * as Instance from "../instance.js"; const id = "https://json-schema.org/keyword/propertyNames"; +const description = `Validation succeeds if the schema validates against every property name in the instance.`; const compile = (schema, ast) => Validation.compile(schema, ast); @@ -21,4 +22,4 @@ const interpret = (propertyNames, instance, ast, dynamicAnchors) => { return isValid; }; -export default { id, compile, interpret }; +export default { id, compile, interpret, description }; diff --git a/lib/keywords/readOnly.js b/lib/keywords/readOnly.js index 27c897b6..bef50c8b 100644 --- a/lib/keywords/readOnly.js +++ b/lib/keywords/readOnly.js @@ -4,6 +4,8 @@ import * as Instance from "../../annotations/annotated-instance.js"; const id = "https://json-schema.org/keyword/readOnly"; +const description = "This keyword indicates that the value of the instance is managed exclusively by the owning authority, and attempts by an application to modify the value of this property are expected to be ignored or rejected by that owning authority. Read more: https://www.learnjsonschema.com/2020-12/meta-data/readonly/"; + const compile = (schema) => Browser.value(schema); const interpret = (readOnly, instance, _ast, _dynamicAnchors, _quiet, schemaLocation) => { @@ -11,4 +13,4 @@ const interpret = (readOnly, instance, _ast, _dynamicAnchors, _quiet, schemaLoca return true; }; -export default { id, compile, interpret }; +export default { id, description, compile, interpret }; diff --git a/lib/keywords/ref.js b/lib/keywords/ref.js index 2b5f6511..8d3ceb54 100644 --- a/lib/keywords/ref.js +++ b/lib/keywords/ref.js @@ -2,10 +2,11 @@ import { Validation } from "../experimental.js"; const id = "https://json-schema.org/keyword/ref"; +const description = `This keyword is used to reference a statically identified schema.`; const compile = Validation.compile; const interpret = Validation.interpret; const collectEvaluatedProperties = Validation.collectEvaluatedProperties; const collectEvaluatedItems = Validation.collectEvaluatedItems; -export default { id, compile, interpret, collectEvaluatedProperties, collectEvaluatedItems }; +export default { id, compile, interpret, collectEvaluatedProperties, collectEvaluatedItems, description }; diff --git a/lib/keywords/required.js b/lib/keywords/required.js index fc49ab73..ebc8b9d3 100644 --- a/lib/keywords/required.js +++ b/lib/keywords/required.js @@ -10,4 +10,6 @@ const interpret = (required, instance) => { return Instance.typeOf(instance) !== "object" || required.every((propertyName) => Object.hasOwn(Instance.value(instance), propertyName)); }; -export default { id, compile, interpret }; +const description = "The required keyword is used to specify which properties must be present within an object instance. Read more: https://www.learnjsonschema.com/2020-12/validation/required/"; + +export default { id, compile, interpret, description }; diff --git a/lib/keywords/then.js b/lib/keywords/then.js index 88e80537..778dea48 100644 --- a/lib/keywords/then.js +++ b/lib/keywords/then.js @@ -4,6 +4,9 @@ import { Validation } from "../experimental.js"; const id = "https://json-schema.org/keyword/then"; +const description = `When if is present, and the instance successfully validates \ +against its subschema, then validation succeeds against this keyword if the instance \ +also successfully validates against this keyword’s subschema.`; const compile = async (schema, ast, parentSchema) => { const ifKeyword = getKeywordName(schema.document.dialectId, "https://json-schema.org/keyword/if"); @@ -37,4 +40,4 @@ const collectEvaluatedItems = ([ifSchema, thenSchema], instance, ast, dynamicAnc return Validation.collectEvaluatedItems(thenSchema, instance, ast, dynamicAnchors); }; -export default { id, compile, interpret, collectEvaluatedProperties, collectEvaluatedItems }; +export default { id, compile, interpret, collectEvaluatedProperties, collectEvaluatedItems, description }; diff --git a/lib/keywords/title.js b/lib/keywords/title.js index 7f3faef0..059813ad 100644 --- a/lib/keywords/title.js +++ b/lib/keywords/title.js @@ -4,6 +4,8 @@ import * as Instance from "../../annotations/annotated-instance.js"; const id = "https://json-schema.org/keyword/title"; +const description = "A preferably short description about the purpose of the instance described by the schema. Read more: https://www.learnjsonschema.com/2020-12/meta-data/title/"; + const compile = (schema) => Browser.value(schema); const interpret = (title, instance, _ast, _dynamicAnchors, _quiet, schemaLocation) => { @@ -11,4 +13,4 @@ const interpret = (title, instance, _ast, _dynamicAnchors, _quiet, schemaLocatio return true; }; -export default { id, compile, interpret }; +export default { id, description, compile, interpret }; diff --git a/lib/keywords/type.js b/lib/keywords/type.js index 44add038..be72e81a 100644 --- a/lib/keywords/type.js +++ b/lib/keywords/type.js @@ -13,4 +13,6 @@ const isTypeOf = (instance) => (type) => type === "integer" ? Instance.typeOf(instance) === "number" && Number.isInteger(Instance.value(instance)) : Instance.typeOf(instance) === type; -export default { id, compile, interpret }; +const description = "Validation succeeds if the type of the instance matches the type represented by the given type, or matches at least one of the given types. Read more: https://www.learnjsonschema.com/2020-12/validation/type/"; + +export default { id, compile, interpret, description }; diff --git a/lib/keywords/unevaluatedItems.js b/lib/keywords/unevaluatedItems.js index 8f9c28b1..bdce044c 100644 --- a/lib/keywords/unevaluatedItems.js +++ b/lib/keywords/unevaluatedItems.js @@ -6,6 +6,8 @@ import { Validation } from "../experimental.js"; const id = "https://json-schema.org/keyword/unevaluatedItems"; +const description = "Validates array elements that did not successfully validate against other standard array applicators. Read more: https://www.learnjsonschema.com/2020-12/unevaluated/unevaluateditems/"; + const compile = async (schema, ast, parentSchema) => { return [canonicalUri(parentSchema), await Validation.compile(schema, ast)]; }; @@ -45,4 +47,4 @@ const collectEvaluatedItems = (keywordValue, instance, ast, dynamicAnchors) => { return evaluatedIndexes; }; -export default { id, compile, interpret, collectEvaluatedItems }; +export default { id, description, compile, interpret, collectEvaluatedItems }; diff --git a/lib/keywords/unevaluatedProperties.js b/lib/keywords/unevaluatedProperties.js index 24749de5..ec8c9a39 100644 --- a/lib/keywords/unevaluatedProperties.js +++ b/lib/keywords/unevaluatedProperties.js @@ -4,6 +4,8 @@ import * as Instance from "../instance.js"; const id = "https://json-schema.org/keyword/unevaluatedProperties"; +const description = "Validates object properties that did not successfully validate against other standard object applicators. Read more: https://www.learnjsonschema.com/2020-12/unevaluated/unevaluatedproperties/"; + const compile = async (schema, ast, parentSchema) => { return [canonicalUri(parentSchema), await Validation.compile(schema, ast)]; }; @@ -54,4 +56,4 @@ const collectEvaluatedProperties = ([schemaUrl, unevaluatedProperties], instance return evaluatedPropertyNames; }; -export default { id, compile, interpret, collectEvaluatedProperties }; +export default { id, description, compile, interpret, collectEvaluatedProperties }; diff --git a/lib/keywords/uniqueItems.js b/lib/keywords/uniqueItems.js index 6d28cf24..4023c57f 100644 --- a/lib/keywords/uniqueItems.js +++ b/lib/keywords/uniqueItems.js @@ -16,4 +16,6 @@ const interpret = (uniqueItems, instance) => { return new Set(normalizedItems).size === normalizedItems.length; }; -export default { id, compile, interpret }; +const description = "The uniqueItems keyword is used to ensure that all the items in an array are unique. Read more: https://www.learnjsonschema.com/2020-12/validation/uniqueitems/"; + +export default { id, compile, interpret, description }; diff --git a/lib/keywords/vocabulary.js b/lib/keywords/vocabulary.js index 02737394..1f86b1c7 100644 --- a/lib/keywords/vocabulary.js +++ b/lib/keywords/vocabulary.js @@ -1 +1,5 @@ -export default { id: "https://json-schema.org/keyword/vocabulary" }; +export default { + id: "https://json-schema.org/keyword/vocabulary", + description: `This keyword is used in meta-schemas to identify the required and \ +optional vocabularies available for use in schemas described by that meta-schema.` +}; diff --git a/lib/keywords/writeOnly.js b/lib/keywords/writeOnly.js index e63203e4..262532b4 100644 --- a/lib/keywords/writeOnly.js +++ b/lib/keywords/writeOnly.js @@ -4,6 +4,8 @@ import * as Instance from "../../annotations/annotated-instance.js"; const id = "https://json-schema.org/keyword/writeOnly"; +const description = "This keyword indicates that the value is never present when the instance is retrieved from the owning authority. Read more: https://www.learnjsonschema.com/2020-12/meta-data/writeonly/"; + const compile = (schema) => Browser.value(schema); const interpret = (writeOnly, instance, _ast, _dynamicAnchors, _quiet, schemaLocation) => { @@ -11,4 +13,4 @@ const interpret = (writeOnly, instance, _ast, _dynamicAnchors, _quiet, schemaLoc return true; }; -export default { id, compile, interpret }; +export default { id, description, compile, interpret };