diff --git a/src/components/schema-table.js b/src/components/schema-table.js index fa984b73..75d50df1 100644 --- a/src/components/schema-table.js +++ b/src/components/schema-table.js @@ -183,14 +183,14 @@ export default class SchemaTable extends LitElement { if (dataType === 'array') { detailObjType = 'array of object'; // Array of Object } else { - detailObjType = 'object'; + detailObjType = data['::dataTypeLabel'] || data['::type']; } } else if (data['::type'] === 'array') { if (dataType === 'array') { // detailObjType = 'array of array'; // Array of array detailObjType = `array of array ${arrayType !== 'object' ? `of ${arrayType}` : ''}`; // Array of array } else { - detailObjType = 'array'; + detailObjType = data['::dataTypeLabel'] || data['::type']; } } @@ -244,7 +244,7 @@ export default class SchemaTable extends LitElement { ? html`${this.generateTree(data[0], 'xxx-of-option', '', '::ARRAY~OF', '', newSchemaLevel, newIndentLevel, '')}` : html` ${Object.keys(data).map((dataKey) => html` - ${['::title', '::description', '::type', '::props', '::deprecated', '::array-type', '::readwrite'].includes(dataKey) + ${['::title', '::description', '::type', '::props', '::deprecated', '::array-type', '::readwrite', '::dataTypeLabel'].includes(dataKey) ? data[dataKey]['::type'] === 'array' || data[dataKey]['::type'] === 'object' ? html`${this.generateTree( data[dataKey]['::type'] === 'array' ? data[dataKey]['::props'] : data[dataKey], diff --git a/src/components/schema-tree.js b/src/components/schema-tree.js index 8fd30c33..e1e41461 100644 --- a/src/components/schema-tree.js +++ b/src/components/schema-tree.js @@ -246,7 +246,7 @@ export default class SchemaTree extends LitElement { ? html`${this.generateTree(data[0], 'xxx-of-option', '', '::ARRAY~OF', '', newSchemaLevel, newIndentLevel, data[0]['::readwrite'])}` : html` ${Object.keys(data).map((dataKey) => html` - ${['::title', '::description', '::type', '::props', '::deprecated', '::array-type', '::readwrite'].includes(dataKey) + ${['::title', '::description', '::type', '::props', '::deprecated', '::array-type', '::readwrite', '::dataTypeLabel'].includes(dataKey) ? data[dataKey]['::type'] === 'array' || data[dataKey]['::type'] === 'object' ? html`${this.generateTree( data[dataKey]['::type'] === 'array' ? data[dataKey]['::props'] : data[dataKey], diff --git a/src/utils/schema-utils.js b/src/utils/schema-utils.js index 12c0d191..aff8b8d2 100644 --- a/src/utils/schema-utils.js +++ b/src/utils/schema-utils.js @@ -685,6 +685,9 @@ export function schemaInObjectNotation(schema, obj, level = 0, suffix = '') { obj['::title'] = schema.title || ''; obj['::description'] = generateMarkdownForArrayAndObjectDescription(schema, level); obj['::type'] = 'object'; + if ((Array.isArray(schema.type) && schema.type.includes('null')) || schema.nullable) { + obj['::dataTypeLabel'] = 'object or null'; + } obj['::deprecated'] = schema.deprecated || false; obj['::readwrite'] = schema.readOnly ? 'readonly' : schema.writeOnly ? 'writeonly' : ''; for (const key in schema.properties) { @@ -701,6 +704,9 @@ export function schemaInObjectNotation(schema, obj, level = 0, suffix = '') { obj['::title'] = schema.title || ''; obj['::description'] = generateMarkdownForArrayAndObjectDescription(schema, level); obj['::type'] = 'array'; + if ((Array.isArray(schema.type) && schema.type.includes('null')) || schema.nullable) { + obj['::dataTypeLabel'] = 'array or null'; + } obj['::deprecated'] = schema.deprecated || false; obj['::readwrite'] = schema.readOnly ? 'readonly' : schema.writeOnly ? 'writeonly' : ''; if (schema.items?.items) {