From aeb748a4af025e03856613da14316da5310db4f9 Mon Sep 17 00:00:00 2001 From: Ed Mackey Date: Thu, 23 Sep 2021 13:38:07 -0400 Subject: [PATCH 1/6] Accept newer schemas, handle new exclusive min/max schema. --- lib/generateMarkdown.js | 50 +++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/lib/generateMarkdown.js b/lib/generateMarkdown.js index 446b87e..c0ac95f 100644 --- a/lib/generateMarkdown.js +++ b/lib/generateMarkdown.js @@ -41,13 +41,13 @@ function generateMarkdown(options) { if (schemaRef === 'http://json-schema.org/draft-03/schema') { resolved = schema3.resolve(schema, options.fileName, options.searchPath, options.ignorableTypes, options.debug); } - else if (schemaRef === 'http://json-schema.org/draft-04/schema') { - resolved = schema4.resolve(schema, options.fileName, options.searchPath, options.ignorableTypes, options.debug); - } else { - resolved = schema3.resolve(schema, options.fileName, options.searchPath, options.ignorableTypes, options.debug); - if (!options.suppressWarnings) { - md += '> WETZEL_WARNING: Only JSON Schema 3 or 4 is supported. Treating as Schema 3.\n\n'; + resolved = schema4.resolve(schema, options.fileName, options.searchPath, options.ignorableTypes, options.debug); + if ((!options.suppressWarnings) && + (schemaRef === 'http://json-schema.org/draft-04/schema' || + schemaRef === 'http://json-schema.org/draft-07/schema' || + schemaRef === 'https://json-schema.org/draft/2020-12/schema')) { + md += '> WETZEL_WARNING: Unrecognized JSON Schema.\n\n'; } } } @@ -292,6 +292,18 @@ function createPropertiesDetails(schema, title, headerLevel, knownTypes, autoLin // TODO: items is a full schema var items = property.items; if (defined(items)) { + // Downgrade newer schemas + if (defined(items.exclusiveMinimum) && typeof items.exclusiveMinimum === 'number') + { + items.minimum = items.exclusiveMinimum; + items.exclusiveMinimum = true; + } + if (defined(items.exclusiveMaximum) && typeof items.exclusiveMaximum === 'number') + { + items.maximum = items.exclusiveMaximum; + items.exclusiveMaximum = true; + } + var itemsExclusiveMinimum = (defined(items.exclusiveMinimum) && items.exclusiveMinimum); var minString = itemsExclusiveMinimum ? 'greater than' : 'greater than or equal to'; @@ -324,16 +336,26 @@ function createPropertiesDetails(schema, title, headerLevel, knownTypes, autoLin md += style.bulletItem(style.propertyDetails('Required') + ': ' + summary.required, 0); - var minimum = property.minimum; - if (defined(minimum)) { - var exclusiveMinimum = (defined(property.exclusiveMinimum) && property.exclusiveMinimum); - md += style.bulletItem(style.propertyDetails('Minimum') + ': ' + style.minMax((exclusiveMinimum ? ' > ' : ' >= ') + minimum), 0); + if (defined(property.exclusiveMinimum) && typeof property.exclusiveMinimum === 'number') + { + md += style.bulletItem(style.propertyDetails('Minimum') + ': ' + style.minMax(' > ' + property.exclusiveMinimum), 0); + } else { + var minimum = property.minimum; + if (defined(minimum)) { + var exclusiveMinimum = (defined(property.exclusiveMinimum) && property.exclusiveMinimum); + md += style.bulletItem(style.propertyDetails('Minimum') + ': ' + style.minMax((exclusiveMinimum ? ' > ' : ' >= ') + minimum), 0); + } } - var maximum = property.maximum; - if (defined(maximum)) { - var exclusiveMaximum = (defined(property.exclusiveMaximum) && property.exclusiveMaximum); - md += style.bulletItem(style.propertyDetails('Maximum') + ': ' + style.minMax((exclusiveMaximum ? ' < ' : ' <= ') + maximum), 0); + if (defined(property.exclusiveMaximum) && typeof property.exclusiveMaximum === 'number') + { + md += style.bulletItem(style.propertyDetails('Maximum') + ': ' + style.minMax(' < ' + property.exclusiveMaximum), 0); + } else { + var maximum = property.maximum; + if (defined(maximum)) { + var exclusiveMaximum = (defined(property.exclusiveMaximum) && property.exclusiveMaximum); + md += style.bulletItem(style.propertyDetails('Maximum') + ': ' + style.minMax((exclusiveMaximum ? ' < ' : ' <= ') + maximum), 0); + } } var format = property.format; From dbb715794825081c77ba20a5e5e37c3bce854306 Mon Sep 17 00:00:00 2001 From: Ed Mackey Date: Thu, 23 Sep 2021 14:43:46 -0400 Subject: [PATCH 2/6] Add support for using const in place of enum. --- lib/generateMarkdown.js | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/lib/generateMarkdown.js b/lib/generateMarkdown.js index c0ac95f..91cad93 100644 --- a/lib/generateMarkdown.js +++ b/lib/generateMarkdown.js @@ -542,19 +542,30 @@ function getAnyOfEnumString(schema, type, depth) { var length = propertyAnyOf.length; for (var i = 0; i < length; ++i) { var element = propertyAnyOf[i]; + var constValue = element['const']; var enumValue = element['enum']; var enumDescription = element['description']; + var enumString; - // The likely scenario when there's no enum value is that it's the object - // containing the _type_ of the enum. Otherwise, it should be an array with - // a single value in it. - if (!defined(enumValue) || !Array.isArray(enumValue) || enumValue.length === 0) { - continue; + // Check if 'const' has been used in place of 'enum'. + if (defined(constValue)) { + enumString = style.enumElement(constValue, type); + if (defined(enumDescription)) { + enumString += " " + enumDescription; + } } + else { + // The likely scenario when there's no enum value is that it's the object + // containing the _type_ of the enum. Otherwise, it should be an array with + // a single value in it. + if (!defined(enumValue) || !Array.isArray(enumValue) || enumValue.length === 0) { + continue; + } - var enumString = style.enumElement(enumValue[0], type); - if (defined(enumDescription)) { - enumString += " " + enumDescription; + enumString = style.enumElement(enumValue[0], type); + if (defined(enumDescription)) { + enumString += " " + enumDescription; + } } allowedValues += style.bulletItem(enumString, depth); From 6871d36cc2249ae21776912f42c0e44edb7dc9a6 Mon Sep 17 00:00:00 2001 From: Ed Mackey Date: Thu, 23 Sep 2021 14:49:59 -0400 Subject: [PATCH 3/6] Fix schema detection problem --- lib/generateMarkdown.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/generateMarkdown.js b/lib/generateMarkdown.js index 91cad93..738d052 100644 --- a/lib/generateMarkdown.js +++ b/lib/generateMarkdown.js @@ -44,9 +44,9 @@ function generateMarkdown(options) { else { resolved = schema4.resolve(schema, options.fileName, options.searchPath, options.ignorableTypes, options.debug); if ((!options.suppressWarnings) && - (schemaRef === 'http://json-schema.org/draft-04/schema' || - schemaRef === 'http://json-schema.org/draft-07/schema' || - schemaRef === 'https://json-schema.org/draft/2020-12/schema')) { + (schemaRef !== 'http://json-schema.org/draft-04/schema' && + schemaRef !== 'http://json-schema.org/draft-07/schema' && + schemaRef !== 'https://json-schema.org/draft/2020-12/schema')) { md += '> WETZEL_WARNING: Unrecognized JSON Schema.\n\n'; } } From 2e516d35345ed21ead4f50c3bb2e78beaef9510c Mon Sep 17 00:00:00 2001 From: Ed Mackey Date: Thu, 23 Sep 2021 17:18:37 -0400 Subject: [PATCH 4/6] Add tests for 2020-12 schema changes. --- test/test-golden/v2020-12-embed.adoc | 74 +++++++++++++++++++ test/test-golden/v2020-12-embedJSON.adoc | 11 +++ test/test-golden/v2020-12-keyword.md | 57 +++++++++++++++ test/test-golden/v2020-12-linked.adoc | 76 ++++++++++++++++++++ test/test-golden/v2020-12-linked.md | 59 +++++++++++++++ test/test-golden/v2020-12-remote.adoc | 74 +++++++++++++++++++ test/test-golden/v2020-12-remote.md | 57 +++++++++++++++ test/test-golden/v2020-12-simple.adoc | 74 +++++++++++++++++++ test/test-golden/v2020-12-simple.md | 57 +++++++++++++++ test/test-schemas/index.json | 3 + test/test-schemas/v2020-12/image.schema.json | 48 +++++++++++++ 11 files changed, 590 insertions(+) create mode 100644 test/test-golden/v2020-12-embed.adoc create mode 100644 test/test-golden/v2020-12-embedJSON.adoc create mode 100644 test/test-golden/v2020-12-keyword.md create mode 100644 test/test-golden/v2020-12-linked.adoc create mode 100644 test/test-golden/v2020-12-linked.md create mode 100644 test/test-golden/v2020-12-remote.adoc create mode 100644 test/test-golden/v2020-12-remote.md create mode 100644 test/test-golden/v2020-12-simple.adoc create mode 100644 test/test-golden/v2020-12-simple.md create mode 100644 test/test-schemas/v2020-12/image.schema.json diff --git a/test/test-golden/v2020-12-embed.adoc b/test/test-golden/v2020-12-embed.adoc new file mode 100644 index 0000000..5d7a920 --- /dev/null +++ b/test/test-golden/v2020-12-embed.adoc @@ -0,0 +1,74 @@ + + +''' +[#reference-image] +== Image + +Image data used to create a texture. Image **MAY** be referenced by an URI (or IRI) or a buffer view index. + +.`Image` Properties +|=== +| |Type|Description|Required + +|**uri** +|`string` +|The URI (or IRI) of the image. +|No + +|**mimeType** +|`string` +|The image's media type. This field **MUST** be defined when `bufferView` is defined. +|No + +|**bufferView** +|`integer` +|The index of the bufferView that contains the image. This field **MUST NOT** be defined when `uri` is defined. +|No + +|**fraction** +|`number` +|A number that **MUST** be between zero and one. +|No + +|=== + +Additional properties are allowed. + +* **JSON schema**: <> + +=== Image.uri + +The URI (or IRI) of the image. Relative paths are relative to the current glTF asset. Instead of referencing an external file, this field **MAY** contain a `data:`-URI. This field **MUST NOT** be defined when `bufferView` is defined. + +* **Type**: `string` +* **Required**: No +* **Format**: iri-reference + +=== Image.mimeType + +The image's media type. This field **MUST** be defined when `bufferView` is defined. + +* **Type**: `string` +* **Required**: No +* **Allowed values**: +** `"image/jpeg"` +** `"image/png"` + +=== Image.bufferView + +The index of the bufferView that contains the image. This field **MUST NOT** be defined when `uri` is defined. + +* **Type**: `integer` +* **Required**: No +* **Minimum**: `>= 0` + +=== Image.fraction + +A number that **MUST** be between zero and one. + +* **Type**: `number` +* **Required**: No +* **Minimum**: `> 0` +* **Maximum**: `< 1` + + diff --git a/test/test-golden/v2020-12-embedJSON.adoc b/test/test-golden/v2020-12-embedJSON.adoc new file mode 100644 index 0000000..66b199c --- /dev/null +++ b/test/test-golden/v2020-12-embedJSON.adoc @@ -0,0 +1,11 @@ + + +[#schema-reference-image] +== JSON Schema for Image + +[source,json] +---- +include::schema/image.schema.json[] +---- + +<<< diff --git a/test/test-golden/v2020-12-keyword.md b/test/test-golden/v2020-12-keyword.md new file mode 100644 index 0000000..b8f7c45 --- /dev/null +++ b/test/test-golden/v2020-12-keyword.md @@ -0,0 +1,57 @@ +# Objects +* [`Image`](#reference-image) (root object) + + +--------------------------------------- + +## Image + +Image data used to create a texture. Image **MAY** be referenced by an URI (or IRI) or a buffer view index. + +**`Image` Properties** + +| |Type|Description|Required| +|---|---|---|---| +|**uri**|`string`|The URI (or IRI) of the image.|No| +|**mimeType**|`string`|The image's media type. This field **MUST** be defined when `bufferView` is defined.|No| +|**bufferView**|`integer`|The index of the bufferView that contains the image. This field **MUST NOT** be defined when `uri` is defined.|No| +|**fraction**|`number`|A number that **MUST** be between zero and one.|No| + +Additional properties are allowed. + +### Image.uri + +The URI (or IRI) of the image. Relative paths are relative to the current glTF asset. Instead of referencing an external file, this field **MAY** contain a `data:`-URI. This field **MUST NOT** be defined when `bufferView` is defined. + +* **Type**: `string` +* **Required**: No +* **Format**: iri-reference + +### Image.mimeType + +The image's media type. This field **MUST** be defined when `bufferView` is defined. + +* **Type**: `string` +* **Required**: No +* **Allowed values**: + * `"image/jpeg"` + * `"image/png"` + +### Image.bufferView + +The index of the bufferView that contains the image. This field **MUST NOT** be defined when `uri` is defined. + +* **Type**: `integer` +* **Required**: No +* **Minimum**: ` >= 0` + +### Image.fraction + +A number that **MUST** be between zero and one. + +* **Type**: `number` +* **Required**: No +* **Minimum**: ` > 0` +* **Maximum**: ` < 1` + + diff --git a/test/test-golden/v2020-12-linked.adoc b/test/test-golden/v2020-12-linked.adoc new file mode 100644 index 0000000..24cce58 --- /dev/null +++ b/test/test-golden/v2020-12-linked.adoc @@ -0,0 +1,76 @@ +== Objects +* <> (root object) + + +''' +[#reference-image] +=== Image + +Image data used to create a texture. Image **MAY** be referenced by an URI (or IRI) or a buffer view index. + +.`Image` Properties +|=== +| |Type|Description|Required + +|**uri** +|`string` +|The URI (or IRI) of the image. +|No + +|**mimeType** +|`string` +|The image's media type. This field **MUST** be defined when `bufferView` is defined. +|No + +|**bufferView** +|`integer` +|The index of the bufferView that contains the image. This field **MUST NOT** be defined when `uri` is defined. +|No + +|**fraction** +|`number` +|A number that **MUST** be between zero and one. +|No + +|=== + +Additional properties are allowed. + +* **JSON schema**: link:schema/image.schema.json[image.schema.json] + +==== Image.uri + +The URI (or IRI) of the image. Relative paths are relative to the current glTF asset. Instead of referencing an external file, this field **MAY** contain a `data:`-URI. This field **MUST NOT** be defined when `bufferView` is defined. + +* **Type**: `string` +* **Required**: No +* **Format**: iri-reference + +==== Image.mimeType + +The image's media type. This field **MUST** be defined when `bufferView` is defined. + +* **Type**: `string` +* **Required**: No +* **Allowed values**: +** `"image/jpeg"` +** `"image/png"` + +==== Image.bufferView + +The index of the bufferView that contains the image. This field **MUST NOT** be defined when `uri` is defined. + +* **Type**: `integer` +* **Required**: No +* **Minimum**: `>= 0` + +==== Image.fraction + +A number that **MUST** be between zero and one. + +* **Type**: `number` +* **Required**: No +* **Minimum**: `> 0` +* **Maximum**: `< 1` + + diff --git a/test/test-golden/v2020-12-linked.md b/test/test-golden/v2020-12-linked.md new file mode 100644 index 0000000..7d4a426 --- /dev/null +++ b/test/test-golden/v2020-12-linked.md @@ -0,0 +1,59 @@ +## Objects +* [`Image`](#reference-image) (root object) + + +--------------------------------------- + +### Image + +Image data used to create a texture. Image **MAY** be referenced by an URI (or IRI) or a buffer view index. + +**`Image` Properties** + +| |Type|Description|Required| +|---|---|---|---| +|**uri**|`string`|The URI (or IRI) of the image.|No| +|**mimeType**|`string`|The image's media type. This field **MUST** be defined when `bufferView` is defined.|No| +|**bufferView**|`integer`|The index of the bufferView that contains the image. This field **MUST NOT** be defined when `uri` is defined.|No| +|**fraction**|`number`|A number that **MUST** be between zero and one.|No| + +Additional properties are allowed. + +* **JSON schema**: [image.schema.json](schema/image.schema.json) + +#### Image.uri + +The URI (or IRI) of the image. Relative paths are relative to the current glTF asset. Instead of referencing an external file, this field **MAY** contain a `data:`-URI. This field **MUST NOT** be defined when `bufferView` is defined. + +* **Type**: `string` +* **Required**: No +* **Format**: iri-reference + +#### Image.mimeType + +The image's media type. This field **MUST** be defined when `bufferView` is defined. + +* **Type**: `string` +* **Required**: No +* **Allowed values**: + * `"image/jpeg"` + * `"image/png"` + +#### Image.bufferView + +The index of the bufferView that contains the image. This field **MUST NOT** be defined when `uri` is defined. + +* **Type**: `integer` +* **Required**: No +* **Minimum**: ` >= 0` + +#### Image.fraction + +A number that **MUST** be between zero and one. + +* **Type**: `number` +* **Required**: No +* **Minimum**: ` > 0` +* **Maximum**: ` < 1` + + diff --git a/test/test-golden/v2020-12-remote.adoc b/test/test-golden/v2020-12-remote.adoc new file mode 100644 index 0000000..53ad3bf --- /dev/null +++ b/test/test-golden/v2020-12-remote.adoc @@ -0,0 +1,74 @@ + + +''' +[#reference-image] +== Image + +Image data used to create a texture. Image **MAY** be referenced by an URI (or IRI) or a buffer view index. + +.`Image` Properties +|=== +| |Type|Description|Required + +|**uri** +|`string` +|The URI (or IRI) of the image. +|No + +|**mimeType** +|`string` +|The image's media type. This field **MUST** be defined when `bufferView` is defined. +|No + +|**bufferView** +|`integer` +|The index of the bufferView that contains the image. This field **MUST NOT** be defined when `uri` is defined. +|No + +|**fraction** +|`number` +|A number that **MUST** be between zero and one. +|No + +|=== + +Additional properties are allowed. + +* **JSON schema**: link:https://www.khronos.org/wetzel/just/testing/schema/image.schema.json[image.schema.json] + +=== Image.uri + +The URI (or IRI) of the image. Relative paths are relative to the current glTF asset. Instead of referencing an external file, this field **MAY** contain a `data:`-URI. This field **MUST NOT** be defined when `bufferView` is defined. + +* **Type**: `string` +* **Required**: No +* **Format**: iri-reference + +=== Image.mimeType + +The image's media type. This field **MUST** be defined when `bufferView` is defined. + +* **Type**: `string` +* **Required**: No +* **Allowed values**: +** `"image/jpeg"` +** `"image/png"` + +=== Image.bufferView + +The index of the bufferView that contains the image. This field **MUST NOT** be defined when `uri` is defined. + +* **Type**: `integer` +* **Required**: No +* **Minimum**: `>= 0` + +=== Image.fraction + +A number that **MUST** be between zero and one. + +* **Type**: `number` +* **Required**: No +* **Minimum**: `> 0` +* **Maximum**: `< 1` + + diff --git a/test/test-golden/v2020-12-remote.md b/test/test-golden/v2020-12-remote.md new file mode 100644 index 0000000..1f73fe8 --- /dev/null +++ b/test/test-golden/v2020-12-remote.md @@ -0,0 +1,57 @@ + + +--------------------------------------- + +## Image + +Image data used to create a texture. Image **MAY** be referenced by an URI (or IRI) or a buffer view index. + +**`Image` Properties** + +| |Type|Description|Required| +|---|---|---|---| +|**uri**|`string`|The URI (or IRI) of the image.|No| +|**mimeType**|`string`|The image's media type. This field **MUST** be defined when `bufferView` is defined.|No| +|**bufferView**|`integer`|The index of the bufferView that contains the image. This field **MUST NOT** be defined when `uri` is defined.|No| +|**fraction**|`number`|A number that **MUST** be between zero and one.|No| + +Additional properties are allowed. + +* **JSON schema**: [image.schema.json](https://www.khronos.org/wetzel/just/testing/schema/image.schema.json) + +### Image.uri + +The URI (or IRI) of the image. Relative paths are relative to the current glTF asset. Instead of referencing an external file, this field **MAY** contain a `data:`-URI. This field **MUST NOT** be defined when `bufferView` is defined. + +* **Type**: `string` +* **Required**: No +* **Format**: iri-reference + +### Image.mimeType + +The image's media type. This field **MUST** be defined when `bufferView` is defined. + +* **Type**: `string` +* **Required**: No +* **Allowed values**: + * `"image/jpeg"` + * `"image/png"` + +### Image.bufferView + +The index of the bufferView that contains the image. This field **MUST NOT** be defined when `uri` is defined. + +* **Type**: `integer` +* **Required**: No +* **Minimum**: ` >= 0` + +### Image.fraction + +A number that **MUST** be between zero and one. + +* **Type**: `number` +* **Required**: No +* **Minimum**: ` > 0` +* **Maximum**: ` < 1` + + diff --git a/test/test-golden/v2020-12-simple.adoc b/test/test-golden/v2020-12-simple.adoc new file mode 100644 index 0000000..7d11cd1 --- /dev/null +++ b/test/test-golden/v2020-12-simple.adoc @@ -0,0 +1,74 @@ += Objects +* <> (root object) + + +''' +[#reference-image] +== Image + +Image data used to create a texture. Image **MAY** be referenced by an URI (or IRI) or a buffer view index. + +.`Image` Properties +|=== +| |Type|Description|Required + +|**uri** +|`string` +|The URI (or IRI) of the image. +|No + +|**mimeType** +|`string` +|The image's media type. This field **MUST** be defined when `bufferView` is defined. +|No + +|**bufferView** +|`integer` +|The index of the bufferView that contains the image. This field **MUST NOT** be defined when `uri` is defined. +|No + +|**fraction** +|`number` +|A number that **MUST** be between zero and one. +|No + +|=== + +Additional properties are allowed. + +=== Image.uri + +The URI (or IRI) of the image. Relative paths are relative to the current glTF asset. Instead of referencing an external file, this field **MAY** contain a `data:`-URI. This field **MUST NOT** be defined when `bufferView` is defined. + +* **Type**: `string` +* **Required**: No +* **Format**: iri-reference + +=== Image.mimeType + +The image's media type. This field **MUST** be defined when `bufferView` is defined. + +* **Type**: `string` +* **Required**: No +* **Allowed values**: +** `"image/jpeg"` +** `"image/png"` + +=== Image.bufferView + +The index of the bufferView that contains the image. This field **MUST NOT** be defined when `uri` is defined. + +* **Type**: `integer` +* **Required**: No +* **Minimum**: `>= 0` + +=== Image.fraction + +A number that **MUST** be between zero and one. + +* **Type**: `number` +* **Required**: No +* **Minimum**: `> 0` +* **Maximum**: `< 1` + + diff --git a/test/test-golden/v2020-12-simple.md b/test/test-golden/v2020-12-simple.md new file mode 100644 index 0000000..b8f7c45 --- /dev/null +++ b/test/test-golden/v2020-12-simple.md @@ -0,0 +1,57 @@ +# Objects +* [`Image`](#reference-image) (root object) + + +--------------------------------------- + +## Image + +Image data used to create a texture. Image **MAY** be referenced by an URI (or IRI) or a buffer view index. + +**`Image` Properties** + +| |Type|Description|Required| +|---|---|---|---| +|**uri**|`string`|The URI (or IRI) of the image.|No| +|**mimeType**|`string`|The image's media type. This field **MUST** be defined when `bufferView` is defined.|No| +|**bufferView**|`integer`|The index of the bufferView that contains the image. This field **MUST NOT** be defined when `uri` is defined.|No| +|**fraction**|`number`|A number that **MUST** be between zero and one.|No| + +Additional properties are allowed. + +### Image.uri + +The URI (or IRI) of the image. Relative paths are relative to the current glTF asset. Instead of referencing an external file, this field **MAY** contain a `data:`-URI. This field **MUST NOT** be defined when `bufferView` is defined. + +* **Type**: `string` +* **Required**: No +* **Format**: iri-reference + +### Image.mimeType + +The image's media type. This field **MUST** be defined when `bufferView` is defined. + +* **Type**: `string` +* **Required**: No +* **Allowed values**: + * `"image/jpeg"` + * `"image/png"` + +### Image.bufferView + +The index of the bufferView that contains the image. This field **MUST NOT** be defined when `uri` is defined. + +* **Type**: `integer` +* **Required**: No +* **Minimum**: ` >= 0` + +### Image.fraction + +A number that **MUST** be between zero and one. + +* **Type**: `number` +* **Required**: No +* **Minimum**: ` > 0` +* **Maximum**: ` < 1` + + diff --git a/test/test-schemas/index.json b/test/test-schemas/index.json index 9636bd4..3a477e6 100644 --- a/test/test-schemas/index.json +++ b/test/test-schemas/index.json @@ -16,5 +16,8 @@ "name": "nested", "path": "nested/nestedTest.schema.json", "ignore": "['nestedid.schema.json', 'nestedchildofrootproperty.schema.json', 'nestedtestproperty.schema.json']" + }, { + "name": "v2020-12", + "path": "v2020-12/image.schema.json" }] } diff --git a/test/test-schemas/v2020-12/image.schema.json b/test/test-schemas/v2020-12/image.schema.json new file mode 100644 index 0000000..c016411 --- /dev/null +++ b/test/test-schemas/v2020-12/image.schema.json @@ -0,0 +1,48 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "image.schema.json", + "title": "Image", + "type": "object", + "description": "Image data used to create a texture. Image **MAY** be referenced by an URI (or IRI) or a buffer view index.", + "properties": { + "uri": { + "type": "string", + "description": "The URI (or IRI) of the image.", + "format": "iri-reference", + "gltf_detailedDescription": "The URI (or IRI) of the image. Relative paths are relative to the current glTF asset. Instead of referencing an external file, this field **MAY** contain a `data:`-URI. This field **MUST NOT** be defined when `bufferView` is defined.", + "gltf_uriType": "image" + }, + "mimeType": { + "anyOf": [ + { + "const": "image/jpeg" + }, + { + "const": "image/png" + }, + { + "type": "string" + } + ], + "description": "The image's media type. This field **MUST** be defined when `bufferView` is defined." + }, + "bufferView": { + "type": "integer", + "minimum": 0, + "description": "The index of the bufferView that contains the image. This field **MUST NOT** be defined when `uri` is defined." + }, + "fraction": { + "type": "number", + "description": "A number that **MUST** be between zero and one.", + "exclusiveMinimum": 0.0, + "exclusiveMaximum": 1.0 + } + }, + "dependencies": { + "bufferView": [ "mimeType" ] + }, + "oneOf": [ + { "required": [ "uri" ] }, + { "required": [ "bufferView" ] } + ] +} From 2867f26fe492ae1efc1aa7720a592a5561c7149b Mon Sep 17 00:00:00 2001 From: Ed Mackey Date: Thu, 23 Sep 2021 17:24:09 -0400 Subject: [PATCH 5/6] Added test of exclusive min/max inside new-schema arrays. --- test/test-golden/v2020-12-embed.adoc | 13 +++++++++++++ test/test-golden/v2020-12-keyword.md | 9 +++++++++ test/test-golden/v2020-12-linked.adoc | 13 +++++++++++++ test/test-golden/v2020-12-linked.md | 9 +++++++++ test/test-golden/v2020-12-remote.adoc | 13 +++++++++++++ test/test-golden/v2020-12-remote.md | 9 +++++++++ test/test-golden/v2020-12-simple.adoc | 13 +++++++++++++ test/test-golden/v2020-12-simple.md | 9 +++++++++ test/test-schemas/v2020-12/image.schema.json | 12 ++++++++++++ 9 files changed, 100 insertions(+) diff --git a/test/test-golden/v2020-12-embed.adoc b/test/test-golden/v2020-12-embed.adoc index 5d7a920..0335628 100644 --- a/test/test-golden/v2020-12-embed.adoc +++ b/test/test-golden/v2020-12-embed.adoc @@ -30,6 +30,11 @@ Image data used to create a texture. Image **MAY** be referenced by an URI (or I |A number that **MUST** be between zero and one. |No +|**moreFractions** +|`number` `[3]` +|An array of three fractional numbers. +|No, default: `[0.1,0.2,0.3]` + |=== Additional properties are allowed. @@ -71,4 +76,12 @@ A number that **MUST** be between zero and one. * **Minimum**: `> 0` * **Maximum**: `< 1` +=== Image.moreFractions + +An array of three fractional numbers. + +* **Type**: `number` `[3]` +** Each element in the array must be greater than `0` and less than `1`. +* **Required**: No, default: `[0.1,0.2,0.3]` + diff --git a/test/test-golden/v2020-12-keyword.md b/test/test-golden/v2020-12-keyword.md index b8f7c45..d64fce7 100644 --- a/test/test-golden/v2020-12-keyword.md +++ b/test/test-golden/v2020-12-keyword.md @@ -16,6 +16,7 @@ Image data used to create a texture. Image **MAY** be referenced by an URI (or I |**mimeType**|`string`|The image's media type. This field **MUST** be defined when `bufferView` is defined.|No| |**bufferView**|`integer`|The index of the bufferView that contains the image. This field **MUST NOT** be defined when `uri` is defined.|No| |**fraction**|`number`|A number that **MUST** be between zero and one.|No| +|**moreFractions**|`number` `[3]`|An array of three fractional numbers.|No, default: `[0.1,0.2,0.3]`| Additional properties are allowed. @@ -54,4 +55,12 @@ A number that **MUST** be between zero and one. * **Minimum**: ` > 0` * **Maximum**: ` < 1` +### Image.moreFractions + +An array of three fractional numbers. + +* **Type**: `number` `[3]` + * Each element in the array **MUST** be greater than `0` and less than `1`. +* **Required**: No, default: `[0.1,0.2,0.3]` + diff --git a/test/test-golden/v2020-12-linked.adoc b/test/test-golden/v2020-12-linked.adoc index 24cce58..31e379e 100644 --- a/test/test-golden/v2020-12-linked.adoc +++ b/test/test-golden/v2020-12-linked.adoc @@ -32,6 +32,11 @@ Image data used to create a texture. Image **MAY** be referenced by an URI (or I |A number that **MUST** be between zero and one. |No +|**moreFractions** +|`number` `[3]` +|An array of three fractional numbers. +|No, default: `[0.1,0.2,0.3]` + |=== Additional properties are allowed. @@ -73,4 +78,12 @@ A number that **MUST** be between zero and one. * **Minimum**: `> 0` * **Maximum**: `< 1` +==== Image.moreFractions + +An array of three fractional numbers. + +* **Type**: `number` `[3]` +** Each element in the array must be greater than `0` and less than `1`. +* **Required**: No, default: `[0.1,0.2,0.3]` + diff --git a/test/test-golden/v2020-12-linked.md b/test/test-golden/v2020-12-linked.md index 7d4a426..596e036 100644 --- a/test/test-golden/v2020-12-linked.md +++ b/test/test-golden/v2020-12-linked.md @@ -16,6 +16,7 @@ Image data used to create a texture. Image **MAY** be referenced by an URI (or I |**mimeType**|`string`|The image's media type. This field **MUST** be defined when `bufferView` is defined.|No| |**bufferView**|`integer`|The index of the bufferView that contains the image. This field **MUST NOT** be defined when `uri` is defined.|No| |**fraction**|`number`|A number that **MUST** be between zero and one.|No| +|**moreFractions**|`number` `[3]`|An array of three fractional numbers.|No, default: `[0.1,0.2,0.3]`| Additional properties are allowed. @@ -56,4 +57,12 @@ A number that **MUST** be between zero and one. * **Minimum**: ` > 0` * **Maximum**: ` < 1` +#### Image.moreFractions + +An array of three fractional numbers. + +* **Type**: `number` `[3]` + * Each element in the array must be greater than `0` and less than `1`. +* **Required**: No, default: `[0.1,0.2,0.3]` + diff --git a/test/test-golden/v2020-12-remote.adoc b/test/test-golden/v2020-12-remote.adoc index 53ad3bf..72613b3 100644 --- a/test/test-golden/v2020-12-remote.adoc +++ b/test/test-golden/v2020-12-remote.adoc @@ -30,6 +30,11 @@ Image data used to create a texture. Image **MAY** be referenced by an URI (or I |A number that **MUST** be between zero and one. |No +|**moreFractions** +|`number` `[3]` +|An array of three fractional numbers. +|No, default: `[0.1,0.2,0.3]` + |=== Additional properties are allowed. @@ -71,4 +76,12 @@ A number that **MUST** be between zero and one. * **Minimum**: `> 0` * **Maximum**: `< 1` +=== Image.moreFractions + +An array of three fractional numbers. + +* **Type**: `number` `[3]` +** Each element in the array must be greater than `0` and less than `1`. +* **Required**: No, default: `[0.1,0.2,0.3]` + diff --git a/test/test-golden/v2020-12-remote.md b/test/test-golden/v2020-12-remote.md index 1f73fe8..5da80f3 100644 --- a/test/test-golden/v2020-12-remote.md +++ b/test/test-golden/v2020-12-remote.md @@ -14,6 +14,7 @@ Image data used to create a texture. Image **MAY** be referenced by an URI (or I |**mimeType**|`string`|The image's media type. This field **MUST** be defined when `bufferView` is defined.|No| |**bufferView**|`integer`|The index of the bufferView that contains the image. This field **MUST NOT** be defined when `uri` is defined.|No| |**fraction**|`number`|A number that **MUST** be between zero and one.|No| +|**moreFractions**|`number` `[3]`|An array of three fractional numbers.|No, default: `[0.1,0.2,0.3]`| Additional properties are allowed. @@ -54,4 +55,12 @@ A number that **MUST** be between zero and one. * **Minimum**: ` > 0` * **Maximum**: ` < 1` +### Image.moreFractions + +An array of three fractional numbers. + +* **Type**: `number` `[3]` + * Each element in the array must be greater than `0` and less than `1`. +* **Required**: No, default: `[0.1,0.2,0.3]` + diff --git a/test/test-golden/v2020-12-simple.adoc b/test/test-golden/v2020-12-simple.adoc index 7d11cd1..2c58946 100644 --- a/test/test-golden/v2020-12-simple.adoc +++ b/test/test-golden/v2020-12-simple.adoc @@ -32,6 +32,11 @@ Image data used to create a texture. Image **MAY** be referenced by an URI (or I |A number that **MUST** be between zero and one. |No +|**moreFractions** +|`number` `[3]` +|An array of three fractional numbers. +|No, default: `[0.1,0.2,0.3]` + |=== Additional properties are allowed. @@ -71,4 +76,12 @@ A number that **MUST** be between zero and one. * **Minimum**: `> 0` * **Maximum**: `< 1` +=== Image.moreFractions + +An array of three fractional numbers. + +* **Type**: `number` `[3]` +** Each element in the array must be greater than `0` and less than `1`. +* **Required**: No, default: `[0.1,0.2,0.3]` + diff --git a/test/test-golden/v2020-12-simple.md b/test/test-golden/v2020-12-simple.md index b8f7c45..ff0e811 100644 --- a/test/test-golden/v2020-12-simple.md +++ b/test/test-golden/v2020-12-simple.md @@ -16,6 +16,7 @@ Image data used to create a texture. Image **MAY** be referenced by an URI (or I |**mimeType**|`string`|The image's media type. This field **MUST** be defined when `bufferView` is defined.|No| |**bufferView**|`integer`|The index of the bufferView that contains the image. This field **MUST NOT** be defined when `uri` is defined.|No| |**fraction**|`number`|A number that **MUST** be between zero and one.|No| +|**moreFractions**|`number` `[3]`|An array of three fractional numbers.|No, default: `[0.1,0.2,0.3]`| Additional properties are allowed. @@ -54,4 +55,12 @@ A number that **MUST** be between zero and one. * **Minimum**: ` > 0` * **Maximum**: ` < 1` +### Image.moreFractions + +An array of three fractional numbers. + +* **Type**: `number` `[3]` + * Each element in the array must be greater than `0` and less than `1`. +* **Required**: No, default: `[0.1,0.2,0.3]` + diff --git a/test/test-schemas/v2020-12/image.schema.json b/test/test-schemas/v2020-12/image.schema.json index c016411..9bc913d 100644 --- a/test/test-schemas/v2020-12/image.schema.json +++ b/test/test-schemas/v2020-12/image.schema.json @@ -36,6 +36,18 @@ "description": "A number that **MUST** be between zero and one.", "exclusiveMinimum": 0.0, "exclusiveMaximum": 1.0 + }, + "moreFractions" : { + "type" : "array", + "description" : "An array of three fractional numbers.", + "items" : { + "type": "number", + "exclusiveMinimum" : 0.0, + "exclusiveMaximum" : 1.0 + }, + "minItems" : 3, + "maxItems" : 3, + "default" : [0.1, 0.2, 0.3] } }, "dependencies": { From 7180642e6e5794746b1deca548f7619c1ae7cff9 Mon Sep 17 00:00:00 2001 From: Ed Mackey Date: Thu, 23 Sep 2021 17:51:41 -0400 Subject: [PATCH 6/6] CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d0e745..53a3a1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +### 0.2.2 - UNRELEASED + +* Added support for certain features of newer JSON schema drafts. [#59](https://github.com/CesiumGS/wetzel/pull/59) + ### 0.2.0, 0.2.1 - 2021-08-16 * Added a new option to configure a keyword for "must" in hard-coded descriptions. [#57](https://github.com/CesiumGS/wetzel/pull/57)