From 6e0a4fcc40102a77f9564ede3450730109f1fd1b 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/schema.js | 132 +++++++++++++++----- draft-06/schema.js | 124 ++++++++++++++----- draft-07/schema.js | 155 +++++++++++++++++------- draft-2019-09/meta/applicator.js | 48 +++++--- draft-2019-09/meta/content.js | 11 +- draft-2019-09/meta/core.js | 29 ++++- draft-2019-09/meta/format.js | 5 +- draft-2019-09/meta/meta-data.js | 26 +++- draft-2019-09/meta/validation.js | 70 ++++++++--- 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 | 11 +- draft-2020-12/meta/core.js | 35 ++++-- draft-2020-12/meta/format-annotation.js | 5 +- draft-2020-12/meta/format-assertion.js | 5 +- draft-2020-12/meta/meta-data.js | 26 +++- draft-2020-12/meta/unevaluated.js | 8 +- draft-2020-12/meta/validation.js | 70 ++++++++--- 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 +- 75 files changed, 839 insertions(+), 267 deletions(-) diff --git a/draft-04/schema.js b/draft-04/schema.js index 130d72f4..4eb303dc 100644 --- a/draft-04/schema.js +++ b/draft-04/schema.js @@ -1,3 +1,32 @@ +import items from "../lib/keywords/items.js"; +import additionalProperties from "../lib/keywords/additionalProperties.js"; +import properties from "../lib/keywords/properties.js"; +import patternProperties from "../lib/keywords/patternProperties.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"; +import typeKeyword from "../lib/keywords/type.js"; +import enumKeyword from "../lib/keywords/enum.js"; +import pattern from "../lib/keywords/pattern.js"; +import minLength from "../lib/keywords/minLength.js"; +import maxLength from "../lib/keywords/maxLength.js"; +import exclusiveMaximum from "../lib/keywords/exclusiveMaximum.js"; +import multipleOf from "../lib/keywords/multipleOf.js"; +import exclusiveMinimum from "../lib/keywords/exclusiveMinimum.js"; +import maximum from "../lib/keywords/maximum.js"; +import minimum from "../lib/keywords/minimum.js"; +import maxProperties from "../lib/keywords/maxProperties.js"; +import minProperties from "../lib/keywords/minProperties.js"; +import required from "../lib/keywords/required.js"; +import maxItems from "../lib/keywords/maxItems.js"; +import minItems from "../lib/keywords/minItems.js"; +import uniqueItems from "../lib/keywords/uniqueItems.js"; +import title from "../lib/keywords/title.js"; +import description from "../lib/keywords/description.js"; +import format from "../lib/keywords/format.js"; + + export default { "id": "http://json-schema.org/draft-04/schema#", "$schema": "http://json-schema.org/draft-04/schema#", @@ -34,36 +63,50 @@ export default { "type": "string" }, "title": { - "type": "string" + "type": "string", + "description": title.description }, "description": { - "type": "string" + "type": "string", + "description": description.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": [ @@ -77,23 +120,42 @@ export default { { "$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", @@ -103,12 +165,14 @@ export default { "properties": { "type": "object", "additionalProperties": { "$ref": "#" }, - "default": {} + "default": {}, + "description": properties.description }, "patternProperties": { "type": "object", "additionalProperties": { "$ref": "#" }, - "default": {} + "default": {}, + "description": patternProperties.description }, "dependencies": { "type": "object", @@ -122,7 +186,8 @@ export default { "enum": { "type": "array", "minItems": 1, - "uniqueItems": true + "uniqueItems": true, + "description": enumKeyword.description }, "type": { "anyOf": [ @@ -133,13 +198,26 @@ export default { "minItems": 1, "uniqueItems": true } - ] + ], + "description": typeKeyword.description + }, + "format": { "type": "string", "description": format.description }, + "allOf": { + "allOf": [{ "$ref": "#/definitions/schemaArray" }], + "description": allOf.description + }, + "anyOf": { + "anyOf": [{ "$ref": "#/definitions/schemaArray" }], + "description": anyOf.description }, - "format": { "type": "string" }, - "allOf": { "$ref": "#/definitions/schemaArray" }, - "anyOf": { "$ref": "#/definitions/schemaArray" }, - "oneOf": { "$ref": "#/definitions/schemaArray" }, - "not": { "$ref": "#" } + "oneOf": { + "oneOf": [{ "$ref": "#/definitions/schemaArray" }], + "description": oneOf.description + }, + "not": { + "allOf": [{ "$ref": "#" }], + "description": not.description + } }, "dependencies": { "exclusiveMaximum": ["maximum"], diff --git a/draft-06/schema.js b/draft-06/schema.js index 3ebf9910..4370e285 100644 --- a/draft-06/schema.js +++ b/draft-06/schema.js @@ -1,3 +1,36 @@ +import id from "../lib/keywords/id.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 propertyNames from "../lib/keywords/propertyNames.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"; +import typeKeyword from "../lib/keywords/type.js"; +import enumKeyword from "../lib/keywords/enum.js"; +import pattern from "../lib/keywords/pattern.js"; +import minLength from "../lib/keywords/minLength.js"; +import maxLength from "../lib/keywords/maxLength.js"; +import exclusiveMaximum from "../lib/keywords/exclusiveMaximum.js"; +import multipleOf from "../lib/keywords/multipleOf.js"; +import exclusiveMinimum from "../lib/keywords/exclusiveMinimum.js"; +import maximum from "../lib/keywords/maximum.js"; +import minimum from "../lib/keywords/minimum.js"; +import maxProperties from "../lib/keywords/maxProperties.js"; +import minProperties from "../lib/keywords/minProperties.js"; +import required from "../lib/keywords/required.js"; +import maxItems from "../lib/keywords/maxItems.js"; +import minItems from "../lib/keywords/minItems.js"; +import uniqueItems from "../lib/keywords/uniqueItems.js"; +import title from "../lib/keywords/title.js"; +import description from "../lib/keywords/description.js"; +import examples from "../lib/keywords/examples.js"; +import format from "../lib/keywords/format.js"; + + export default { "$schema": "http://json-schema.org/draft-06/schema#", "$id": "http://json-schema.org/draft-06/schema#", @@ -40,48 +73,67 @@ 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" }, "title": { - "type": "string" + "type": "string", + "description": title.description }, "description": { - "type": "string" + "type": "string", + "description": description.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": { "$ref": "#" }, "items": { @@ -89,19 +141,21 @@ export default { { "$ref": "#" }, { "$ref": "#/definitions/schemaArray" } ], - "default": {} + "default": {}, + "description": items.description }, - "maxItems": { "$ref": "#/definitions/nonNegativeInteger" }, - "minItems": { "$ref": "#/definitions/nonNegativeIntegerDefault0" }, + "maxItems": { "allOf": [{ "$ref": "#/definitions/nonNegativeInteger" }], "description": maxItems.description }, + "minItems": { "allOf": [{ "$ref": "#/definitions/nonNegativeIntegerDefault0" }], "description": minItems.description }, "uniqueItems": { "type": "boolean", - "default": false - }, - "contains": { "$ref": "#" }, - "maxProperties": { "$ref": "#/definitions/nonNegativeInteger" }, - "minProperties": { "$ref": "#/definitions/nonNegativeIntegerDefault0" }, - "required": { "$ref": "#/definitions/stringArray" }, - "additionalProperties": { "$ref": "#" }, + "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 }, "definitions": { "type": "object", "additionalProperties": { "$ref": "#" }, @@ -110,12 +164,14 @@ export default { "properties": { "type": "object", "additionalProperties": { "$ref": "#" }, - "default": {} + "default": {}, + "description": properties.description }, "patternProperties": { "type": "object", "additionalProperties": { "$ref": "#" }, - "default": {} + "default": {}, + "description": patternProperties.description }, "dependencies": { "type": "object", @@ -126,12 +182,13 @@ export default { ] } }, - "propertyNames": { "$ref": "#" }, + "propertyNames": { "allOf": [{ "$ref": "#" }], "description": propertyNames.description }, "const": {}, "enum": { "type": "array", "minItems": 1, - "uniqueItems": true + "uniqueItems": true, + "description": enumKeyword.description }, "type": { "anyOf": [ @@ -142,13 +199,14 @@ export default { "minItems": 1, "uniqueItems": true } - ] + ], + "description": typeKeyword.description }, - "format": { "type": "string" }, - "allOf": { "$ref": "#/definitions/schemaArray" }, - "anyOf": { "$ref": "#/definitions/schemaArray" }, - "oneOf": { "$ref": "#/definitions/schemaArray" }, - "not": { "$ref": "#" } + "format": { "type": "string", "description": format.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": {} }; diff --git a/draft-07/schema.js b/draft-07/schema.js index 83aa3de6..de97812e 100644 --- a/draft-07/schema.js +++ b/draft-07/schema.js @@ -1,3 +1,46 @@ +import id from "../lib/keywords/id.js"; +import ref from "../lib/keywords/ref.js"; +import definitions from "../lib/keywords/definitions.js"; +import comment from "../lib/keywords/comment.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 propertyNames from "../lib/keywords/propertyNames.js"; +import ifKeyword from "../lib/keywords/if.js"; +import thenKeyword from "../lib/keywords/then.js"; +import elseKeyword 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"; +import typeKeyword from "../lib/keywords/type.js"; +import enumKeyword from "../lib/keywords/enum.js"; +import pattern from "../lib/keywords/pattern.js"; +import minLength from "../lib/keywords/minLength.js"; +import maxLength from "../lib/keywords/maxLength.js"; +import exclusiveMaximum from "../lib/keywords/exclusiveMaximum.js"; +import multipleOf from "../lib/keywords/multipleOf.js"; +import exclusiveMinimum from "../lib/keywords/exclusiveMinimum.js"; +import maximum from "../lib/keywords/maximum.js"; +import minimum from "../lib/keywords/minimum.js"; +import maxProperties from "../lib/keywords/maxProperties.js"; +import minProperties from "../lib/keywords/minProperties.js"; +import required from "../lib/keywords/required.js"; +import maxItems from "../lib/keywords/maxItems.js"; +import minItems from "../lib/keywords/minItems.js"; +import uniqueItems from "../lib/keywords/uniqueItems.js"; +import title from "../lib/keywords/title.js"; +import description from "../lib/keywords/description.js"; +import writeOnly from "../lib/keywords/writeOnly.js"; +import readOnly from "../lib/keywords/readOnly.js"; +import examples from "../lib/keywords/examples.js"; +import format from "../lib/keywords/format.js"; +import contentMediaType from "../lib/keywords/contentMediaType.js"; +import contentEncoding from "../lib/keywords/contentEncoding.js"; + + export default { "$schema": "http://json-schema.org/draft-07/schema#", "$id": "http://json-schema.org/draft-07/schema#", @@ -40,59 +83,76 @@ 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", + "discription": ref.description }, "$comment": { - "type": "string" + "type": "string", + "discription": comment.description }, "title": { - "type": "string" + "type": "string", + "description": title.description }, "description": { - "type": "string" + "type": "string", + "description": description.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": { "$ref": "#/definitions/nonNegativeInteger" }, - "minLength": { "$ref": "#/definitions/nonNegativeIntegerDefault0" }, + "maxLength": { "allOf": [{ "$ref": "#/definitions/nonNegativeInteger" }], "description": maxLength.description }, + "minLength": { "allOf": [{ "$ref": "#/definitions/nonNegativeIntegerDefault0" }], "description": minLength.description }, "pattern": { "type": "string", - "format": "regex" + "format": "regex", + "description": pattern.description }, "additionalItems": { "$ref": "#" }, "items": { @@ -100,34 +160,39 @@ export default { { "$ref": "#" }, { "$ref": "#/definitions/schemaArray" } ], - "default": true + "default": true, + "description": items.description }, - "maxItems": { "$ref": "#/definitions/nonNegativeInteger" }, - "minItems": { "$ref": "#/definitions/nonNegativeIntegerDefault0" }, + "maxItems": { "allOf": [{ "$ref": "#/definitions/nonNegativeInteger" }], "description": maxItems.description }, + "minItems": { "allOf": [{ "$ref": "#/definitions/nonNegativeIntegerDefault0" }], "description": minItems.description }, "uniqueItems": { "type": "boolean", - "default": false - }, - "contains": { "$ref": "#" }, - "maxProperties": { "$ref": "#/definitions/nonNegativeInteger" }, - "minProperties": { "$ref": "#/definitions/nonNegativeIntegerDefault0" }, - "required": { "$ref": "#/definitions/stringArray" }, - "additionalProperties": { "$ref": "#" }, + "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": { "$ref": "#", "description": additionalProperties.description }, "definitions": { "type": "object", "additionalProperties": { "$ref": "#" }, - "default": {} + "default": {}, + "discription": 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", @@ -138,13 +203,14 @@ export default { ] } }, - "propertyNames": { "$ref": "#" }, + "propertyNames": { "allOf": [{ "$ref": "#" }], "description": propertyNames.description }, "const": true, "enum": { "type": "array", "items": true, "minItems": 1, - "uniqueItems": true + "uniqueItems": true, + "description": enumKeyword.description }, "type": { "anyOf": [ @@ -155,18 +221,19 @@ export default { "minItems": 1, "uniqueItems": true } - ] - }, - "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": "#" } + ], + "description": typeKeyword.description + }, + "format": { "type": "string", "description": format.description }, + "contentMediaType": { "type": "string", "description": contentMediaType.description }, + "contentEncoding": { "type": "string", "description": contentEncoding.description }, + "if": { "allOf": [{ "$ref": "#" }], "description": ifKeyword.description }, + "then": { "allOf": [{ "$ref": "#" }], "description": thenKeyword.description }, + "else": { "allOf": [{ "$ref": "#" }], "description": elseKeyword.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..98ad9805 100644 --- a/draft-2019-09/meta/applicator.js +++ b/draft-2019-09/meta/applicator.js @@ -1,3 +1,19 @@ +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 ifKeyword from "../../lib/keywords/if.js"; +import thenKeyword from "../../lib/keywords/then.js"; +import elseKeyword 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", @@ -11,36 +27,40 @@ export default { "anyOf": [ { "$recursiveRef": "#" }, { "$ref": "#/$defs/schemaArray" } - ] + ], + "description": items.description }, - "contains": { "$recursiveRef": "#" }, - "additionalProperties": { "$recursiveRef": "#" }, + "contains": { "$recursiveRef": "#", "description": contains.description }, + "additionalProperties": { "$recursiveRef": "#", "description": additionalProperties.description }, "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": "#" - } + }, + "description": dependentSchemas.description }, - "propertyNames": { "$recursiveRef": "#" }, - "if": { "$recursiveRef": "#" }, - "then": { "$recursiveRef": "#" }, - "else": { "$recursiveRef": "#" }, - "allOf": { "$ref": "#/$defs/schemaArray" }, - "anyOf": { "$ref": "#/$defs/schemaArray" }, - "oneOf": { "$ref": "#/$defs/schemaArray" }, - "not": { "$recursiveRef": "#" } + "propertyNames": { "$recursiveRef": "#", "description": propertyNames.description }, + "if": { "$recursiveRef": "#", "description": ifKeyword.description }, + "then": { "$recursiveRef": "#", "description": thenKeyword.description }, + "else": { "$recursiveRef": "#", "description": elseKeyword.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..b1a23ca4 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,8 @@ 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..b5516a44 100644 --- a/draft-2019-09/meta/core.js +++ b/draft-2019-09/meta/core.js @@ -1,3 +1,11 @@ +import id from "../../lib/keywords/id.js"; +import ref from "../../lib/keywords/ref.js"; +import definitions from "../../lib/keywords/definitions.js"; +import comment from "../../lib/keywords/comment.js"; +import vocabulary from "../../lib/keywords/vocabulary.js"; +import anchor from "../../lib/keywords/anchor.js"; + + export default { "$id": "https://json-schema.org/draft/2019-09/meta/core", "$schema": "https://json-schema.org/draft/2019-09/schema", @@ -9,19 +17,25 @@ 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", @@ -33,6 +47,7 @@ export default { }, "$vocabulary": { "type": "object", + "description": vocabulary.description, "propertyNames": { "type": "string", "format": "uri" @@ -42,12 +57,14 @@ export default { } }, "$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..355243af 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,6 @@ 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..77970444 100644 --- a/draft-2019-09/meta/meta-data.js +++ b/draft-2019-09/meta/meta-data.js @@ -1,3 +1,11 @@ +import title from "../../lib/keywords/title.js"; +import description from "../../lib/keywords/description.js"; +import writeOnly from "../../lib/keywords/writeOnly.js"; +import readOnly from "../../lib/keywords/readOnly.js"; +import examples from "../../lib/keywords/examples.js"; +import deprecated from "../../lib/keywords/deprecated.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 +15,33 @@ export default { "properties": { "title": { - "type": "string" + "type": "string", + "description": title.description }, "description": { - "type": "string" + "type": "string", + "description": description.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..6dacefd8 100644 --- a/draft-2019-09/meta/validation.js +++ b/draft-2019-09/meta/validation.js @@ -1,3 +1,24 @@ +import typeKeyword from "../../lib/keywords/type.js"; +import enumKeyword from "../../lib/keywords/enum.js"; +import pattern from "../../lib/keywords/pattern.js"; +import minLength from "../../lib/keywords/minLength.js"; +import maxLength from "../../lib/keywords/maxLength.js"; +import exclusiveMaximum from "../../lib/keywords/exclusiveMaximum.js"; +import multipleOf from "../../lib/keywords/multipleOf.js"; +import exclusiveMinimum from "../../lib/keywords/exclusiveMinimum.js"; +import maximum from "../../lib/keywords/maximum.js"; +import minimum from "../../lib/keywords/minimum.js"; +import dependentRequired from "../../lib/keywords/dependentRequired.js"; +import maxProperties from "../../lib/keywords/maxProperties.js"; +import minProperties from "../../lib/keywords/minProperties.js"; +import required from "../../lib/keywords/required.js"; +import maxItems from "../../lib/keywords/maxItems.js"; +import minItems from "../../lib/keywords/minItems.js"; +import maxContains from "../../lib/keywords/maxContains.js"; +import minContains from "../../lib/keywords/minContains.js"; +import uniqueItems from "../../lib/keywords/uniqueItems.js"; + + export default { "$id": "https://json-schema.org/draft/2019-09/meta/validation", "$schema": "https://json-schema.org/draft/2019-09/schema", @@ -7,50 +28,60 @@ 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" }, - "minLength": { "$ref": "#/$defs/nonNegativeIntegerDefault0" }, + "maxLength": { "$ref": "#/$defs/nonNegativeInteger", "description": maxLength.description }, + "minLength": { "$ref": "#/$defs/nonNegativeIntegerDefault0", "description": minLength.description }, "pattern": { "type": "string", - "format": "regex" + "format": "regex", + "description": pattern.description }, - "maxItems": { "$ref": "#/$defs/nonNegativeInteger" }, - "minItems": { "$ref": "#/$defs/nonNegativeIntegerDefault0" }, + "maxItems": { "$ref": "#/$defs/nonNegativeInteger", "description": maxItems.description }, + "minItems": { "$ref": "#/$defs/nonNegativeIntegerDefault0", "description": minItems.description }, "uniqueItems": { "type": "boolean", - "default": false + "default": false, + "description": uniqueItems.description }, - "maxContains": { "$ref": "#/$defs/nonNegativeInteger" }, + "maxContains": { "$ref": "#/$defs/nonNegativeInteger", "description": maxContains.description }, "minContains": { "$ref": "#/$defs/nonNegativeInteger", - "default": 1 + "default": 1, + "description": minContains.description }, - "maxProperties": { "$ref": "#/$defs/nonNegativeInteger" }, - "minProperties": { "$ref": "#/$defs/nonNegativeIntegerDefault0" }, - "required": { "$ref": "#/$defs/stringArray" }, + "maxProperties": { "$ref": "#/$defs/nonNegativeInteger", "description": maxProperties.description }, + "minProperties": { "$ref": "#/$defs/nonNegativeIntegerDefault0", "description": minProperties.description }, + "required": { "$ref": "#/$defs/stringArray", "description": required.description }, "dependentRequired": { "type": "object", "additionalProperties": { "$ref": "#/$defs/stringArray" - } + }, + "description": dependentRequired.description }, "const": true, "enum": { "type": "array", - "items": true + "items": true, + "description": enumKeyword.description }, "type": { "anyOf": [ @@ -61,7 +92,8 @@ export default { "minItems": 1, "uniqueItems": true } - ] + ], + "description": typeKeyword.description } }, "$defs": { 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..1811ae33 100644 --- a/draft-2020-12/meta/applicator.js +++ b/draft-2020-12/meta/applicator.js @@ -1,3 +1,20 @@ +import allOfKeyword from "../../lib/keywords/allOf.js"; +import anyOfKeyword from "../../lib/keywords/anyOf.js"; +import oneOfKeyword from "../../lib/keywords/oneOf.js"; +import thenKeyword from "../../lib/keywords/then.js"; +import ifKeyword from "../../lib/keywords/if.js"; +import elseKeyword from "../../lib/keywords/else.js"; +import notKeyword from "../../lib/keywords/not.js"; +import propertiesKeyword from "../../lib/keywords/properties.js"; +import additionalPropertiesKeyword from "../../lib/keywords/additionalProperties.js"; +import patternPropertiesKeyword from "../../lib/keywords/patternProperties.js"; +import dependentSchemasKeyword from "../../lib/keywords/dependentSchemas.js"; +import propertyNamesKeyword from "../../lib/keywords/propertyNames.js"; +import itemsKeyword from "../../lib/keywords/items.js"; +import prefixItemsKeyword from "../../lib/keywords/prefixItems.js"; +import containsKeyword from "../../lib/keywords/contains.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": prefixItemsKeyword.description + }, + "items": { + "$dynamicRef": "#meta", + "description": itemsKeyword.description + }, + "contains": { + "$dynamicRef": "#meta", + "description": containsKeyword.description + }, + "additionalProperties": { + "$dynamicRef": "#meta", + "description": additionalPropertiesKeyword.description + }, "properties": { "type": "object", "additionalProperties": { "$dynamicRef": "#meta" }, - "default": {} + "default": {}, + "description": propertiesKeyword.description }, "patternProperties": { "type": "object", "additionalProperties": { "$dynamicRef": "#meta" }, "propertyNames": { "format": "regex" }, - "default": {} + "default": {}, + "description": patternPropertiesKeyword.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": dependentSchemasKeyword.description + }, + "propertyNames": { + "$dynamicRef": "#meta", + "description": propertyNamesKeyword.description + }, + "if": { + "$dynamicRef": "#meta", + "description": ifKeyword.description + }, + "then": { + "$dynamicRef": "#meta", + "description": thenKeyword.description + }, + "else": { + "$dynamicRef": "#meta", + "description": elseKeyword.description + }, + "allOf": { + "$ref": "#/$defs/schemaArray", + "description": allOfKeyword.description + }, + "anyOf": { + "$ref": "#/$defs/schemaArray", + "description": anyOfKeyword.description + }, + "oneOf": { + "$ref": "#/$defs/schemaArray", + "description": oneOfKeyword.description + }, + "not": { + "$dynamicRef": "#meta", + "description": notKeyword.description + } }, "$defs": { "schemaArray": { diff --git a/draft-2020-12/meta/content.js b/draft-2020-12/meta/content.js index 8c542eb2..197847ef 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,8 @@ 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..32e4ba09 100644 --- a/draft-2020-12/meta/core.js +++ b/draft-2020-12/meta/core.js @@ -1,3 +1,13 @@ +import idKeyword from "../../lib/keywords/id.js"; +import refKeyword from "../../lib/keywords/ref.js"; +import anchorKeyword from "../../lib/keywords/anchor.js"; +import dynamicAnchorKeyword from "../../lib/keywords/dynamicAnchor.js"; +import dynamicRefKeyword from "../../lib/keywords/dynamicRef.js"; +import vocabularyKeyword from "../../lib/keywords/vocabulary.js"; +import commentKeyword from "../../lib/keywords/comment.js"; +import definitionsKeyword 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": idKeyword.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": anchorKeyword.description }, "$ref": { "type": "string", - "format": "uri-reference" + "format": "uri-reference", + "description": refKeyword.description }, "$dynamicRef": { "type": "string", - "format": "uri-reference" + "format": "uri-reference", + "description": dynamicRefKeyword.description }, "$dynamicAnchor": { "type": "string", - "pattern": "^[A-Za-z_][-A-Za-z0-9._]*$" + "pattern": "^[A-Za-z_][-A-Za-z0-9._]*$", + "description": dynamicAnchorKeyword.description }, "$vocabulary": { "type": "object", + "description": vocabularyKeyword.description, "propertyNames": { "type": "string", "format": "uri" @@ -42,12 +59,14 @@ export default { } }, "$comment": { - "type": "string" + "type": "string", + "description": commentKeyword.description }, "$defs": { "type": "object", "additionalProperties": { "$dynamicRef": "#meta" }, - "default": {} + "default": {}, + "description": definitionsKeyword.description } } }; diff --git a/draft-2020-12/meta/format-annotation.js b/draft-2020-12/meta/format-annotation.js index f20e1ec3..c890f45a 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,6 @@ 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..cb16b3cc 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,6 @@ 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..76750a1c 100644 --- a/draft-2020-12/meta/meta-data.js +++ b/draft-2020-12/meta/meta-data.js @@ -1,3 +1,11 @@ +import title from "../../lib/keywords/title.js"; +import description from "../../lib/keywords/description.js"; +import writeOnly from "../../lib/keywords/writeOnly.js"; +import readOnly from "../../lib/keywords/readOnly.js"; +import examples from "../../lib/keywords/examples.js"; +import deprecated from "../../lib/keywords/deprecated.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 +15,33 @@ export default { "properties": { "title": { - "type": "string" + "type": "string", + "description": title.description }, "description": { - "type": "string" + "type": "string", + "description": description.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..e7ba8e62 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,7 @@ 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..7fe62751 100644 --- a/draft-2020-12/meta/validation.js +++ b/draft-2020-12/meta/validation.js @@ -1,3 +1,24 @@ +import typeKeyword from "../../lib/keywords/type.js"; +import enumKeyword from "../../lib/keywords/enum.js"; +import pattern from "../../lib/keywords/pattern.js"; +import minLength from "../../lib/keywords/minLength.js"; +import maxLength from "../../lib/keywords/maxLength.js"; +import exclusiveMaximum from "../../lib/keywords/exclusiveMaximum.js"; +import multipleOf from "../../lib/keywords/multipleOf.js"; +import exclusiveMinimum from "../../lib/keywords/exclusiveMinimum.js"; +import maximum from "../../lib/keywords/maximum.js"; +import minimum from "../../lib/keywords/minimum.js"; +import dependentRequired from "../../lib/keywords/dependentRequired.js"; +import maxProperties from "../../lib/keywords/maxProperties.js"; +import minProperties from "../../lib/keywords/minProperties.js"; +import required from "../../lib/keywords/required.js"; +import maxItems from "../../lib/keywords/maxItems.js"; +import minItems from "../../lib/keywords/minItems.js"; +import maxContains from "../../lib/keywords/maxContains.js"; +import minContains from "../../lib/keywords/minContains.js"; +import uniqueItems from "../../lib/keywords/uniqueItems.js"; + + export default { "$id": "https://json-schema.org/draft/2020-12/meta/validation", "$schema": "https://json-schema.org/draft/2020-12/schema", @@ -7,50 +28,60 @@ 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" }, - "minLength": { "$ref": "#/$defs/nonNegativeIntegerDefault0" }, + "maxLength": { "$ref": "#/$defs/nonNegativeInteger", "description": maxLength.description }, + "minLength": { "$ref": "#/$defs/nonNegativeIntegerDefault0", "description": minLength.description }, "pattern": { "type": "string", - "format": "regex" + "format": "regex", + "description": pattern.description }, - "maxItems": { "$ref": "#/$defs/nonNegativeInteger" }, - "minItems": { "$ref": "#/$defs/nonNegativeIntegerDefault0" }, + "maxItems": { "$ref": "#/$defs/nonNegativeInteger", "description": maxItems.description }, + "minItems": { "$ref": "#/$defs/nonNegativeIntegerDefault0", "description": minItems.description }, "uniqueItems": { "type": "boolean", - "default": false + "default": false, + "description": uniqueItems.description }, - "maxContains": { "$ref": "#/$defs/nonNegativeInteger" }, + "maxContains": { "$ref": "#/$defs/nonNegativeInteger", "description": maxContains.description }, "minContains": { "$ref": "#/$defs/nonNegativeInteger", - "default": 1 + "default": 1, + "description": minContains.description }, - "maxProperties": { "$ref": "#/$defs/nonNegativeInteger" }, - "minProperties": { "$ref": "#/$defs/nonNegativeIntegerDefault0" }, - "required": { "$ref": "#/$defs/stringArray" }, + "maxProperties": { "$ref": "#/$defs/nonNegativeInteger", "description": maxProperties.description }, + "minProperties": { "$ref": "#/$defs/nonNegativeIntegerDefault0", "description": minProperties.description }, + "required": { "$ref": "#/$defs/stringArray", "description": required.description }, "dependentRequired": { "type": "object", "additionalProperties": { "$ref": "#/$defs/stringArray" - } + }, + "description": dependentRequired.description }, "const": true, "enum": { "type": "array", - "items": true + "items": true, + "description": enumKeyword.description }, "type": { "anyOf": [ @@ -61,7 +92,8 @@ export default { "minItems": 1, "uniqueItems": true } - ] + ], + "description": typeKeyword.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 };