From fb4db4a9740cf77059aa74275377684b74113a65 Mon Sep 17 00:00:00 2001 From: "David E. Wheeler" Date: Wed, 9 Mar 2022 14:11:00 -0500 Subject: [PATCH] Add support for pattern properties Convert the patterns to actual RegExp objects and then render them as such. This is especially useful for the perfectly valid empty pattern, which otherwise would not appear. Add a function, `propertySpecs`, which returns specs for handling both properties and patternProperties, and then iterate over them both to produce both the summary table and the more detailed info. Right now it creates a separate table for patter properties, but it might be worth considering a single table, since the rendering of the regex makes it pretty clear which is which. Add tests for pattern properties, too. --- lib/generateMarkdown.js | 301 ++++++++++--------- lib/style.js | 5 +- test/test-golden/v2020-12-embed.adoc | 38 +++ test/test-golden/v2020-12-keyword.md | 29 ++ test/test-golden/v2020-12-linked.adoc | 38 +++ test/test-golden/v2020-12-linked.md | 29 ++ test/test-golden/v2020-12-remote.adoc | 38 +++ test/test-golden/v2020-12-remote.md | 29 ++ test/test-golden/v2020-12-simple.adoc | 38 +++ test/test-golden/v2020-12-simple.md | 29 ++ test/test-schemas/v2020-12/image.schema.json | 16 + 11 files changed, 448 insertions(+), 142 deletions(-) diff --git a/lib/generateMarkdown.js b/lib/generateMarkdown.js index 953b1e4..4176b70 100644 --- a/lib/generateMarkdown.js +++ b/lib/generateMarkdown.js @@ -228,30 +228,48 @@ function getSchemaMarkdown(schema, fileName, headerLevel, suppressWarnings, sche //////////////////////////////////////////////////////////////////////////////// +function propertySpecs(schema) { + return [ + { + label: "Properties", + properties: schema.properties, + formatName: function(n) { return n }, + }, + { + label: "Pattern Properties", + properties: schema.patternProperties, + formatName: function(n) { return style.typeValue(new RegExp(n)) }, + }, + ] +} + function createPropertiesSummary(schema, knownTypes, autoLink) { var md = ''; - if (schema.properties !== undefined && Object.keys(schema.properties).length > 0) { - md += style.beginTable(style.typeValue(schema.title) + ' Properties', [' ', 'Type', 'Description', 'Required']); + for (const propType of propertySpecs(schema)) { + var properties = propType.properties - var properties = schema.properties; - for (var name in properties) { - if (properties.hasOwnProperty(name)) { - var property = properties[name]; - var summary = getPropertySummary(property, knownTypes, autoLink); + if (properties !== undefined && Object.keys(properties).length > 0) { + md += style.beginTable(style.typeValue(schema.title) + ' ' + propType.label, [' ', 'Type', 'Description', 'Required']); + + for (var name in properties) { + if (properties.hasOwnProperty(name)) { + var property = properties[name]; + var summary = getPropertySummary(property, knownTypes, autoLink); - md += style.addTableRow([ - style.propertyNameSummary(name), - summary.formattedType, - defaultValue(summary.description, ''), - (summary.required === 'Yes' ? style.requiredIcon : '') + summary.required - ]); + md += style.addTableRow([ + style.propertyNameSummary(propType.formatName(name)), + summary.formattedType, + defaultValue(summary.description, ''), + (summary.required === 'Yes' ? style.requiredIcon : '') + summary.required + ]); + } } - } - md += style.endTable(); + md += style.endTable(); + } } - + return md; } @@ -269,163 +287,166 @@ function createPropertiesDetails(schema, title, headerLevel, knownTypes, autoLin var headerMd = style.getHeaderMarkdown(headerLevel); var md = ''; - var properties = schema.properties; - for (var name in properties) { - if (properties.hasOwnProperty(name)) { - var property = properties[name]; - var summary = getPropertySummary(property, knownTypes, autoLink); - var type = summary.type; - - var variableTitle = schema.typeName; - if (!defined(variableTitle)) { - variableTitle = title; - } + for (const propType of propertySpecs(schema)) { + var properties = propType.properties + if (properties == undefined) continue + for (var name in properties) { + if (properties.hasOwnProperty(name)) { + var property = properties[name]; + var summary = getPropertySummary(property, knownTypes, autoLink); + var type = summary.type; - md += headerMd + ' ' + variableTitle + '.' + name + '\n\n'; + var variableTitle = schema.typeName; + if (!defined(variableTitle)) { + variableTitle = title; + } - // TODO: Add plugin point for custom JSON schema properties like gltf_* - var detailedDescription = autoLinkDescription(property.gltf_detailedDescription, knownTypes, autoLink); - if (defined(detailedDescription)) { - md += detailedDescription + '\n\n'; - } else if (defined(summary.description)) { - md += summary.description + '\n\n'; - } + md += headerMd + ' ' + variableTitle + '.' + propType.formatName(name) + '\n\n'; - md += style.bulletItem(style.propertyDetails('Type') + ': ' + summary.formattedType, 0); + // TODO: Add plugin point for custom JSON schema properties like gltf_* + var detailedDescription = autoLinkDescription(property.gltf_detailedDescription, knownTypes, autoLink); + if (defined(detailedDescription)) { + md += detailedDescription + '\n\n'; + } else if (defined(summary.description)) { + md += summary.description + '\n\n'; + } - var eachElementInTheArrayMust = 'Each element in the array' + style.mustKeyword; + md += style.bulletItem(style.propertyDetails('Type') + ': ' + summary.formattedType, 0); - var uniqueItems = property.uniqueItems; - if (defined(uniqueItems) && uniqueItems) { - md += style.bulletItem(eachElementInTheArrayMust + 'be unique.', 1); - } + var eachElementInTheArrayMust = 'Each element in the array' + style.mustKeyword; - // 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 uniqueItems = property.uniqueItems; + if (defined(uniqueItems) && uniqueItems) { + md += style.bulletItem(eachElementInTheArrayMust + 'be unique.', 1); } - var itemsExclusiveMinimum = (defined(items.exclusiveMinimum) && items.exclusiveMinimum); - var minString = itemsExclusiveMinimum ? 'greater than' : 'greater than or equal to'; + // 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 itemsExclusiveMaximum = (defined(items.exclusiveMaximum) && items.exclusiveMaximum); - var maxString = itemsExclusiveMaximum ? 'less than' : 'less than or equal to'; + var itemsExclusiveMinimum = (defined(items.exclusiveMinimum) && items.exclusiveMinimum); + var minString = itemsExclusiveMinimum ? 'greater than' : 'greater than or equal to'; - if (defined(items.minimum) && defined(items.maximum)) { - md += style.bulletItem(eachElementInTheArrayMust + 'be ' + minString + ' ' + - style.minMax(items.minimum) + ' and ' + maxString + ' ' + style.minMax(items.maximum) + '.', 1); - } else if (defined(items.minimum)) { - md += style.bulletItem(eachElementInTheArrayMust + 'be ' + minString + ' ' + style.minMax(items.minimum) + '.', 1); - } else if (defined(items.maximum)) { - md += style.bulletItem(eachElementInTheArrayMust + 'be ' + maxString + ' ' + style.minMax(items.maximum) + '.', 1); - } + var itemsExclusiveMaximum = (defined(items.exclusiveMaximum) && items.exclusiveMaximum); + var maxString = itemsExclusiveMaximum ? 'less than' : 'less than or equal to'; - if (defined(items.minLength) && defined(items.maxLength)) { - md += style.bulletItem(eachElementInTheArrayMust + 'have length between ' + style.minMax(items.minLength) + - ' and ' + style.minMax(items.maxLength) + '.', 1); - } else if (defined(items.minLength)) { - md += style.bulletItem(eachElementInTheArrayMust + 'have length greater than or equal to ' + style.minMax(items.minLength) + '.', 1); - } else if (defined(items.maxLength)) { - md += style.bulletItem(eachElementInTheArrayMust + 'have length less than or equal to ' + style.minMax(items.maxLength) + '.', 1); - } + if (defined(items.minimum) && defined(items.maximum)) { + md += style.bulletItem(eachElementInTheArrayMust + 'be ' + minString + ' ' + + style.minMax(items.minimum) + ' and ' + maxString + ' ' + style.minMax(items.maximum) + '.', 1); + } else if (defined(items.minimum)) { + md += style.bulletItem(eachElementInTheArrayMust + 'be ' + minString + ' ' + style.minMax(items.minimum) + '.', 1); + } else if (defined(items.maximum)) { + md += style.bulletItem(eachElementInTheArrayMust + 'be ' + maxString + ' ' + style.minMax(items.maximum) + '.', 1); + } + + if (defined(items.minLength) && defined(items.maxLength)) { + md += style.bulletItem(eachElementInTheArrayMust + 'have length between ' + style.minMax(items.minLength) + + ' and ' + style.minMax(items.maxLength) + '.', 1); + } else if (defined(items.minLength)) { + md += style.bulletItem(eachElementInTheArrayMust + 'have length greater than or equal to ' + style.minMax(items.minLength) + '.', 1); + } else if (defined(items.maxLength)) { + md += style.bulletItem(eachElementInTheArrayMust + 'have length less than or equal to ' + style.minMax(items.maxLength) + '.', 1); + } - var itemsString = getEnumString(items, type, 2); - if (defined(itemsString)) { - md += style.bulletItem(eachElementInTheArrayMust + 'be one of the following values:', 1) + itemsString; + var itemsString = getEnumString(items, type, 2); + if (defined(itemsString)) { + md += style.bulletItem(eachElementInTheArrayMust + 'be one of the following values:', 1) + itemsString; + } } - } - md += style.bulletItem(style.propertyDetails('Required') + ': ' + summary.required, 0); + md += style.bulletItem(style.propertyDetails('Required') + ': ' + summary.required, 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); + 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); + } } - } - 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); + 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; - if (defined(format)) { - md += style.bulletItem(style.propertyDetails('Format') + ': ' + format, 0); - } + var format = property.format; + if (defined(format)) { + md += style.bulletItem(style.propertyDetails('Format') + ': ' + format, 0); + } - var pattern = property.pattern; - if (defined(pattern)) { - md += style.bulletItem(style.propertyDetails('Pattern') + ': ' + style.minMax(pattern), 0); - } + var pattern = property.pattern; + if (defined(pattern)) { + md += style.bulletItem(style.propertyDetails('Pattern') + ': ' + style.minMax(pattern), 0); + } - var minLength = property.minLength; - if (defined(minLength)) { - md += style.bulletItem(style.propertyDetails('Minimum Length') + style.minMax(': >= ' + minLength), 0); - } + var minLength = property.minLength; + if (defined(minLength)) { + md += style.bulletItem(style.propertyDetails('Minimum Length') + style.minMax(': >= ' + minLength), 0); + } - var maxLength = property.maxLength; - if (defined(maxLength)) { - md += style.bulletItem(style.propertyDetails('Maximum Length') + style.minMax(': <= ' + maxLength), 0); - } + var maxLength = property.maxLength; + if (defined(maxLength)) { + md += style.bulletItem(style.propertyDetails('Maximum Length') + style.minMax(': <= ' + maxLength), 0); + } - var enumString = getEnumString(property, type, 1); - if (defined(enumString)) { - md += style.bulletItem(style.propertyDetails('Allowed values') + ':', 0) + enumString; - } + var enumString = getEnumString(property, type, 1); + if (defined(enumString)) { + md += style.bulletItem(style.propertyDetails('Allowed values') + ':', 0) + enumString; + } - var additionalProperties = property.additionalProperties; - if (defined(additionalProperties) && (typeof additionalProperties === 'object')) { - var additionalPropertiesType = getPropertyType(additionalProperties); - if (defined(additionalPropertiesType)) { - // TODO: additionalProperties is really a full schema - var formattedType = style.typeValue(additionalPropertiesType); - if ((additionalProperties.type === 'object') && defined(property.title)) { - formattedType = style.linkType(property.title, property.title, autoLink); + var additionalProperties = property.additionalProperties; + if (defined(additionalProperties) && (typeof additionalProperties === 'object')) { + var additionalPropertiesType = getPropertyType(additionalProperties); + if (defined(additionalPropertiesType)) { + // TODO: additionalProperties is really a full schema + var formattedType = style.typeValue(additionalPropertiesType); + if ((additionalProperties.type === 'object') && defined(property.title)) { + formattedType = style.linkType(property.title, property.title, autoLink); + } + + md += style.bulletItem(style.propertyDetails('Type of each property') + ': ' + formattedType, 0); } + } - md += style.bulletItem(style.propertyDetails('Type of each property') + ': ' + formattedType, 0); + var examples = property.examples; + if (defined(examples)) { + md += style.bulletItem(style.propertyDetails('Examples') + ':'); + for (const example of examples) { + md += style.bulletItem(style.defaultValue(example, type), 1); + } } - } - var examples = property.examples; - if (defined(examples)) { - md += style.bulletItem(style.propertyDetails('Examples') + ':'); - for (const example of examples) { - md += style.bulletItem(style.defaultValue(example, type), 1); + // TODO: Add plugin point for custom JSON schema properties like gltf_* + var webgl = property.gltf_webgl; + if (defined(webgl)) { + md += style.bulletItem(style.propertyGltfWebGL('Related WebGL functions') + ': ' + webgl, 0); } - } - // TODO: Add plugin point for custom JSON schema properties like gltf_* - var webgl = property.gltf_webgl; - if (defined(webgl)) { - md += style.bulletItem(style.propertyGltfWebGL('Related WebGL functions') + ': ' + webgl, 0); + md += '\n'; } - - md += '\n'; } + md += '\n'; } - md += '\n'; return md; } diff --git a/lib/style.js b/lib/style.js index 7ec85fb..2b22a89 100644 --- a/lib/style.js +++ b/lib/style.js @@ -340,7 +340,7 @@ function styleBold(string) { function styleCode(code) { if (defined(code)) { // If it's an object, just serialize it. - if (typeof code === 'object') { + if (typeof code === 'object' && code.constructor != RegExp) { // Someday may want to use a code fence if it's longer than, say, 88 // chars, but that would require keeping track of the current // indentation. Not really how things are designed to work right @@ -353,7 +353,8 @@ function styleCode(code) { var stringified = code.toString(); if (stringified.length > 0) { - return '`' + stringified + '`'; + // Escape ` so it doesn't end early, and | so it works in a table cell. + return '`' + stringified.replaceAll(/([`|])/g, '\\$1') + '`'; } } diff --git a/test/test-golden/v2020-12-embed.adoc b/test/test-golden/v2020-12-embed.adoc index 71a0972..3aeabf7 100644 --- a/test/test-golden/v2020-12-embed.adoc +++ b/test/test-golden/v2020-12-embed.adoc @@ -37,6 +37,22 @@ Image data used to create a texture. Image **MAY** be referenced by an URI (or I |=== +.`Image` Pattern Properties +|=== +| |Type|Description|Required + +|**`/^(?:rgb\|hex\|hsl\|rgba\|hsla)Color/`** +|`string` +|The background color for the image +|No + +|**`/^(?:height\|width)$/`** +|`string` +|A dimension for the image +|No + +|=== + Additional properties are allowed. * **JSON schema**: <> @@ -93,6 +109,28 @@ An array of three fractional numbers. ** `[18, 0.1, 1.1]` +=== Image.`/^(?:rgb\|hex\|hsl\|rgba\|hsla)Color/` + +The background color for the image + +* **Type**: `string` +* **Required**: No +* **Examples**: +** `"rgb(255, 99, 71)"` +** `"#ff6347"` +** `"hsl(9, 100%, 64%)"` + +=== Image.`/^(?:height\|width)$/` + +A dimension for the image + +* **Type**: `string` +* **Required**: No +* **Examples**: +** `"10"` +** `"400px"` + + == Examples * `{"uri": "https://raw.githubusercontent.com/KhronosGroup/glTF/main/specification/figures/gltf.png", "mimeType": "image/png"}` diff --git a/test/test-golden/v2020-12-keyword.md b/test/test-golden/v2020-12-keyword.md index 142a067..45fb06d 100644 --- a/test/test-golden/v2020-12-keyword.md +++ b/test/test-golden/v2020-12-keyword.md @@ -18,6 +18,13 @@ Image data used to create a texture. Image **MAY** be referenced by an URI (or I |**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]`| +**`Image` Pattern Properties** + +| |Type|Description|Required| +|---|---|---|---| +|**`/^(?:rgb\|hex\|hsl\|rgba\|hsla)Color/`**|`string`|The background color for the image|No| +|**`/^(?:height\|width)$/`**|`string`|A dimension for the image|No| + Additional properties are allowed. ### Image.uri @@ -72,6 +79,28 @@ An array of three fractional numbers. * `[18, 0.1, 1.1]` +### Image.`/^(?:rgb\|hex\|hsl\|rgba\|hsla)Color/` + +The background color for the image + +* **Type**: `string` +* **Required**: No +* **Examples**: + * `"rgb(255, 99, 71)"` + * `"#ff6347"` + * `"hsl(9, 100%, 64%)"` + +### Image.`/^(?:height\|width)$/` + +A dimension for the image + +* **Type**: `string` +* **Required**: No +* **Examples**: + * `"10"` + * `"400px"` + + ## Examples * `{"uri": "https://raw.githubusercontent.com/KhronosGroup/glTF/main/specification/figures/gltf.png", "mimeType": "image/png"}` diff --git a/test/test-golden/v2020-12-linked.adoc b/test/test-golden/v2020-12-linked.adoc index d917cab..ad143ba 100644 --- a/test/test-golden/v2020-12-linked.adoc +++ b/test/test-golden/v2020-12-linked.adoc @@ -39,6 +39,22 @@ Image data used to create a texture. Image **MAY** be referenced by an URI (or I |=== +.`Image` Pattern Properties +|=== +| |Type|Description|Required + +|**`/^(?:rgb\|hex\|hsl\|rgba\|hsla)Color/`** +|`string` +|The background color for the image +|No + +|**`/^(?:height\|width)$/`** +|`string` +|A dimension for the image +|No + +|=== + Additional properties are allowed. * **JSON schema**: link:schema/image.schema.json[image.schema.json] @@ -95,6 +111,28 @@ An array of three fractional numbers. ** `[18, 0.1, 1.1]` +==== Image.`/^(?:rgb\|hex\|hsl\|rgba\|hsla)Color/` + +The background color for the image + +* **Type**: `string` +* **Required**: No +* **Examples**: +** `"rgb(255, 99, 71)"` +** `"#ff6347"` +** `"hsl(9, 100%, 64%)"` + +==== Image.`/^(?:height\|width)$/` + +A dimension for the image + +* **Type**: `string` +* **Required**: No +* **Examples**: +** `"10"` +** `"400px"` + + === Examples * `{"uri": "https://raw.githubusercontent.com/KhronosGroup/glTF/main/specification/figures/gltf.png", "mimeType": "image/png"}` diff --git a/test/test-golden/v2020-12-linked.md b/test/test-golden/v2020-12-linked.md index c706bac..0061ad1 100644 --- a/test/test-golden/v2020-12-linked.md +++ b/test/test-golden/v2020-12-linked.md @@ -18,6 +18,13 @@ Image data used to create a texture. Image **MAY** be referenced by an URI (or I |**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]`| +**`Image` Pattern Properties** + +| |Type|Description|Required| +|---|---|---|---| +|**`/^(?:rgb\|hex\|hsl\|rgba\|hsla)Color/`**|`string`|The background color for the image|No| +|**`/^(?:height\|width)$/`**|`string`|A dimension for the image|No| + Additional properties are allowed. * **JSON schema**: [image.schema.json](schema/image.schema.json) @@ -74,6 +81,28 @@ An array of three fractional numbers. * `[18, 0.1, 1.1]` +#### Image.`/^(?:rgb\|hex\|hsl\|rgba\|hsla)Color/` + +The background color for the image + +* **Type**: `string` +* **Required**: No +* **Examples**: + * `"rgb(255, 99, 71)"` + * `"#ff6347"` + * `"hsl(9, 100%, 64%)"` + +#### Image.`/^(?:height\|width)$/` + +A dimension for the image + +* **Type**: `string` +* **Required**: No +* **Examples**: + * `"10"` + * `"400px"` + + ### Examples * `{"uri": "https://raw.githubusercontent.com/KhronosGroup/glTF/main/specification/figures/gltf.png", "mimeType": "image/png"}` diff --git a/test/test-golden/v2020-12-remote.adoc b/test/test-golden/v2020-12-remote.adoc index 45d5fcc..041f680 100644 --- a/test/test-golden/v2020-12-remote.adoc +++ b/test/test-golden/v2020-12-remote.adoc @@ -37,6 +37,22 @@ Image data used to create a texture. Image **MAY** be referenced by an URI (or I |=== +.`Image` Pattern Properties +|=== +| |Type|Description|Required + +|**`/^(?:rgb\|hex\|hsl\|rgba\|hsla)Color/`** +|`string` +|The background color for the image +|No + +|**`/^(?:height\|width)$/`** +|`string` +|A dimension for the image +|No + +|=== + Additional properties are allowed. * **JSON schema**: link:https://www.khronos.org/wetzel/just/testing/schema/image.schema.json[image.schema.json] @@ -93,6 +109,28 @@ An array of three fractional numbers. ** `[18, 0.1, 1.1]` +=== Image.`/^(?:rgb\|hex\|hsl\|rgba\|hsla)Color/` + +The background color for the image + +* **Type**: `string` +* **Required**: No +* **Examples**: +** `"rgb(255, 99, 71)"` +** `"#ff6347"` +** `"hsl(9, 100%, 64%)"` + +=== Image.`/^(?:height\|width)$/` + +A dimension for the image + +* **Type**: `string` +* **Required**: No +* **Examples**: +** `"10"` +** `"400px"` + + == Examples * `{"uri": "https://raw.githubusercontent.com/KhronosGroup/glTF/main/specification/figures/gltf.png", "mimeType": "image/png"}` diff --git a/test/test-golden/v2020-12-remote.md b/test/test-golden/v2020-12-remote.md index 8f62242..ae23121 100644 --- a/test/test-golden/v2020-12-remote.md +++ b/test/test-golden/v2020-12-remote.md @@ -16,6 +16,13 @@ Image data used to create a texture. Image **MAY** be referenced by an URI (or I |**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]`| +**`Image` Pattern Properties** + +| |Type|Description|Required| +|---|---|---|---| +|**`/^(?:rgb\|hex\|hsl\|rgba\|hsla)Color/`**|`string`|The background color for the image|No| +|**`/^(?:height\|width)$/`**|`string`|A dimension for the image|No| + Additional properties are allowed. * **JSON schema**: [image.schema.json](https://www.khronos.org/wetzel/just/testing/schema/image.schema.json) @@ -72,6 +79,28 @@ An array of three fractional numbers. * `[18, 0.1, 1.1]` +### Image.`/^(?:rgb\|hex\|hsl\|rgba\|hsla)Color/` + +The background color for the image + +* **Type**: `string` +* **Required**: No +* **Examples**: + * `"rgb(255, 99, 71)"` + * `"#ff6347"` + * `"hsl(9, 100%, 64%)"` + +### Image.`/^(?:height\|width)$/` + +A dimension for the image + +* **Type**: `string` +* **Required**: No +* **Examples**: + * `"10"` + * `"400px"` + + ## Examples * `{"uri": "https://raw.githubusercontent.com/KhronosGroup/glTF/main/specification/figures/gltf.png", "mimeType": "image/png"}` diff --git a/test/test-golden/v2020-12-simple.adoc b/test/test-golden/v2020-12-simple.adoc index bf69acd..9414801 100644 --- a/test/test-golden/v2020-12-simple.adoc +++ b/test/test-golden/v2020-12-simple.adoc @@ -39,6 +39,22 @@ Image data used to create a texture. Image **MAY** be referenced by an URI (or I |=== +.`Image` Pattern Properties +|=== +| |Type|Description|Required + +|**`/^(?:rgb\|hex\|hsl\|rgba\|hsla)Color/`** +|`string` +|The background color for the image +|No + +|**`/^(?:height\|width)$/`** +|`string` +|A dimension for the image +|No + +|=== + Additional properties are allowed. === Image.uri @@ -93,6 +109,28 @@ An array of three fractional numbers. ** `[18, 0.1, 1.1]` +=== Image.`/^(?:rgb\|hex\|hsl\|rgba\|hsla)Color/` + +The background color for the image + +* **Type**: `string` +* **Required**: No +* **Examples**: +** `"rgb(255, 99, 71)"` +** `"#ff6347"` +** `"hsl(9, 100%, 64%)"` + +=== Image.`/^(?:height\|width)$/` + +A dimension for the image + +* **Type**: `string` +* **Required**: No +* **Examples**: +** `"10"` +** `"400px"` + + == Examples * `{"uri": "https://raw.githubusercontent.com/KhronosGroup/glTF/main/specification/figures/gltf.png", "mimeType": "image/png"}` diff --git a/test/test-golden/v2020-12-simple.md b/test/test-golden/v2020-12-simple.md index e68c022..0f809b7 100644 --- a/test/test-golden/v2020-12-simple.md +++ b/test/test-golden/v2020-12-simple.md @@ -18,6 +18,13 @@ Image data used to create a texture. Image **MAY** be referenced by an URI (or I |**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]`| +**`Image` Pattern Properties** + +| |Type|Description|Required| +|---|---|---|---| +|**`/^(?:rgb\|hex\|hsl\|rgba\|hsla)Color/`**|`string`|The background color for the image|No| +|**`/^(?:height\|width)$/`**|`string`|A dimension for the image|No| + Additional properties are allowed. ### Image.uri @@ -72,6 +79,28 @@ An array of three fractional numbers. * `[18, 0.1, 1.1]` +### Image.`/^(?:rgb\|hex\|hsl\|rgba\|hsla)Color/` + +The background color for the image + +* **Type**: `string` +* **Required**: No +* **Examples**: + * `"rgb(255, 99, 71)"` + * `"#ff6347"` + * `"hsl(9, 100%, 64%)"` + +### Image.`/^(?:height\|width)$/` + +A dimension for the image + +* **Type**: `string` +* **Required**: No +* **Examples**: + * `"10"` + * `"400px"` + + ## Examples * `{"uri": "https://raw.githubusercontent.com/KhronosGroup/glTF/main/specification/figures/gltf.png", "mimeType": "image/png"}` diff --git a/test/test-schemas/v2020-12/image.schema.json b/test/test-schemas/v2020-12/image.schema.json index 3d88820..4732571 100644 --- a/test/test-schemas/v2020-12/image.schema.json +++ b/test/test-schemas/v2020-12/image.schema.json @@ -58,6 +58,22 @@ ] } }, + "patternProperties": { + "^(?:rgb|hex|hsl|rgba|hsla)Color": { + "type": "string", + "description": "The background color for the image", + "examples": [ + "rgb(255, 99, 71)", + "#ff6347", + "hsl(9, 100%, 64%)" + ] + }, + "^(?:height|width)$": { + "type": "string", + "description": "A dimension for the image", + "examples": ["10", "400px"] + } + }, "dependencies": { "bufferView": [ "mimeType" ] },