openapi-explorer 2.2.693 → 2.2.696
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/openapi-explorer.min.js +2 -2
- package/dist/es/components/request-form-table.js +5 -4
- package/dist/es/components/schema-table.js +3 -3
- package/dist/es/components/schema-tree.js +11 -9
- package/dist/es/utils/schema-utils.js +2 -10
- package/dist/lib/components/request-form-table.js +5 -4
- package/dist/lib/components/schema-table.js +3 -3
- package/dist/lib/components/schema-tree.js +11 -9
- package/dist/lib/utils/schema-utils.js +2 -10
- package/package.json +1 -1
@@ -34,7 +34,7 @@ function generateFormRows(data, options, dataType = 'object', key = '', descript
|
|
34
34
|
return undefined;
|
35
35
|
}
|
36
36
|
const displayLine = [description].filter(v => v).join(' ');
|
37
|
-
return html` ${newSchemaLevel >= 0 && key ? html` <tr class="complex-object-display ${data['::type']}" data-obj="${keyLabel}"> <td class="key ${data['::deprecated'] ? 'deprecated' : ''}"> <div style="display:flex;align-items:center"> ${data['::type'] === 'xxx-of-option' ||
|
37
|
+
return html` ${newSchemaLevel >= 0 && key ? html` <tr class="complex-object-display ${data['::type']}" data-obj="${keyLabel}"> <td class="key ${data['::deprecated'] ? 'deprecated' : ''}"> <div style="display:flex;align-items:center"> ${data['::type'] === 'xxx-of-option' || key.startsWith('::OPTION') ? html`<span class="xxx-of-key">${keyLabel}</span><span class="${isOneOfLabel ? 'xxx-of-key' : 'xxx-of-descr'}">${keyDescr}</span>` : isRequired ? html`<span class="key-label requiredStar" style="display:inline-block" title="Required">${keyLabel}</span>` : html`<span class="key-label" style="display:inline-block">${keyLabel === '::props' ? '' : keyLabel}</span>`} </div> </td> <td> </td> <td class="key-descr m-markdown-small">${unsafeHTML(marked(displayLine))}</td> </tr>` : html`${data['::type'] === 'array' && dataType === 'array' ? html`<tr><td> ${dataType} </td> </tr>` : ''}`} ${Array.isArray(data) && data[0] ? html`${generateFormRows.call(this, data[0], options, 'xxx-of-option', '::ARRAY~OF', '', newSchemaLevel)}` : html`${Object.keys(data).map(dataKey => {
|
38
38
|
var _data$dataKey;
|
39
39
|
return !['::metadata', '::title', '::description', '::type', '::link', '::props', '::deprecated', '::array-type', '::dataTypeLabel', '::flags'].includes(dataKey) || (_data$dataKey = data[dataKey]) !== null && _data$dataKey !== void 0 && _data$dataKey['::type'] && !data[dataKey]['::type'].includes('xxx-of') ? html`${generateFormRows.call(this, data[dataKey]['::type'] === 'array' ? data[dataKey]['::props'] : data[dataKey], options, data[dataKey]['::type'], dataKey, data[dataKey]['::description'], newSchemaLevel)}` : '';
|
40
40
|
})}`}`;
|
@@ -42,7 +42,7 @@ function generateFormRows(data, options, dataType = 'object', key = '', descript
|
|
42
42
|
|
43
43
|
// For Primitive Data types
|
44
44
|
const parsedData = JSON.parse(data);
|
45
|
-
return
|
45
|
+
return generatePrimitiveRow.call(this, parsedData, {
|
46
46
|
key,
|
47
47
|
keyLabel,
|
48
48
|
keyDescr,
|
@@ -50,7 +50,7 @@ function generateFormRows(data, options, dataType = 'object', key = '', descript
|
|
50
50
|
dataType,
|
51
51
|
isRequired,
|
52
52
|
options
|
53
|
-
})
|
53
|
+
});
|
54
54
|
}
|
55
55
|
function generatePrimitiveRow(rowData, parentRecursionOptions) {
|
56
56
|
var _this$duplicatedRowsB;
|
@@ -98,7 +98,7 @@ function generatePrimitiveRow(rowData, parentRecursionOptions) {
|
|
98
98
|
this.requestUpdate();
|
99
99
|
}
|
100
100
|
};
|
101
|
-
|
101
|
+
const arrayIterator = map(range(((_this$duplicatedRowsB = this.duplicatedRowsByKey) === null || _this$duplicatedRowsB === void 0 ? void 0 : _this$duplicatedRowsB[duplicateRowGeneratorKey]) || 1), () => html` <tr> ${inputFieldKeyLabel.call(this, key.startsWith('::OPTION'), keyLabel, keyDescr, dataType, deprecated, isRequired, schemaTitle, format || type, rowGenerator)} ${dataType === 'array' ? getArrayFormField.call(this, keyLabel, example, defaultValue, format, rowGenerator) : ''} ${dataType !== 'array' ? getPrimitiveFormField.call(this, keyLabel, example, defaultValue, format, options, rowGenerator) : ''} <td> ${description ? html`<div class="param-description">${unsafeHTML(marked(description))}</div>` : ''} ${defaultValue || constraints || allowedValues || pattern ? html` <div class="param-constraint"> ${pattern ? html`<span style="font-weight:700">Pattern: </span>${pattern}<br>` : ''} ${constraints.length ? html`<span style="font-weight:700">Constraints: </span>${constraints.join(', ')}<br>` : ''} ${allowedValues === null || allowedValues === void 0 ? void 0 : allowedValues.filter(v => v !== '').map((v, i) => html` ${i > 0 ? '|' : html`<span style="font-weight:700">Allowed: </span>`} ${html` <a part="anchor anchor-param-constraint" data-type="${type === 'array' ? type : 'string'}" data-enum="${v.trim()}" @click="${e => {
|
102
102
|
const inputEl = e.target.closest('table').querySelector(`[data-pname="${keyLabel}"]`);
|
103
103
|
if (inputEl) {
|
104
104
|
inputEl.value = e.target.dataset.type === 'array' ? [e.target.dataset.enum] : e.target.dataset.enum;
|
@@ -111,6 +111,7 @@ function generatePrimitiveRow(rowData, parentRecursionOptions) {
|
|
111
111
|
}
|
112
112
|
this.computeCurlSyntax();
|
113
113
|
}}"> ${type === 'array' ? example.join(', ') : example} </a> ${type === 'array' ? '] ' : ''} </span>` : ''} </td> </tr>` : ''}`);
|
114
|
+
return Array.from(arrayIterator);
|
114
115
|
}
|
115
116
|
function inputFieldKeyLabel(isOption, keyLabel, keyDescription, dataType, deprecated, isRequired, schemaTitle, format, rowGenerator) {
|
116
117
|
if (isPatternProperty(keyLabel)) {
|
@@ -77,7 +77,7 @@ export default class SchemaTable extends LitElement {
|
|
77
77
|
generateTree(data, dataType = 'object', key = '', title = '', description = '', schemaLevel = 0, indentLevel = 0) {
|
78
78
|
var _keyLabel;
|
79
79
|
const newSchemaLevel = data['::type'] && data['::type'].startsWith('xxx-of') ? schemaLevel : schemaLevel + 1;
|
80
|
-
const newIndentLevel =
|
80
|
+
const newIndentLevel = key.startsWith('::OPTION') ? indentLevel : indentLevel + 1;
|
81
81
|
// 16px space indentation at each level, start the first one at 32px to align with the field hr key row object
|
82
82
|
const leftPadding = Math.max(firstColumnInitialPadding, tablePadding * newIndentLevel);
|
83
83
|
if (!data) {
|
@@ -118,7 +118,7 @@ export default class SchemaTable extends LitElement {
|
|
118
118
|
} else if (data['::type']) {
|
119
119
|
displaySchemaLink = data['::link'];
|
120
120
|
if (dataType === 'array') {
|
121
|
-
detailObjType = data['::link'] || keyLabel.replace(/(s|Collection|List)[*]?$/i, '').replace(/[*]$/, ''); // Array of Object
|
121
|
+
detailObjType = data['::link'] || !key.startsWith('::') && keyLabel.replace(/(s|Collection|List)[*]?$/i, '').replace(/[*]$/, '') || 'object'; // Array of Object
|
122
122
|
} else {
|
123
123
|
detailObjType = (data['::link'] || data['::type']).replace(/[*]$/, '');
|
124
124
|
}
|
@@ -163,7 +163,7 @@ export default class SchemaTable extends LitElement {
|
|
163
163
|
});
|
164
164
|
}
|
165
165
|
const displayLine = [title && `**${title}${description ? ':' : ''}**`, description].filter(v => v).join(' ');
|
166
|
-
const outerResult = html` ${newSchemaLevel >= 0 && key ? html` <div class="tr ${newSchemaLevel <= this.schemaExpandLevel ? '' : 'collapsed'} ${data['::type']}" data-obj="${keyLabel}"> <div class="td no-select key ${data['::deprecated'] ? 'deprecated' : ''}" part="schema-key" style="padding-left:${leftPadding}px;cursor:pointer" @click="${e => this.toggleObjectExpand(e, keyLabel)}"> <div style="display:flex;align-items:center"> ${keyLabel || keyDescr ? html`<div class="obj-toggle" data-obj="${keyLabel}">▾</div>` : ''} ${data['::type'] === 'xxx-of-option' ||
|
166
|
+
const outerResult = html` ${newSchemaLevel >= 0 && key ? html` <div class="tr ${newSchemaLevel <= this.schemaExpandLevel ? '' : 'collapsed'} ${data['::type']}" data-obj="${keyLabel}"> <div class="td no-select key ${data['::deprecated'] ? 'deprecated' : ''}" part="schema-key" style="padding-left:${leftPadding}px;cursor:pointer" @click="${e => this.toggleObjectExpand(e, keyLabel)}"> <div style="display:flex;align-items:center"> ${keyLabel || keyDescr ? html`<div class="obj-toggle" data-obj="${keyLabel}">▾</div>` : ''} ${data['::type'] === 'xxx-of-option' || key.startsWith('::OPTION') ? html`<span class="xxx-of-key" style="margin-left:-6px">${keyLabel}</span><span class="${isOneOfLabel ? 'xxx-of-key' : 'xxx-of-descr'}">${keyDescr}</span>` : keyLabel.endsWith('*') ? html`<span class="key-label requiredStar" style="display:inline-block;margin-left:-6px" title="Required"> ${keyLabel.substring(0, keyLabel.length - 1)}</span>` : html`<span class="key-label" style="display:inline-block;margin-left:-6px">${keyLabel === '::props' ? '' : keyLabel}</span>`} </div> </div> <div class="td key-type" part="schema-type"> ${displaySchemaLink ? html`<div class="schema-link" style="overflow:hidden;text-overflow:ellipsis" @click="${() => this.scrollToSchemaComponentByName(displaySchemaLink)}"> ${dataType === 'array' ? '[' : ''}<span style="color:var(--primary)">${detailObjType}</span>${dataType === 'array' ? ']' : ''} </div>` : html`<div>${(data['::type'] || '').includes('xxx-of') ? '' : `${dataType === 'array' ? '[' : ''}${detailObjType}${dataType === 'array' ? ']' : ''}`}</div>`} <div class="attributes" title="${flags['🆁'] && 'Read only attribute' || flags['🆆'] && 'Write only attribute' || ''}">${flags['🆁'] || flags['🆆'] || ''}</div> </div> <div class="td key-descr" part="schema-description"> <span class="m-markdown-small">${unsafeHTML(marked(displayLine))}</span> ${(_data$Metadata = data['::metadata']) !== null && _data$Metadata !== void 0 && (_data$Metadata$constr = _data$Metadata.constraints) !== null && _data$Metadata$constr !== void 0 && _data$Metadata$constr.length ? html`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Constraints: </span>${data['::metadata'].constraints.join(', ')}</div><br>` : ''} </div> </div>` : html` ${data['::type'] === 'array' && dataType === 'array' ? html`<div class="tr"> <div class="td"> ${dataType} </div> </div>` : ''} `} <div class="object-body"> ${recursiveResult} <div> </div></div>`;
|
167
167
|
return {
|
168
168
|
result: outerResult,
|
169
169
|
keyLabelMaxCharacterLength: Math.max(innerMaxIndentationLevel, (keyLabel || keyDescr).length),
|
@@ -93,8 +93,8 @@ export default class SchemaTree extends LitElement {
|
|
93
93
|
const minFieldColWidth = 300 - indentLevel * leftPadding;
|
94
94
|
let openBracket = '';
|
95
95
|
let closeBracket = '';
|
96
|
-
const newSchemaLevel = data['::type']
|
97
|
-
const newIndentLevel =
|
96
|
+
const newSchemaLevel = data['::type'] === 'xxx-of-option' ? schemaLevel : schemaLevel + 1;
|
97
|
+
const newIndentLevel = indentLevel + 1;
|
98
98
|
if (data['::type'] === 'array') {
|
99
99
|
if (dataType === 'array') {
|
100
100
|
const arrType = arrayType !== 'object' ? arrayType : '';
|
@@ -112,13 +112,15 @@ export default class SchemaTree extends LitElement {
|
|
112
112
|
}
|
113
113
|
closeBracket = ']';
|
114
114
|
}
|
115
|
-
} else if (data['::type'] === 'xxx-of'
|
116
|
-
if (
|
117
|
-
|
118
|
-
|
119
|
-
|
115
|
+
} else if (data['::type'] === 'xxx-of-option') {
|
116
|
+
if (dataType === 'array') {
|
117
|
+
if (schemaLevel < this.schemaExpandLevel) {
|
118
|
+
openBracket = html`<span class="open-bracket array" @click="${this.toggleObjectExpand}">[</span>`;
|
119
|
+
} else {
|
120
|
+
openBracket = html`<span class="open-bracket array" @click="${this.toggleObjectExpand}">[...]</span>`;
|
121
|
+
}
|
122
|
+
closeBracket = ']';
|
120
123
|
}
|
121
|
-
closeBracket = ']';
|
122
124
|
} else if (data['::type']) {
|
123
125
|
if (dataType === 'array') {
|
124
126
|
if (schemaLevel < this.schemaExpandLevel) {
|
@@ -145,7 +147,7 @@ export default class SchemaTree extends LitElement {
|
|
145
147
|
return undefined;
|
146
148
|
}
|
147
149
|
const displayLine = [flags['🆁'] || flags['🆆'], title && `**${title}${description ? ':' : ''}**`, description].filter(v => v).join(' ');
|
148
|
-
return html` <div class="tr ${schemaLevel < this.schemaExpandLevel || data['::type'] && data['::type'].startsWith('xxx-of') ? '' : 'collapsed'} ${data['::type'] || 'no-type-info'}"> <div class="td key ${data['::deprecated'] ? 'deprecated' : ''}" style="min-width:${minFieldColWidth}px"> ${data['::type'] === 'xxx-of-option' ||
|
150
|
+
return html` <div class="tr ${schemaLevel < this.schemaExpandLevel || data['::type'] && data['::type'].startsWith('xxx-of') ? '' : 'collapsed'} ${data['::type'] || 'no-type-info'}"> <div class="td key ${data['::deprecated'] ? 'deprecated' : ''}" style="min-width:${minFieldColWidth}px"> ${data['::type'] === 'xxx-of-option' || key.startsWith('::OPTION') ? html`<span class="key-label xxx-of-key">${keyLabel}</span><span class="xxx-of-descr">${keyDescr}</span>` : keyLabel === '::props' || keyLabel === '::ARRAY~OF' ? '' : schemaLevel > 0 ? html`<span class="key-label"> ${keyLabel.replace(/\*$/, '')}${keyLabel.endsWith('*') ? html`<span class="requiredStar" title="Required"></span>` : ''}: </span>` : ''} ${openBracket} </div> <div class="td key-descr"> <span class="m-markdown-small" style="vertical-align:middle" title="${flags['🆁'] && 'Read only attribute' || flags['🆆'] && 'Write only attribute' || ''}"> ${unsafeHTML(marked(displayLine))} </span> ${this.schemaDescriptionExpanded ? html` ${(_data$Metadata = data['::metadata']) !== null && _data$Metadata !== void 0 && (_data$Metadata$constr = _data$Metadata.constraints) !== null && _data$Metadata$constr !== void 0 && _data$Metadata$constr.length ? html`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Constraints: </span>${data['::metadata'].constraints.join(', ')}</div><br>` : ''}` : ''} </div> </div> <div class="inside-bracket-wrapper"> <div class="inside-bracket ${data['::type'] || 'no-type-info'}" style="padding-left:${data['::type'] === 'xxx-of-option' ? 0 : leftPadding}px"> ${Array.isArray(data) && data[0] ? html`${this.generateTree(data[0], 'xxx-of-option', '', data[0]['::flags'] || {}, '::ARRAY~OF', data[0]['::title'], data[0]['::description'], newSchemaLevel, newIndentLevel)}` : html` ${Object.keys(data).map(dataKey => {
|
149
151
|
var _data$dataKey;
|
150
152
|
return !['::metadata', '::title', '::description', '::type', '::link', '::props', '::deprecated', '::array-type', '::dataTypeLabel', '::flags'].includes(dataKey) || (_data$dataKey = data[dataKey]) !== null && _data$dataKey !== void 0 && _data$dataKey['::type'] && !data[dataKey]['::type'].includes('xxx-of') ? html`${this.generateTree(data[dataKey]['::type'] === 'array' ? data[dataKey]['::props'] : data[dataKey], data[dataKey]['::type'], data[dataKey]['::array-type'] || '', data[dataKey]['::flags'], dataKey, data[dataKey]['::title'], data[dataKey]['::description'], newSchemaLevel, newIndentLevel)}` : '';
|
151
153
|
})}`} </div> ${data['::type'] && data['::type'].includes('xxx-of') ? '' : html`<div class="close-bracket"> ${closeBracket} </div>`} </div> `;
|
@@ -376,32 +376,24 @@ export function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '
|
|
376
376
|
}
|
377
377
|
if (anyOf || oneOf) {
|
378
378
|
const objWithAnyOfProps = {};
|
379
|
+
objWithAnyOfProps['::type'] = 'xxx-of-option';
|
379
380
|
let writeOnly = true;
|
380
381
|
let readOnly = true;
|
381
382
|
(anyOf || oneOf || []).forEach((v, index) => {
|
382
|
-
if (v.type === 'object' || v.properties || v.allOf || v.anyOf || v.oneOf) {
|
383
|
+
if (v.type === 'object' || v.properties || v.allOf || v.anyOf || v.oneOf || v.type === 'array' || v.items) {
|
383
384
|
const partialObj = schemaInObjectNotation(v, options);
|
384
385
|
if (partialObj) {
|
385
386
|
var _partialObj$Flags, _partialObj$Flags2;
|
386
387
|
objWithAnyOfProps[`::OPTION~${index + 1}${v.title ? `~${v.title}` : ''}`] = partialObj;
|
387
|
-
objWithAnyOfProps['::type'] = 'xxx-of-option';
|
388
388
|
readOnly = readOnly && ((_partialObj$Flags = partialObj['::flags']) === null || _partialObj$Flags === void 0 ? void 0 : _partialObj$Flags['🆁']);
|
389
389
|
writeOnly = writeOnly && ((_partialObj$Flags2 = partialObj['::flags']) === null || _partialObj$Flags2 === void 0 ? void 0 : _partialObj$Flags2['🆆']);
|
390
390
|
}
|
391
|
-
} else if (v.type === 'array' || v.items) {
|
392
|
-
var _partialObj$Flags3, _partialObj$Flags4;
|
393
|
-
const partialObj = schemaInObjectNotation(v, options);
|
394
|
-
objWithAnyOfProps[`::OPTION~${index + 1}${v.title ? `~${v.title}` : ''}`] = partialObj;
|
395
|
-
objWithAnyOfProps['::type'] = 'xxx-of-array';
|
396
|
-
readOnly = readOnly && ((_partialObj$Flags3 = partialObj['::flags']) === null || _partialObj$Flags3 === void 0 ? void 0 : _partialObj$Flags3['🆁']);
|
397
|
-
writeOnly = writeOnly && ((_partialObj$Flags4 = partialObj['::flags']) === null || _partialObj$Flags4 === void 0 ? void 0 : _partialObj$Flags4['🆆']);
|
398
391
|
} else {
|
399
392
|
const typeInfo = getTypeInfo(v, options);
|
400
393
|
if (typeInfo !== null && typeInfo !== void 0 && typeInfo.type) {
|
401
394
|
var _objWithAnyOfProps$, _objWithAnyOfProps$2;
|
402
395
|
const prop = `::OPTION~${index + 1}${v.title ? `~${v.title}` : ''}`;
|
403
396
|
objWithAnyOfProps[prop] = `${typeInfo.html}`;
|
404
|
-
objWithAnyOfProps['::type'] = 'xxx-of-option';
|
405
397
|
readOnly = readOnly && ((_objWithAnyOfProps$ = objWithAnyOfProps['::flags']) === null || _objWithAnyOfProps$ === void 0 ? void 0 : _objWithAnyOfProps$['🆁']);
|
406
398
|
writeOnly = writeOnly && ((_objWithAnyOfProps$2 = objWithAnyOfProps['::flags']) === null || _objWithAnyOfProps$2 === void 0 ? void 0 : _objWithAnyOfProps$2['🆆']);
|
407
399
|
}
|
@@ -39,7 +39,7 @@ function generateFormRows(data, options, dataType = 'object', key = '', descript
|
|
39
39
|
return undefined;
|
40
40
|
}
|
41
41
|
const displayLine = [description].filter(v => v).join(' ');
|
42
|
-
return (0, _lit.html)` ${newSchemaLevel >= 0 && key ? (0, _lit.html)` <tr class="complex-object-display ${data['::type']}" data-obj="${keyLabel}"> <td class="key ${data['::deprecated'] ? 'deprecated' : ''}"> <div style="display:flex;align-items:center"> ${data['::type'] === 'xxx-of-option' ||
|
42
|
+
return (0, _lit.html)` ${newSchemaLevel >= 0 && key ? (0, _lit.html)` <tr class="complex-object-display ${data['::type']}" data-obj="${keyLabel}"> <td class="key ${data['::deprecated'] ? 'deprecated' : ''}"> <div style="display:flex;align-items:center"> ${data['::type'] === 'xxx-of-option' || key.startsWith('::OPTION') ? (0, _lit.html)`<span class="xxx-of-key">${keyLabel}</span><span class="${isOneOfLabel ? 'xxx-of-key' : 'xxx-of-descr'}">${keyDescr}</span>` : isRequired ? (0, _lit.html)`<span class="key-label requiredStar" style="display:inline-block" title="Required">${keyLabel}</span>` : (0, _lit.html)`<span class="key-label" style="display:inline-block">${keyLabel === '::props' ? '' : keyLabel}</span>`} </div> </td> <td> </td> <td class="key-descr m-markdown-small">${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(displayLine))}</td> </tr>` : (0, _lit.html)`${data['::type'] === 'array' && dataType === 'array' ? (0, _lit.html)`<tr><td> ${dataType} </td> </tr>` : ''}`} ${Array.isArray(data) && data[0] ? (0, _lit.html)`${generateFormRows.call(this, data[0], options, 'xxx-of-option', '::ARRAY~OF', '', newSchemaLevel)}` : (0, _lit.html)`${Object.keys(data).map(dataKey => {
|
43
43
|
var _data$dataKey;
|
44
44
|
return !['::metadata', '::title', '::description', '::type', '::link', '::props', '::deprecated', '::array-type', '::dataTypeLabel', '::flags'].includes(dataKey) || (_data$dataKey = data[dataKey]) !== null && _data$dataKey !== void 0 && _data$dataKey['::type'] && !data[dataKey]['::type'].includes('xxx-of') ? (0, _lit.html)`${generateFormRows.call(this, data[dataKey]['::type'] === 'array' ? data[dataKey]['::props'] : data[dataKey], options, data[dataKey]['::type'], dataKey, data[dataKey]['::description'], newSchemaLevel)}` : '';
|
45
45
|
})}`}`;
|
@@ -47,7 +47,7 @@ function generateFormRows(data, options, dataType = 'object', key = '', descript
|
|
47
47
|
|
48
48
|
// For Primitive Data types
|
49
49
|
const parsedData = JSON.parse(data);
|
50
|
-
return
|
50
|
+
return generatePrimitiveRow.call(this, parsedData, {
|
51
51
|
key,
|
52
52
|
keyLabel,
|
53
53
|
keyDescr,
|
@@ -55,7 +55,7 @@ function generateFormRows(data, options, dataType = 'object', key = '', descript
|
|
55
55
|
dataType,
|
56
56
|
isRequired,
|
57
57
|
options
|
58
|
-
})
|
58
|
+
});
|
59
59
|
}
|
60
60
|
function generatePrimitiveRow(rowData, parentRecursionOptions) {
|
61
61
|
var _this$duplicatedRowsB;
|
@@ -103,7 +103,7 @@ function generatePrimitiveRow(rowData, parentRecursionOptions) {
|
|
103
103
|
this.requestUpdate();
|
104
104
|
}
|
105
105
|
};
|
106
|
-
|
106
|
+
const arrayIterator = (0, _map.map)((0, _range.range)(((_this$duplicatedRowsB = this.duplicatedRowsByKey) === null || _this$duplicatedRowsB === void 0 ? void 0 : _this$duplicatedRowsB[duplicateRowGeneratorKey]) || 1), () => (0, _lit.html)` <tr> ${inputFieldKeyLabel.call(this, key.startsWith('::OPTION'), keyLabel, keyDescr, dataType, deprecated, isRequired, schemaTitle, format || type, rowGenerator)} ${dataType === 'array' ? getArrayFormField.call(this, keyLabel, example, defaultValue, format, rowGenerator) : ''} ${dataType !== 'array' ? getPrimitiveFormField.call(this, keyLabel, example, defaultValue, format, options, rowGenerator) : ''} <td> ${description ? (0, _lit.html)`<div class="param-description">${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(description))}</div>` : ''} ${defaultValue || constraints || allowedValues || pattern ? (0, _lit.html)` <div class="param-constraint"> ${pattern ? (0, _lit.html)`<span style="font-weight:700">Pattern: </span>${pattern}<br>` : ''} ${constraints.length ? (0, _lit.html)`<span style="font-weight:700">Constraints: </span>${constraints.join(', ')}<br>` : ''} ${allowedValues === null || allowedValues === void 0 ? void 0 : allowedValues.filter(v => v !== '').map((v, i) => (0, _lit.html)` ${i > 0 ? '|' : (0, _lit.html)`<span style="font-weight:700">Allowed: </span>`} ${(0, _lit.html)` <a part="anchor anchor-param-constraint" data-type="${type === 'array' ? type : 'string'}" data-enum="${v.trim()}" @click="${e => {
|
107
107
|
const inputEl = e.target.closest('table').querySelector(`[data-pname="${keyLabel}"]`);
|
108
108
|
if (inputEl) {
|
109
109
|
inputEl.value = e.target.dataset.type === 'array' ? [e.target.dataset.enum] : e.target.dataset.enum;
|
@@ -116,6 +116,7 @@ function generatePrimitiveRow(rowData, parentRecursionOptions) {
|
|
116
116
|
}
|
117
117
|
this.computeCurlSyntax();
|
118
118
|
}}"> ${type === 'array' ? example.join(', ') : example} </a> ${type === 'array' ? '] ' : ''} </span>` : ''} </td> </tr>` : ''}`);
|
119
|
+
return Array.from(arrayIterator);
|
119
120
|
}
|
120
121
|
function inputFieldKeyLabel(isOption, keyLabel, keyDescription, dataType, deprecated, isRequired, schemaTitle, format, rowGenerator) {
|
121
122
|
if ((0, _schemaUtils.isPatternProperty)(keyLabel)) {
|
@@ -82,7 +82,7 @@ class SchemaTable extends _lit.LitElement {
|
|
82
82
|
generateTree(data, dataType = 'object', key = '', title = '', description = '', schemaLevel = 0, indentLevel = 0) {
|
83
83
|
var _keyLabel;
|
84
84
|
const newSchemaLevel = data['::type'] && data['::type'].startsWith('xxx-of') ? schemaLevel : schemaLevel + 1;
|
85
|
-
const newIndentLevel =
|
85
|
+
const newIndentLevel = key.startsWith('::OPTION') ? indentLevel : indentLevel + 1;
|
86
86
|
// 16px space indentation at each level, start the first one at 32px to align with the field hr key row object
|
87
87
|
const leftPadding = Math.max(firstColumnInitialPadding, tablePadding * newIndentLevel);
|
88
88
|
if (!data) {
|
@@ -123,7 +123,7 @@ class SchemaTable extends _lit.LitElement {
|
|
123
123
|
} else if (data['::type']) {
|
124
124
|
displaySchemaLink = data['::link'];
|
125
125
|
if (dataType === 'array') {
|
126
|
-
detailObjType = data['::link'] || keyLabel.replace(/(s|Collection|List)[*]?$/i, '').replace(/[*]$/, ''); // Array of Object
|
126
|
+
detailObjType = data['::link'] || !key.startsWith('::') && keyLabel.replace(/(s|Collection|List)[*]?$/i, '').replace(/[*]$/, '') || 'object'; // Array of Object
|
127
127
|
} else {
|
128
128
|
detailObjType = (data['::link'] || data['::type']).replace(/[*]$/, '');
|
129
129
|
}
|
@@ -168,7 +168,7 @@ class SchemaTable extends _lit.LitElement {
|
|
168
168
|
});
|
169
169
|
}
|
170
170
|
const displayLine = [title && `**${title}${description ? ':' : ''}**`, description].filter(v => v).join(' ');
|
171
|
-
const outerResult = (0, _lit.html)` ${newSchemaLevel >= 0 && key ? (0, _lit.html)` <div class="tr ${newSchemaLevel <= this.schemaExpandLevel ? '' : 'collapsed'} ${data['::type']}" data-obj="${keyLabel}"> <div class="td no-select key ${data['::deprecated'] ? 'deprecated' : ''}" part="schema-key" style="padding-left:${leftPadding}px;cursor:pointer" @click="${e => this.toggleObjectExpand(e, keyLabel)}"> <div style="display:flex;align-items:center"> ${keyLabel || keyDescr ? (0, _lit.html)`<div class="obj-toggle" data-obj="${keyLabel}">▾</div>` : ''} ${data['::type'] === 'xxx-of-option' ||
|
171
|
+
const outerResult = (0, _lit.html)` ${newSchemaLevel >= 0 && key ? (0, _lit.html)` <div class="tr ${newSchemaLevel <= this.schemaExpandLevel ? '' : 'collapsed'} ${data['::type']}" data-obj="${keyLabel}"> <div class="td no-select key ${data['::deprecated'] ? 'deprecated' : ''}" part="schema-key" style="padding-left:${leftPadding}px;cursor:pointer" @click="${e => this.toggleObjectExpand(e, keyLabel)}"> <div style="display:flex;align-items:center"> ${keyLabel || keyDescr ? (0, _lit.html)`<div class="obj-toggle" data-obj="${keyLabel}">▾</div>` : ''} ${data['::type'] === 'xxx-of-option' || key.startsWith('::OPTION') ? (0, _lit.html)`<span class="xxx-of-key" style="margin-left:-6px">${keyLabel}</span><span class="${isOneOfLabel ? 'xxx-of-key' : 'xxx-of-descr'}">${keyDescr}</span>` : keyLabel.endsWith('*') ? (0, _lit.html)`<span class="key-label requiredStar" style="display:inline-block;margin-left:-6px" title="Required"> ${keyLabel.substring(0, keyLabel.length - 1)}</span>` : (0, _lit.html)`<span class="key-label" style="display:inline-block;margin-left:-6px">${keyLabel === '::props' ? '' : keyLabel}</span>`} </div> </div> <div class="td key-type" part="schema-type"> ${displaySchemaLink ? (0, _lit.html)`<div class="schema-link" style="overflow:hidden;text-overflow:ellipsis" @click="${() => this.scrollToSchemaComponentByName(displaySchemaLink)}"> ${dataType === 'array' ? '[' : ''}<span style="color:var(--primary)">${detailObjType}</span>${dataType === 'array' ? ']' : ''} </div>` : (0, _lit.html)`<div>${(data['::type'] || '').includes('xxx-of') ? '' : `${dataType === 'array' ? '[' : ''}${detailObjType}${dataType === 'array' ? ']' : ''}`}</div>`} <div class="attributes" title="${flags['🆁'] && 'Read only attribute' || flags['🆆'] && 'Write only attribute' || ''}">${flags['🆁'] || flags['🆆'] || ''}</div> </div> <div class="td key-descr" part="schema-description"> <span class="m-markdown-small">${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(displayLine))}</span> ${(_data$Metadata = data['::metadata']) !== null && _data$Metadata !== void 0 && (_data$Metadata$constr = _data$Metadata.constraints) !== null && _data$Metadata$constr !== void 0 && _data$Metadata$constr.length ? (0, _lit.html)`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Constraints: </span>${data['::metadata'].constraints.join(', ')}</div><br>` : ''} </div> </div>` : (0, _lit.html)` ${data['::type'] === 'array' && dataType === 'array' ? (0, _lit.html)`<div class="tr"> <div class="td"> ${dataType} </div> </div>` : ''} `} <div class="object-body"> ${recursiveResult} <div> </div></div>`;
|
172
172
|
return {
|
173
173
|
result: outerResult,
|
174
174
|
keyLabelMaxCharacterLength: Math.max(innerMaxIndentationLevel, (keyLabel || keyDescr).length),
|
@@ -98,8 +98,8 @@ class SchemaTree extends _lit.LitElement {
|
|
98
98
|
const minFieldColWidth = 300 - indentLevel * leftPadding;
|
99
99
|
let openBracket = '';
|
100
100
|
let closeBracket = '';
|
101
|
-
const newSchemaLevel = data['::type']
|
102
|
-
const newIndentLevel =
|
101
|
+
const newSchemaLevel = data['::type'] === 'xxx-of-option' ? schemaLevel : schemaLevel + 1;
|
102
|
+
const newIndentLevel = indentLevel + 1;
|
103
103
|
if (data['::type'] === 'array') {
|
104
104
|
if (dataType === 'array') {
|
105
105
|
const arrType = arrayType !== 'object' ? arrayType : '';
|
@@ -117,13 +117,15 @@ class SchemaTree extends _lit.LitElement {
|
|
117
117
|
}
|
118
118
|
closeBracket = ']';
|
119
119
|
}
|
120
|
-
} else if (data['::type'] === 'xxx-of'
|
121
|
-
if (
|
122
|
-
|
123
|
-
|
124
|
-
|
120
|
+
} else if (data['::type'] === 'xxx-of-option') {
|
121
|
+
if (dataType === 'array') {
|
122
|
+
if (schemaLevel < this.schemaExpandLevel) {
|
123
|
+
openBracket = (0, _lit.html)`<span class="open-bracket array" @click="${this.toggleObjectExpand}">[</span>`;
|
124
|
+
} else {
|
125
|
+
openBracket = (0, _lit.html)`<span class="open-bracket array" @click="${this.toggleObjectExpand}">[...]</span>`;
|
126
|
+
}
|
127
|
+
closeBracket = ']';
|
125
128
|
}
|
126
|
-
closeBracket = ']';
|
127
129
|
} else if (data['::type']) {
|
128
130
|
if (dataType === 'array') {
|
129
131
|
if (schemaLevel < this.schemaExpandLevel) {
|
@@ -150,7 +152,7 @@ class SchemaTree extends _lit.LitElement {
|
|
150
152
|
return undefined;
|
151
153
|
}
|
152
154
|
const displayLine = [flags['🆁'] || flags['🆆'], title && `**${title}${description ? ':' : ''}**`, description].filter(v => v).join(' ');
|
153
|
-
return (0, _lit.html)` <div class="tr ${schemaLevel < this.schemaExpandLevel || data['::type'] && data['::type'].startsWith('xxx-of') ? '' : 'collapsed'} ${data['::type'] || 'no-type-info'}"> <div class="td key ${data['::deprecated'] ? 'deprecated' : ''}" style="min-width:${minFieldColWidth}px"> ${data['::type'] === 'xxx-of-option' ||
|
155
|
+
return (0, _lit.html)` <div class="tr ${schemaLevel < this.schemaExpandLevel || data['::type'] && data['::type'].startsWith('xxx-of') ? '' : 'collapsed'} ${data['::type'] || 'no-type-info'}"> <div class="td key ${data['::deprecated'] ? 'deprecated' : ''}" style="min-width:${minFieldColWidth}px"> ${data['::type'] === 'xxx-of-option' || key.startsWith('::OPTION') ? (0, _lit.html)`<span class="key-label xxx-of-key">${keyLabel}</span><span class="xxx-of-descr">${keyDescr}</span>` : keyLabel === '::props' || keyLabel === '::ARRAY~OF' ? '' : schemaLevel > 0 ? (0, _lit.html)`<span class="key-label"> ${keyLabel.replace(/\*$/, '')}${keyLabel.endsWith('*') ? (0, _lit.html)`<span class="requiredStar" title="Required"></span>` : ''}: </span>` : ''} ${openBracket} </div> <div class="td key-descr"> <span class="m-markdown-small" style="vertical-align:middle" title="${flags['🆁'] && 'Read only attribute' || flags['🆆'] && 'Write only attribute' || ''}"> ${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(displayLine))} </span> ${this.schemaDescriptionExpanded ? (0, _lit.html)` ${(_data$Metadata = data['::metadata']) !== null && _data$Metadata !== void 0 && (_data$Metadata$constr = _data$Metadata.constraints) !== null && _data$Metadata$constr !== void 0 && _data$Metadata$constr.length ? (0, _lit.html)`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Constraints: </span>${data['::metadata'].constraints.join(', ')}</div><br>` : ''}` : ''} </div> </div> <div class="inside-bracket-wrapper"> <div class="inside-bracket ${data['::type'] || 'no-type-info'}" style="padding-left:${data['::type'] === 'xxx-of-option' ? 0 : leftPadding}px"> ${Array.isArray(data) && data[0] ? (0, _lit.html)`${this.generateTree(data[0], 'xxx-of-option', '', data[0]['::flags'] || {}, '::ARRAY~OF', data[0]['::title'], data[0]['::description'], newSchemaLevel, newIndentLevel)}` : (0, _lit.html)` ${Object.keys(data).map(dataKey => {
|
154
156
|
var _data$dataKey;
|
155
157
|
return !['::metadata', '::title', '::description', '::type', '::link', '::props', '::deprecated', '::array-type', '::dataTypeLabel', '::flags'].includes(dataKey) || (_data$dataKey = data[dataKey]) !== null && _data$dataKey !== void 0 && _data$dataKey['::type'] && !data[dataKey]['::type'].includes('xxx-of') ? (0, _lit.html)`${this.generateTree(data[dataKey]['::type'] === 'array' ? data[dataKey]['::props'] : data[dataKey], data[dataKey]['::type'], data[dataKey]['::array-type'] || '', data[dataKey]['::flags'], dataKey, data[dataKey]['::title'], data[dataKey]['::description'], newSchemaLevel, newIndentLevel)}` : '';
|
156
158
|
})}`} </div> ${data['::type'] && data['::type'].includes('xxx-of') ? '' : (0, _lit.html)`<div class="close-bracket"> ${closeBracket} </div>`} </div> `;
|
@@ -385,32 +385,24 @@ function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '') {
|
|
385
385
|
}
|
386
386
|
if (anyOf || oneOf) {
|
387
387
|
const objWithAnyOfProps = {};
|
388
|
+
objWithAnyOfProps['::type'] = 'xxx-of-option';
|
388
389
|
let writeOnly = true;
|
389
390
|
let readOnly = true;
|
390
391
|
(anyOf || oneOf || []).forEach((v, index) => {
|
391
|
-
if (v.type === 'object' || v.properties || v.allOf || v.anyOf || v.oneOf) {
|
392
|
+
if (v.type === 'object' || v.properties || v.allOf || v.anyOf || v.oneOf || v.type === 'array' || v.items) {
|
392
393
|
const partialObj = schemaInObjectNotation(v, options);
|
393
394
|
if (partialObj) {
|
394
395
|
var _partialObj$Flags, _partialObj$Flags2;
|
395
396
|
objWithAnyOfProps[`::OPTION~${index + 1}${v.title ? `~${v.title}` : ''}`] = partialObj;
|
396
|
-
objWithAnyOfProps['::type'] = 'xxx-of-option';
|
397
397
|
readOnly = readOnly && ((_partialObj$Flags = partialObj['::flags']) === null || _partialObj$Flags === void 0 ? void 0 : _partialObj$Flags['🆁']);
|
398
398
|
writeOnly = writeOnly && ((_partialObj$Flags2 = partialObj['::flags']) === null || _partialObj$Flags2 === void 0 ? void 0 : _partialObj$Flags2['🆆']);
|
399
399
|
}
|
400
|
-
} else if (v.type === 'array' || v.items) {
|
401
|
-
var _partialObj$Flags3, _partialObj$Flags4;
|
402
|
-
const partialObj = schemaInObjectNotation(v, options);
|
403
|
-
objWithAnyOfProps[`::OPTION~${index + 1}${v.title ? `~${v.title}` : ''}`] = partialObj;
|
404
|
-
objWithAnyOfProps['::type'] = 'xxx-of-array';
|
405
|
-
readOnly = readOnly && ((_partialObj$Flags3 = partialObj['::flags']) === null || _partialObj$Flags3 === void 0 ? void 0 : _partialObj$Flags3['🆁']);
|
406
|
-
writeOnly = writeOnly && ((_partialObj$Flags4 = partialObj['::flags']) === null || _partialObj$Flags4 === void 0 ? void 0 : _partialObj$Flags4['🆆']);
|
407
400
|
} else {
|
408
401
|
const typeInfo = getTypeInfo(v, options);
|
409
402
|
if (typeInfo !== null && typeInfo !== void 0 && typeInfo.type) {
|
410
403
|
var _objWithAnyOfProps$, _objWithAnyOfProps$2;
|
411
404
|
const prop = `::OPTION~${index + 1}${v.title ? `~${v.title}` : ''}`;
|
412
405
|
objWithAnyOfProps[prop] = `${typeInfo.html}`;
|
413
|
-
objWithAnyOfProps['::type'] = 'xxx-of-option';
|
414
406
|
readOnly = readOnly && ((_objWithAnyOfProps$ = objWithAnyOfProps['::flags']) === null || _objWithAnyOfProps$ === void 0 ? void 0 : _objWithAnyOfProps$['🆁']);
|
415
407
|
writeOnly = writeOnly && ((_objWithAnyOfProps$2 = objWithAnyOfProps['::flags']) === null || _objWithAnyOfProps$2 === void 0 ? void 0 : _objWithAnyOfProps$2['🆆']);
|
416
408
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "openapi-explorer",
|
3
|
-
"version": "2.2.
|
3
|
+
"version": "2.2.696",
|
4
4
|
"description": "OpenAPI Explorer - API viewer with dynamically generated components, documentation, and interaction console",
|
5
5
|
"author": "Authress Developers <developers@authress.io>",
|
6
6
|
"type": "module",
|