openapi-explorer 2.2.776 → 2.3.779
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/api-response.js +1 -0
- package/dist/es/components/request-form-table.js +1 -1
- package/dist/es/components/schema-table.js +14 -9
- package/dist/es/components/schema-tree.js +48 -42
- package/dist/es/styles/font-styles.js +1 -1
- package/dist/es/templates/components-template.js +1 -1
- package/dist/es/utils/schema-utils.js +11 -7
- package/dist/es/utils/spec-parser.js +4 -4
- package/dist/es/utils/theme.js +1 -1
- package/dist/lib/components/api-response.js +1 -0
- package/dist/lib/components/request-form-table.js +1 -1
- package/dist/lib/components/schema-table.js +14 -9
- package/dist/lib/components/schema-tree.js +48 -42
- package/dist/lib/styles/font-styles.js +1 -1
- package/dist/lib/templates/components-template.js +1 -1
- package/dist/lib/utils/schema-utils.js +11 -7
- package/dist/lib/utils/spec-parser.js +4 -4
- package/dist/lib/utils/theme.js +1 -1
- package/package.json +2 -2
|
@@ -100,6 +100,7 @@ export default class ApiResponse extends LitElement {
|
|
|
100
100
|
const schemaTree = schemaInObjectNotation(mimeRespObj.schema, {
|
|
101
101
|
includeNulls: this.includeNulls
|
|
102
102
|
});
|
|
103
|
+
|
|
103
104
|
// Generate Example
|
|
104
105
|
const respExamples = generateExample(mimeRespObj.examples || '', mimeRespObj.example || '', mimeRespObj.schema, mimeResp, true, false, mimeResp.includes('json') ? 'json' : 'text');
|
|
105
106
|
allMimeResp[mimeResp] = {
|
|
@@ -36,7 +36,7 @@ function generateFormRows(data, options, dataType = 'object', key = '', descript
|
|
|
36
36
|
const displayLine = [description].filter(v => v).join(' ');
|
|
37
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(toMarkdown(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
|
-
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)}` : '';
|
|
39
|
+
return !['::metadata', '::title', '::description', '::type', '::link', '::circular', '::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
|
})}`}`;
|
|
41
41
|
}
|
|
42
42
|
|
|
@@ -17,6 +17,10 @@ export default class SchemaTable extends LitElement {
|
|
|
17
17
|
type: String,
|
|
18
18
|
attribute: 'schema-hide-read-only'
|
|
19
19
|
},
|
|
20
|
+
hideComponentTitle: {
|
|
21
|
+
type: Boolean,
|
|
22
|
+
attribute: 'hide-component-title'
|
|
23
|
+
},
|
|
20
24
|
schemaHideWriteOnly: {
|
|
21
25
|
type: String,
|
|
22
26
|
attribute: 'schema-hide-write-only'
|
|
@@ -52,20 +56,20 @@ export default class SchemaTable extends LitElement {
|
|
|
52
56
|
this.interactive = true; // Note: interactive is not a reactive property
|
|
53
57
|
}
|
|
54
58
|
static finalizeStyles() {
|
|
55
|
-
return [FontStyles, KeyFrameStyles, SchemaStyles, css`.table{font-size:var(--font-size-small);text-align:left;line-height:calc(var(--font-size-small) + 6px)}.table .tr{width:calc(100% - 5px);padding:0 0 0 5px;border-bottom:1px dotted var(--light-border-color)}.table .td{padding:4px 0}.requiredStar::after{content:'*';color:var(--red);font-size:larger}.key.deprecated .key-label{text-decoration:line-through}.table .key-type{white-space:normal}.key-type{display:flex}.key-type>.attributes{margin:.0625rem 0 0 .25rem}.obj-toggle{display:inline-flex;margin-left:-.8rem;margin-right:.8rem;color:var(--primary-color);cursor:pointer;font-size:calc(var(--font-size-small) + 4px);font-family:var(--font-mono);background-clip:border-box}.tr+.object-body{overflow:hidden}.table:not(.interactive) .object-body{animation-duration:0s!important}.tr:not(.collapsed)+.object-body{animation:linear .2s expand-height}.tr.collapsed+.object-body{animation:linear .2s collapse-height;max-height:0}.obj-toggle{transition:transform .1s ease}.tr.collapsed .obj-toggle{transform:rotate(-90deg)}`];
|
|
59
|
+
return [FontStyles, KeyFrameStyles, SchemaStyles, css`.table{font-size:var(--font-size-small);text-align:left;line-height:calc(var(--font-size-small) + 6px)}.table .tr{width:calc(100% - 5px);padding:0 0 0 5px;border-bottom:1px dotted var(--light-border-color)}.table .td{padding:4px 0}.requiredStar::after{content:'*';color:var(--red);font-size:larger}.key.deprecated .key-label{text-decoration:line-through}.table .key-type{white-space:normal}.key-type{display:flex}.key-type>.attributes{margin:.0625rem 0 0 .25rem}.obj-toggle{display:inline-flex;margin-left:-.8rem;margin-right:.8rem;color:var(--primary-color);cursor:pointer;font-size:calc(var(--font-size-small) + 4px);font-family:var(--font-mono);background-clip:border-box}.tr+.object-body{overflow:hidden}.table:not(.interactive) .object-body{animation-duration:0s!important}.tr:not(.collapsed)+.object-body{animation:linear .2s expand-height}.tr.collapsed+.object-body{animation:linear .2s collapse-height;max-height:0}.obj-toggle{transition:transform .1s ease}.tr.collapsed .obj-toggle{transform:rotate(-90deg)}.tr.object.circular-object .obj-toggle{display:none}.tr.object:not(.circular-object) .key-label{margin-left:-6px}`];
|
|
56
60
|
}
|
|
57
61
|
|
|
58
62
|
/* eslint-disable indent */
|
|
59
63
|
render() {
|
|
60
64
|
var _this$data, _this$data2, _this$data3, _this$data3$Props, _this$data4, _this$data4$Props, _this$data5;
|
|
61
65
|
const title = ((_this$data = this.data) === null || _this$data === void 0 ? void 0 : _this$data['::title']) || ((_this$data2 = this.data) === null || _this$data2 === void 0 ? void 0 : _this$data2['::type']) === 'array' && ((_this$data3 = this.data) === null || _this$data3 === void 0 ? void 0 : (_this$data3$Props = _this$data3['::props']) === null || _this$data3$Props === void 0 ? void 0 : _this$data3$Props['::title']) && `[${(_this$data4 = this.data) === null || _this$data4 === void 0 ? void 0 : (_this$data4$Props = _this$data4['::props']) === null || _this$data4$Props === void 0 ? void 0 : _this$data4$Props['::title']}]`;
|
|
62
|
-
const displayLine = [title, (_this$data5 = this.data) === null || _this$data5 === void 0 ? void 0 : _this$data5['::description']].filter(d => d).join(' - ');
|
|
66
|
+
const displayLine = [!this.hideComponentTitle && title, (_this$data5 = this.data) === null || _this$data5 === void 0 ? void 0 : _this$data5['::description']].filter(d => d).join(' - ');
|
|
63
67
|
const {
|
|
64
68
|
result,
|
|
65
69
|
keyLabelMaxCharacterLength,
|
|
66
70
|
typeMaxCharacterLength
|
|
67
71
|
} = this.data ? this.generateTree(this.data['::type'] === 'array' ? this.data['::props'] : this.data, this.data['::type']) : {};
|
|
68
|
-
return html` ${displayLine ? html`<span class="m-markdown" style="padding-bottom:8px"> ${unsafeHTML(toMarkdown(displayLine))}</span>` : ''} <style>.table .key{width
|
|
72
|
+
return html` ${displayLine ? html`<span class="m-markdown" style="padding-bottom:8px"> ${unsafeHTML(toMarkdown(displayLine))}</span>` : ''} <style>.table .key{width:calc(var(--font-size-small) * ${Math.max(16, keyLabelMaxCharacterLength || 0)});max-width:Min(400px,75%)}.table .key-type{width:calc(var(--font-size-small) * ${Math.max(16, typeMaxCharacterLength || 0)});max-width:25%}</style> <div class="table ${this.interactive ? 'interactive' : ''}"> <div style="border:1px solid var(--light-border-color)"> <div style="display:flex;background-color:var(--bg2);padding:8px 4px;border-bottom:1px solid var(--light-border-color)"> <div class="key" part="schema-key schema-table-header" style="font-family:var(--font-regular);font-weight:700;color:var(--fg);padding-left:${firstColumnInitialPadding}px"> Field </div> <div class="key-type" part="schema-type schema-table-header" style="font-family:var(--font-regular);font-weight:700;color:var(--fg)"> Type </div> <div class="key-descr" part="schema-description schema-table-header" style="font-family:var(--font-regular);font-weight:700;color:var(--fg)"> Description </div> </div> ${result || ''} </div> </div> `;
|
|
69
73
|
}
|
|
70
74
|
scrollToSchemaComponentByName(componentName) {
|
|
71
75
|
this.dispatchEvent(new CustomEvent('scrollToSchemaComponentByName', {
|
|
@@ -150,24 +154,25 @@ export default class SchemaTable extends LitElement {
|
|
|
150
154
|
} else {
|
|
151
155
|
recursiveResult = Object.keys(data).filter(dataKey => {
|
|
152
156
|
var _data$dataKey;
|
|
153
|
-
return !['::metadata', '::title', '::description', '::type', '::link', '::props', '::deprecated', '::array-type', '::dataTypeLabel', '::flags'].includes(dataKey) || ((_data$dataKey = data[dataKey]) === null || _data$dataKey === void 0 ? void 0 : _data$dataKey['::type']) && !data[dataKey]['::type'].includes('xxx-of');
|
|
157
|
+
return !['::metadata', '::title', '::description', '::type', '::link', '::circular', '::props', '::deprecated', '::array-type', '::dataTypeLabel', '::flags'].includes(dataKey) || ((_data$dataKey = data[dataKey]) === null || _data$dataKey === void 0 ? void 0 : _data$dataKey['::type']) && !data[dataKey]['::type'].includes('xxx-of');
|
|
154
158
|
}).map(dataKey => {
|
|
155
159
|
const {
|
|
156
160
|
result: innerResult,
|
|
157
|
-
keyLabelMaxCharacterLength:
|
|
161
|
+
keyLabelMaxCharacterLength: innerObjectLevelIndentationLevel,
|
|
158
162
|
typeMaxCharacterLength: innerObjectLevelTypeMaxCharacterLength
|
|
159
163
|
} = this.generateTree(data[dataKey]['::type'] === 'array' ? data[dataKey]['::props'] : data[dataKey], data[dataKey]['::type'], dataKey, data[dataKey]['::title'], data[dataKey]['::description'], newSchemaLevel, newIndentLevel) || {};
|
|
160
|
-
innerMaxIndentationLevel = Math.max(innerMaxIndentationLevel,
|
|
164
|
+
innerMaxIndentationLevel = Math.max(innerMaxIndentationLevel, innerObjectLevelIndentationLevel);
|
|
161
165
|
innerTypeMaxCharacterLength = Math.max(innerTypeMaxCharacterLength, innerObjectLevelTypeMaxCharacterLength);
|
|
162
166
|
return innerResult;
|
|
163
167
|
});
|
|
164
168
|
}
|
|
165
|
-
const displayLine = [title && `**${title}${description ? ':' : ''}**`, description].filter(v => v).join(' ');
|
|
166
|
-
const
|
|
169
|
+
const displayLine = [title && !data['::link'] && `**${title}${description ? ':' : ''}**`, description].filter(v => v).join(' ');
|
|
170
|
+
const detailObjTypeDisplay = data['::circular'] ? `{ Recursive: ${detailObjType} }` : detailObjType;
|
|
171
|
+
const outerResult = html` ${newSchemaLevel >= 0 && key ? html` <div class="tr ${newSchemaLevel <= this.schemaExpandLevel ? '' : 'collapsed'} ${data['::circular'] ? 'circular-object' : 'object'} ${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)}"> <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="key-label xxx-of-key">${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" title="Required"> ${keyLabel.substring(0, keyLabel.length - 1)}</span>` : html`<span class="key-label" style="display:inline-block">${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(--secondary-color)">${detailObjTypeDisplay}</span>${dataType === 'array' ? ']' : ''} </div>` : html`<div>${(data['::type'] || '').includes('xxx-of') ? '' : `${dataType === 'array' ? '[' : ''}${detailObjTypeDisplay}${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(toMarkdown(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
172
|
return {
|
|
168
173
|
result: outerResult,
|
|
169
174
|
keyLabelMaxCharacterLength: Math.max(innerMaxIndentationLevel, (keyLabel || keyDescr).length),
|
|
170
|
-
typeMaxCharacterLength: Math.max(innerTypeMaxCharacterLength,
|
|
175
|
+
typeMaxCharacterLength: Math.max(innerTypeMaxCharacterLength, detailObjTypeDisplay.length)
|
|
171
176
|
};
|
|
172
177
|
}
|
|
173
178
|
|
|
@@ -23,6 +23,10 @@ export default class SchemaTree extends LitElement {
|
|
|
23
23
|
type: String,
|
|
24
24
|
attribute: 'schema-hide-read-only'
|
|
25
25
|
},
|
|
26
|
+
hideComponentTitle: {
|
|
27
|
+
type: Boolean,
|
|
28
|
+
attribute: 'hide-component-title'
|
|
29
|
+
},
|
|
26
30
|
schemaHideWriteOnly: {
|
|
27
31
|
type: String,
|
|
28
32
|
attribute: 'schema-hide-write-only'
|
|
@@ -63,13 +67,20 @@ export default class SchemaTree extends LitElement {
|
|
|
63
67
|
render() {
|
|
64
68
|
var _this$data, _this$data2, _this$data3, _this$data3$Props, _this$data4, _this$data4$Props, _this$data5;
|
|
65
69
|
const title = ((_this$data = this.data) === null || _this$data === void 0 ? void 0 : _this$data['::title']) || ((_this$data2 = this.data) === null || _this$data2 === void 0 ? void 0 : _this$data2['::type']) === 'array' && ((_this$data3 = this.data) === null || _this$data3 === void 0 ? void 0 : (_this$data3$Props = _this$data3['::props']) === null || _this$data3$Props === void 0 ? void 0 : _this$data3$Props['::title']) && `[${(_this$data4 = this.data) === null || _this$data4 === void 0 ? void 0 : (_this$data4$Props = _this$data4['::props']) === null || _this$data4$Props === void 0 ? void 0 : _this$data4$Props['::title']}]`;
|
|
66
|
-
const displayLine = [title, (_this$data5 = this.data) === null || _this$data5 === void 0 ? void 0 : _this$data5['::description']].filter(d => d).join(' - ');
|
|
70
|
+
const displayLine = [!this.hideComponentTitle && title, (_this$data5 = this.data) === null || _this$data5 === void 0 ? void 0 : _this$data5['::description']].filter(d => d).join(' - ');
|
|
67
71
|
return html` <div class="tree ${this.interactive ? 'interactive' : ''}"> <div class="toolbar"> ${displayLine ? html`<span class="m-markdown" style="margin-block-start:0"> ${unsafeHTML(toMarkdown(displayLine))}</span>` : html`<div> </div>`} <div class="toolbar-item" @click="${() => this.toggleSchemaDescription()}"> ${this.schemaDescriptionExpanded ? getI18nText('schemas.collapse-desc') : getI18nText('schemas.expand-desc')} </div> </div> ${this.data ? html`${this.generateTree(this.data['::type'] === 'array' ? this.data['::props'] : this.data, this.data['::type'], this.data['::array-type'] || '')}` : html`<span class="mono-font" style="color:var(--red)"> ${getI18nText('schemas.schema-missing')} </span>`} </div> `;
|
|
68
72
|
}
|
|
69
73
|
toggleSchemaDescription() {
|
|
70
74
|
this.schemaDescriptionExpanded = !this.schemaDescriptionExpanded;
|
|
71
75
|
this.requestUpdate();
|
|
72
76
|
}
|
|
77
|
+
scrollToSchemaComponentByName(componentName) {
|
|
78
|
+
this.dispatchEvent(new CustomEvent('scrollToSchemaComponentByName', {
|
|
79
|
+
bubbles: true,
|
|
80
|
+
composed: true,
|
|
81
|
+
detail: componentName
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
73
84
|
generateTree(data, dataType = 'object', arrayType = '', flags = {}, key = '', title = '', description = '', schemaLevel = 0, indentLevel = 0) {
|
|
74
85
|
if (!data) {
|
|
75
86
|
return html`<div class="null" style="display:inline"> <span class="key-label xxx-of-key"> ${key.replace('::OPTION~', '')}</span> ${dataType === 'array' && html`<span class="mono-font"> [ ] </span>` || dataType === 'object' && html`<span class="mono-font"> { } </span>` || html`<span class="mono-font"> ${dataType} </span>`} </div>`;
|
|
@@ -91,53 +102,48 @@ export default class SchemaTree extends LitElement {
|
|
|
91
102
|
const leftPadding = 16;
|
|
92
103
|
// Min-width used for model keys: `td key `
|
|
93
104
|
const minFieldColWidth = 300 - indentLevel * leftPadding;
|
|
94
|
-
let openBracket = '';
|
|
95
|
-
let closeBracket = '';
|
|
96
105
|
const newSchemaLevel = data['::type'] === 'xxx-of-option' ? schemaLevel : schemaLevel + 1;
|
|
97
106
|
const newIndentLevel = indentLevel + 1;
|
|
98
|
-
|
|
99
|
-
if (
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
107
|
+
const [openBracket, closeBracket] = (() => {
|
|
108
|
+
if (data['::circular']) {
|
|
109
|
+
const displaySchemaLink = data['::link'];
|
|
110
|
+
return [html`<span class="open-bracket object" @click="${() => this.scrollToSchemaComponentByName(displaySchemaLink)}"> <span>${dataType === 'array' ? '[' : ''}<span style="color:var(--secondary-color)">{${displaySchemaLink}}</span>${dataType === 'array' ? ']' : ''}</span> </span>`];
|
|
111
|
+
}
|
|
112
|
+
if (data['::type'] === 'array') {
|
|
113
|
+
if (dataType === 'array') {
|
|
114
|
+
const arrType = arrayType !== 'object' ? arrayType : '';
|
|
115
|
+
if (schemaLevel < this.schemaExpandLevel && !data['::circular']) {
|
|
116
|
+
return [html`<span class="open-bracket array-of-array" data-array-type="${arrType}" @click="${this.toggleObjectExpand}">[[ ${arrType} </span>`, ']]'];
|
|
117
|
+
}
|
|
118
|
+
return [html`<span class="open-bracket array-of-array" data-array-type="${arrType}" @click="${this.toggleObjectExpand}">[[...]]</span>`];
|
|
105
119
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if (schemaLevel < this.schemaExpandLevel) {
|
|
109
|
-
openBracket = html`<span class="open-bracket array" @click="${this.toggleObjectExpand}">[</span>`;
|
|
110
|
-
} else {
|
|
111
|
-
openBracket = html`<span class="open-bracket array" @click="${this.toggleObjectExpand}">[...]</span>`;
|
|
120
|
+
if (schemaLevel < this.schemaExpandLevel && !data['::circular']) {
|
|
121
|
+
return [html`<span class="open-bracket array" @click="${this.toggleObjectExpand}">[</span>`, ']'];
|
|
112
122
|
}
|
|
113
|
-
|
|
123
|
+
return [html`<span class="open-bracket array" @click="${this.toggleObjectExpand}">[...]</span>`];
|
|
114
124
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
125
|
+
if (data['::type'] === 'xxx-of-option') {
|
|
126
|
+
if (dataType === 'array') {
|
|
127
|
+
if (schemaLevel < this.schemaExpandLevel && !data['::circular']) {
|
|
128
|
+
return [html`<span class="open-bracket array" @click="${this.toggleObjectExpand}">[</span>`, ']'];
|
|
129
|
+
}
|
|
130
|
+
return [html`<span class="open-bracket array" @click="${this.toggleObjectExpand}">[...]</span>`];
|
|
121
131
|
}
|
|
122
|
-
closeBracket = ']';
|
|
123
132
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
133
|
+
if (data['::type']) {
|
|
134
|
+
if (dataType === 'array') {
|
|
135
|
+
if (schemaLevel < this.schemaExpandLevel && !data['::circular']) {
|
|
136
|
+
return [html`<span class="open-bracket array-of-object" @click="${this.toggleObjectExpand}">[{</span>`, '}]'];
|
|
137
|
+
}
|
|
138
|
+
return [html`<span class="open-bracket array-of-object" @click="${this.toggleObjectExpand}">[{...}]</span>`];
|
|
130
139
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
if (schemaLevel < this.schemaExpandLevel) {
|
|
134
|
-
openBracket = html`<span class="open-bracket object" @click="${this.toggleObjectExpand}">{</span>`;
|
|
135
|
-
} else {
|
|
136
|
-
openBracket = html`<span class="open-bracket object" @click="${this.toggleObjectExpand}">{...}</span>`;
|
|
140
|
+
if (schemaLevel < this.schemaExpandLevel && !data['::circular']) {
|
|
141
|
+
return [html`<span class="open-bracket object" @click="${this.toggleObjectExpand}">{</span>`, '}'];
|
|
137
142
|
}
|
|
138
|
-
|
|
143
|
+
return [html`<span class="open-bracket object" @click="${this.toggleObjectExpand}">{...}</span>`];
|
|
139
144
|
}
|
|
140
|
-
|
|
145
|
+
return [''];
|
|
146
|
+
})();
|
|
141
147
|
if (typeof data === 'object') {
|
|
142
148
|
var _data$Metadata, _data$Metadata$constr;
|
|
143
149
|
if (flags['🆁'] && this.schemaHideReadOnly === 'true') {
|
|
@@ -146,11 +152,11 @@ export default class SchemaTree extends LitElement {
|
|
|
146
152
|
if (flags['🆆'] && this.schemaHideWriteOnly === 'true') {
|
|
147
153
|
return undefined;
|
|
148
154
|
}
|
|
149
|
-
const displayLine = [flags['🆁'] || flags['🆆'], title && `**${title}${description ? ':' : ''}**`, description].filter(v => v).join(' ');
|
|
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(toMarkdown(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 => {
|
|
155
|
+
const displayLine = [flags['🆁'] || flags['🆆'], title && !data['::link'] && `**${title}${description ? ':' : ''}**`, description].filter(v => v).join(' ');
|
|
156
|
+
return html` <div class="tr ${schemaLevel < this.schemaExpandLevel || data['::type'] && data['::type'].startsWith('xxx-of') ? '' : 'collapsed'} ${data['::circular'] ? 'circular-object' : 'object'} ${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(toMarkdown(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 => {
|
|
151
157
|
var _data$dataKey;
|
|
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)}` : '';
|
|
153
|
-
})}`} </div> ${data['::type'] && data['::type'].includes('xxx-of') ? '' : html`<div class="close-bracket"> ${closeBracket} </div>`} </div> `;
|
|
158
|
+
return !['::metadata', '::title', '::description', '::type', '::link', '::circular', '::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)}` : '';
|
|
159
|
+
})}`} </div> ${!closeBracket || data['::type'] && data['::type'].includes('xxx-of') ? '' : html`<div class="close-bracket"> ${closeBracket} </div>`} </div> `;
|
|
154
160
|
}
|
|
155
161
|
|
|
156
162
|
// For Primitive Data types
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
|
-
export default css`.hover-bg:hover{background:var(--bg3)}::selection{background:var(--selection-bg);color:var(--selection-fg)}.regular-font{font-family:var(--font-regular)}.mono-font{font-family:var(--font-mono)}.title{font-size:calc(var(--font-size-small) + 1rem);font-weight:400}.sub-title{font-size:20px}.req-res-title{font-family:var(--font-regular);font-size:calc(var(--font-size-small) + 4px);font-weight:700}.tiny-title{font-size:calc(var(--font-size-small) + 1px);font-weight:700}.regular-font-size{font-size:var(--font-size-regular)}.small-font-size{font-size:var(--font-size-small)}.upper{text-transform:uppercase}.primary-text{color:var(--primary-color)}.bold-text{font-weight:700}.gray-text{color:var(--light-fg)}.red-text{color:var(--red)}.blue-text{color:var(--blue)}.multiline{overflow:scroll;max-height:var(--resp-area-height,300px);color:var(--fg3)}.method-fg.put{color:var(--orange)}.method-fg.post{color:var(--green)}.method-fg.get,.method-fg.head{color:var(--blue)}.method-fg.delete{color:var(--red)}.method-fg.query{color:var(--purple)}.method-fg.trace{color:var(--purple)}.method-fg.options{color:var(--gray)}.method-fg.patch{color:var(--yellow)}h1{font-family:var(--font-regular);font-size:28px;padding-top:10px;letter-spacing:normal;font-weight:400}h2{font-family:var(--font-regular);font-size:24px;padding-top:10px;letter-spacing:normal;font-weight:400}h3{font-family:var(--font-regular);font-size:18px;padding-top:10px;letter-spacing:normal;font-weight:400}h4{font-family:var(--font-regular);font-size:16px;padding-top:10px;letter-spacing:normal;font-weight:400}h5{font-family:var(--font-regular);font-size:14px;padding-top:10px;letter-spacing:normal;font-weight:400}h6{font-family:var(--font-regular);font-size:14px;padding-top:10px;letter-spacing:normal;font-weight:400}h1,h2,h3,h4,h5{margin-block-end:.2em;margin-block-start:.5em}h3{margin-top:0}p{margin-block-start:.5em}a{color:var(--blue);cursor:pointer}a.inactive-link{color:var(--fg);text-decoration:none;cursor:text}code,pre,syntax-highlighter{margin:0;font-family:var(--font-mono);font-size:
|
|
2
|
+
export default css`.hover-bg:hover{background:var(--bg3)}::selection{background:var(--selection-bg);color:var(--selection-fg)}.regular-font{font-family:var(--font-regular)}.mono-font{font-family:var(--font-mono)}.title{font-size:calc(var(--font-size-small) + 1rem);font-weight:400}.sub-title{font-size:20px}.req-res-title{font-family:var(--font-regular);font-size:calc(var(--font-size-small) + 4px);font-weight:700}.tiny-title{font-size:calc(var(--font-size-small) + 1px);font-weight:700}.regular-font-size{font-size:var(--font-size-regular)}.small-font-size{font-size:var(--font-size-small)}.upper{text-transform:uppercase}.primary-text{color:var(--primary-color)}.bold-text{font-weight:700}.gray-text{color:var(--light-fg)}.red-text{color:var(--red)}.blue-text{color:var(--blue)}.multiline{overflow:scroll;max-height:var(--resp-area-height,300px);color:var(--fg3)}.method-fg.put{color:var(--orange)}.method-fg.post{color:var(--green)}.method-fg.get,.method-fg.head{color:var(--blue)}.method-fg.delete{color:var(--red)}.method-fg.query{color:var(--purple)}.method-fg.trace{color:var(--purple)}.method-fg.options{color:var(--gray)}.method-fg.patch{color:var(--yellow)}h1{font-family:var(--font-regular);font-size:28px;padding-top:10px;letter-spacing:normal;font-weight:400}h2{font-family:var(--font-regular);font-size:24px;padding-top:10px;letter-spacing:normal;font-weight:400}h3{font-family:var(--font-regular);font-size:18px;padding-top:10px;letter-spacing:normal;font-weight:400}h4{font-family:var(--font-regular);font-size:16px;padding-top:10px;letter-spacing:normal;font-weight:400}h5{font-family:var(--font-regular);font-size:14px;padding-top:10px;letter-spacing:normal;font-weight:400}h6{font-family:var(--font-regular);font-size:14px;padding-top:10px;letter-spacing:normal;font-weight:400}h1,h2,h3,h4,h5{margin-block-end:.2em;margin-block-start:.5em}h3{margin-top:0}p{margin-block-start:.5em}a{color:var(--blue);cursor:pointer}a.inactive-link{color:var(--fg);text-decoration:none;cursor:text}code,pre,syntax-highlighter{margin:0;font-family:var(--font-mono);font-size:var(--font-size-mono)}.m-markdown syntax-highlighter{display:block}.m-markdown,.m-markdown-small{display:block}.m-markdown a,.m-markdown li,.m-markdown p,.m-markdown span{font-size:var(--font-size-regular);line-height:calc(var(--font-size-regular) + 6px)}.m-markdown-small a,.m-markdown-small li,.m-markdown-small p,.m-markdown-small span{font-size:var(--font-size-small);line-height:calc(var(--font-size-small) + 6px)}.m-markdown p:not(:first-child){margin-block-start:12px}.m-markdown-small p:not(:first-child){margin-block-start:12px}.m-markdown :first-child,.m-markdown-small :first-child{margin-block-start:0}.m-markdown p,.m-markdown-small p{margin-block-end:0;overflow-wrap:anywhere}.toolbar .m-markdown p,.toolbar .m-markdown-small p{margin-block-start:0}.m-markdown code span{font-size:var(--font-size-mono)}.m-markdown code,.m-markdown syntax-highlighter,.m-markdown-small code{padding:1px 6px;border-radius:2px;color:var(--inline-code-fg);background-color:var(--bg3);font-size:calc(var(--font-size-mono));line-height:1.2}.m-markdown-small code,.m-markdown-small syntax-highlighter{font-size:var(--font-size-mono)}.m-markdown pre,.m-markdown syntax-highlighter,.m-markdown-small pre{white-space:pre-wrap;overflow-x:auto;line-height:normal;border-radius:2px;border:1px solid var(--code-border-color)}.m-markdown pre,.m-markdown syntax-highlighter{padding:8px;background-color:var(--bg2);color:var(--code-fg)}.m-markdown-small pre,.m-markdown-small syntax-highlighter{margin-top:4px;padding:2px 4px;background-color:var(--bg3);color:var(--fg2)}.m-markdown pre code,.m-markdown-small pre code{border:none;padding:0}.m-markdown pre code{color:var(--code-fg);background-color:var(--bg2);background-color:transparent}.m-markdown-small pre code,.m-markdown-small syntax-highlighter{color:var(--fg2);background-color:var(--bg3)}.m-markdown ol,.m-markdown ul{padding-inline-start:30px}.m-markdown-small ol,.m-markdown-small ul{padding-inline-start:20px}.m-markdown a,.m-markdown-small a{color:var(--blue)}.m-markdown img,.m-markdown-small img{max-width:100%}.m-markdown table,.m-markdown-small table{border-spacing:0;margin:10px 0;border-collapse:separate;border:1px solid var(--border-color);border-radius:var(--border-radius);font-size:calc(var(--font-size-small) + 1px);line-height:calc(var(--font-size-small) + 4px);max-width:100%}.m-markdown-small table{font-size:var(--font-size-small);line-height:calc(var(--font-size-small) + 2px);margin:8px 0}.m-markdown td,.m-markdown th,.m-markdown-small td,.m-markdown-small th{vertical-align:top;border-top:1px solid var(--border-color);line-height:calc(var(--font-size-small) + 4px)}.m-markdown tr:first-child th,.m-markdown-small tr:first-child th{border-top:0 none}.m-markdown td,.m-markdown th{padding:10px 12px}.m-markdown-small td,.m-markdown-small th{padding:8px 8px}.m-markdown th,.m-markdown-small th{font-weight:600;background-color:var(--bg2);vertical-align:middle}.m-markdown-small table code{font-size:calc(var(--font-size-mono) - 1px)}.m-markdown table code{font-size:var(--font-size-mono)}.m-markdown blockquote,.m-markdown-small blockquote{margin-inline-start:0;margin-inline-end:0;border-left:3px solid var(--border-color);padding:6px 0 6px 6px}`;
|
|
@@ -9,7 +9,7 @@ function componentBodyTemplate(sComponent) {
|
|
|
9
9
|
const formdataPartSchema = schemaInObjectNotation(sComponent.component, {
|
|
10
10
|
includeNulls: this.includeNulls
|
|
11
11
|
});
|
|
12
|
-
return html` <div class="expanded-endpoint-component observe-me ${sComponent.
|
|
12
|
+
return html` <div class="expanded-endpoint-component observe-me ${sComponent.id}" id="cmp--${sComponent.id}"> <h2 @click="${() => this.scrollTo(`cmp--${sComponent.id}`)}">${sComponent.name}</h2> <div class="mono-font regular-font-size" style="padding:8px 0;color:var(--fg2)"> ${!this.displaySchemaAsTree ? html`<schema-table .data="${formdataPartSchema}" @scrollToSchemaComponentByName="${v => this.scrollToSchemaComponentByName(v)}" schema-expand-level="${this.schemaExpandLevel}" hide-component-title="${true}" schema-hide-read-only="${false}" schema-hide-write-only="${false}" exportparts="schema-key, schema-type, schema-description, schema-table-header"> </schema-table>` : html`<schema-tree .data="${formdataPartSchema}" schema-expand-level="${this.schemaExpandLevel}" hide-component-title="${true}" schema-hide-read-only="${false}" schema-hide-write-only="${false}" exportparts="schema-key, schema-type, schema-description"> </schema-tree>`} </div> </div> `;
|
|
13
13
|
}
|
|
14
14
|
export function getComponentInfo(componentKeyId) {
|
|
15
15
|
const infoDictionary = {
|
|
@@ -19,9 +19,7 @@ export function getTypeInfo(parameter, options = {
|
|
|
19
19
|
const schema = Object.assign({}, parameter, parameter.schema);
|
|
20
20
|
let dataType = IS_MISSING_TYPE_INFO_TYPE;
|
|
21
21
|
let format = schema.format || ((_schema$items = schema.items) === null || _schema$items === void 0 ? void 0 : _schema$items.format) || '';
|
|
22
|
-
if (schema.
|
|
23
|
-
dataType = `{recursive: ${schema.circularReference.name}} `;
|
|
24
|
-
} else if (schema.type || schema.const) {
|
|
22
|
+
if (schema.type || schema.const) {
|
|
25
23
|
if (!schema.type && schema.const) {
|
|
26
24
|
schema.type = 'const';
|
|
27
25
|
}
|
|
@@ -413,7 +411,8 @@ export function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '
|
|
|
413
411
|
resultObj[anyOf ? `::ANY~OF ${suffix}` : `::ONE~OF ${suffix}`] = objWithAnyOfProps;
|
|
414
412
|
}
|
|
415
413
|
resultObj['::link'] = schema.title || '';
|
|
416
|
-
resultObj['::
|
|
414
|
+
resultObj['::circular'] = !!schema.circularReference;
|
|
415
|
+
resultObj['::type'] = 'object';
|
|
417
416
|
resultObj['::flags'] = {
|
|
418
417
|
'🆁': readOnly && '🆁',
|
|
419
418
|
'🆆': writeOnly && '🆆'
|
|
@@ -457,6 +456,7 @@ export function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '
|
|
|
457
456
|
}
|
|
458
457
|
if (complexTypes.length > 0) {
|
|
459
458
|
obj['::link'] = schema.title || '';
|
|
459
|
+
obj['::circular'] = !!schema.circularReference;
|
|
460
460
|
obj['::type'] = 'object';
|
|
461
461
|
const multiTypeOptions = {
|
|
462
462
|
'::type': 'xxx-of-option'
|
|
@@ -480,7 +480,8 @@ export function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '
|
|
|
480
480
|
'🆆': schema.writeOnly && '🆆'
|
|
481
481
|
},
|
|
482
482
|
'::link': schema.title || '',
|
|
483
|
-
'::
|
|
483
|
+
'::circular': !!schema.circularReference,
|
|
484
|
+
'::type': 'object',
|
|
484
485
|
'::deprecated': schema.deprecated || false,
|
|
485
486
|
'::metadata': metadata
|
|
486
487
|
};
|
|
@@ -502,6 +503,7 @@ export function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '
|
|
|
502
503
|
'🆆': schema.writeOnly && '🆆'
|
|
503
504
|
},
|
|
504
505
|
'::link': arrayItemsSchema.title || schema.title || '',
|
|
506
|
+
'::circular': !!schema.circularReference,
|
|
505
507
|
'::type': 'array',
|
|
506
508
|
// Array properties are read from the ::props object instead of reading from the keys of this object
|
|
507
509
|
'::props': schemaInObjectNotation(Object.assign({}, schema, arrayItemsSchema, {
|
|
@@ -517,7 +519,7 @@ export function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '
|
|
|
517
519
|
}
|
|
518
520
|
return obj;
|
|
519
521
|
}
|
|
520
|
-
if (propertyType === 'object' || schemaProperties) {
|
|
522
|
+
if (propertyType === 'object' || schemaProperties || schema.circularReference) {
|
|
521
523
|
const obj = {
|
|
522
524
|
'::type': ''
|
|
523
525
|
};
|
|
@@ -528,7 +530,8 @@ export function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '
|
|
|
528
530
|
'🆆': schema.writeOnly && '🆆'
|
|
529
531
|
};
|
|
530
532
|
obj['::link'] = schema.title || '';
|
|
531
|
-
obj['::
|
|
533
|
+
obj['::circular'] = !!schema.circularReference;
|
|
534
|
+
obj['::type'] = 'object';
|
|
532
535
|
obj['::deprecated'] = schema.deprecated || false;
|
|
533
536
|
obj['::metadata'] = metadata;
|
|
534
537
|
for (const key in schemaProperties) {
|
|
@@ -559,6 +562,7 @@ export function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '
|
|
|
559
562
|
'🆆': schema.writeOnly && '🆆'
|
|
560
563
|
};
|
|
561
564
|
obj['::link'] = (arrayItemsSchema === null || arrayItemsSchema === void 0 ? void 0 : arrayItemsSchema.title) || schema.title || '';
|
|
565
|
+
obj['::circular'] = !!schema.circularReference;
|
|
562
566
|
obj['::type'] = 'array';
|
|
563
567
|
obj['::deprecated'] = schema.deprecated || false;
|
|
564
568
|
obj['::metadata'] = metadata;
|
|
@@ -135,11 +135,11 @@ function getComponents(openApiSpec) {
|
|
|
135
135
|
}
|
|
136
136
|
const components = [];
|
|
137
137
|
for (const componentKeyId in openApiSpec.components) {
|
|
138
|
-
const subComponents = Object.keys(openApiSpec.components[componentKeyId]).map(
|
|
138
|
+
const subComponents = Object.keys(openApiSpec.components[componentKeyId]).map(sComponentId => ({
|
|
139
139
|
expanded: true,
|
|
140
|
-
id: `${componentKeyId.toLowerCase()}-${
|
|
141
|
-
name:
|
|
142
|
-
component: openApiSpec.components[componentKeyId][
|
|
140
|
+
id: `${componentKeyId.toLowerCase()}-${sComponentId.toLowerCase()}`.replace(invalidCharsRegEx, '-'),
|
|
141
|
+
name: openApiSpec.components[componentKeyId][sComponentId].title || sComponentId,
|
|
142
|
+
component: openApiSpec.components[componentKeyId][sComponentId]
|
|
143
143
|
})).sort((a, b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase()));
|
|
144
144
|
if (componentKeyId === 'requestBodies' || componentKeyId === 'securitySchemes' || componentKeyId === 'securitySchemas') {
|
|
145
145
|
continue;
|
package/dist/es/utils/theme.js
CHANGED
|
@@ -68,5 +68,5 @@ export default function setTheme(theme = {}) {
|
|
|
68
68
|
codeKeywordColor: theme.codeKeywordColor || '#07a',
|
|
69
69
|
codeOperatorColor: theme.codeOperatorColor || '#9a6e3a'
|
|
70
70
|
};
|
|
71
|
-
return html` <style>*,:after,:before{box-sizing:border-box}:host{--border-radius:2px;--layout:${this.layout || 'column'};--nav-path-padding:7px 0 7px 1.5rem;--resp-area-height:${this.responseAreaHeight};--font-size-small:
|
|
71
|
+
return html` <style>*,:after,:before{box-sizing:border-box}:host{--border-radius:2px;--layout:${this.layout || 'column'};--nav-path-padding:7px 0 7px 1.5rem;--resp-area-height:${this.responseAreaHeight};--font-size-small:16px;--font-size-mono:15px;--font-size-regular:18px;--dialog-z-index:1000;--bg:${newTheme.bg1};--bg2:${newTheme.bg2};--bg3:${newTheme.bg3};--light-bg:${newTheme.lightBg};--fg:${newTheme.fg1};--fg2:${newTheme.fg2};--fg3:${newTheme.fg3};--light-fg:${newTheme.lightFg};--selection-bg:${newTheme.selectionBg};--selection-fg:${newTheme.selectionFg};--overlay-bg:${newTheme.overlayBg};--border-color:${newTheme.borderColor};--light-border-color:${newTheme.lightBorderColor};--code-border-color:${newTheme.codeBorderColor};--input-bg:${newTheme.inputBg};--placeholder-color:${newTheme.placeHolder};--hover-color:${newTheme.hoverColor};${defaultColors.join(';\n')} ${lightColors.join(';\n')} --header-bg:${newTheme.headerColor};--header-fg:${newTheme.headerColorInvert};--header-color-darker:${newTheme.headerColorDarker};--header-color-border:${newTheme.headerColorBorder};--nav-bg-color:${newTheme.navBgColor};--nav-text-color:${newTheme.navTextColor};--nav-hover-bg-color:${newTheme.navHoverBgColor};--nav-hover-scrollbar-color:${navHoverScrollbarColor};--nav-hover-text-color:${newTheme.navHoverTextColor};--code-fg:${newTheme.codeFg};--inline-code-fg:${newTheme.inlineCodeFg};--code-property-color:${newTheme.codePropertyColor};--code-keyword-color:${newTheme.codeKeywordColor};--code-operator-color:${newTheme.codeOperatorColor};--primary-color:${theme.primaryColor};--secondary-color:${theme.secondaryColor};--primary-btn-text-color:${ColorUtils.color.selectTextColorFromBackground(theme.primaryColor)}}</style>`;
|
|
72
72
|
}
|
|
@@ -105,6 +105,7 @@ class ApiResponse extends _lit.LitElement {
|
|
|
105
105
|
const schemaTree = (0, _schemaUtils.schemaInObjectNotation)(mimeRespObj.schema, {
|
|
106
106
|
includeNulls: this.includeNulls
|
|
107
107
|
});
|
|
108
|
+
|
|
108
109
|
// Generate Example
|
|
109
110
|
const respExamples = (0, _schemaUtils.generateExample)(mimeRespObj.examples || '', mimeRespObj.example || '', mimeRespObj.schema, mimeResp, true, false, mimeResp.includes('json') ? 'json' : 'text');
|
|
110
111
|
allMimeResp[mimeResp] = {
|
|
@@ -41,7 +41,7 @@ function generateFormRows(data, options, dataType = 'object', key = '', descript
|
|
|
41
41
|
const displayLine = [description].filter(v => v).join(' ');
|
|
42
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, _commonUtils.toMarkdown)(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
|
-
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)}` : '';
|
|
44
|
+
return !['::metadata', '::title', '::description', '::type', '::link', '::circular', '::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
|
})}`}`;
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -22,6 +22,10 @@ class SchemaTable extends _lit.LitElement {
|
|
|
22
22
|
type: String,
|
|
23
23
|
attribute: 'schema-hide-read-only'
|
|
24
24
|
},
|
|
25
|
+
hideComponentTitle: {
|
|
26
|
+
type: Boolean,
|
|
27
|
+
attribute: 'hide-component-title'
|
|
28
|
+
},
|
|
25
29
|
schemaHideWriteOnly: {
|
|
26
30
|
type: String,
|
|
27
31
|
attribute: 'schema-hide-write-only'
|
|
@@ -57,20 +61,20 @@ class SchemaTable extends _lit.LitElement {
|
|
|
57
61
|
this.interactive = true; // Note: interactive is not a reactive property
|
|
58
62
|
}
|
|
59
63
|
static finalizeStyles() {
|
|
60
|
-
return [_fontStyles.default, _keyFrameStyles.default, _schemaStyles.default, (0, _lit.css)`.table{font-size:var(--font-size-small);text-align:left;line-height:calc(var(--font-size-small) + 6px)}.table .tr{width:calc(100% - 5px);padding:0 0 0 5px;border-bottom:1px dotted var(--light-border-color)}.table .td{padding:4px 0}.requiredStar::after{content:'*';color:var(--red);font-size:larger}.key.deprecated .key-label{text-decoration:line-through}.table .key-type{white-space:normal}.key-type{display:flex}.key-type>.attributes{margin:.0625rem 0 0 .25rem}.obj-toggle{display:inline-flex;margin-left:-.8rem;margin-right:.8rem;color:var(--primary-color);cursor:pointer;font-size:calc(var(--font-size-small) + 4px);font-family:var(--font-mono);background-clip:border-box}.tr+.object-body{overflow:hidden}.table:not(.interactive) .object-body{animation-duration:0s!important}.tr:not(.collapsed)+.object-body{animation:linear .2s expand-height}.tr.collapsed+.object-body{animation:linear .2s collapse-height;max-height:0}.obj-toggle{transition:transform .1s ease}.tr.collapsed .obj-toggle{transform:rotate(-90deg)}`];
|
|
64
|
+
return [_fontStyles.default, _keyFrameStyles.default, _schemaStyles.default, (0, _lit.css)`.table{font-size:var(--font-size-small);text-align:left;line-height:calc(var(--font-size-small) + 6px)}.table .tr{width:calc(100% - 5px);padding:0 0 0 5px;border-bottom:1px dotted var(--light-border-color)}.table .td{padding:4px 0}.requiredStar::after{content:'*';color:var(--red);font-size:larger}.key.deprecated .key-label{text-decoration:line-through}.table .key-type{white-space:normal}.key-type{display:flex}.key-type>.attributes{margin:.0625rem 0 0 .25rem}.obj-toggle{display:inline-flex;margin-left:-.8rem;margin-right:.8rem;color:var(--primary-color);cursor:pointer;font-size:calc(var(--font-size-small) + 4px);font-family:var(--font-mono);background-clip:border-box}.tr+.object-body{overflow:hidden}.table:not(.interactive) .object-body{animation-duration:0s!important}.tr:not(.collapsed)+.object-body{animation:linear .2s expand-height}.tr.collapsed+.object-body{animation:linear .2s collapse-height;max-height:0}.obj-toggle{transition:transform .1s ease}.tr.collapsed .obj-toggle{transform:rotate(-90deg)}.tr.object.circular-object .obj-toggle{display:none}.tr.object:not(.circular-object) .key-label{margin-left:-6px}`];
|
|
61
65
|
}
|
|
62
66
|
|
|
63
67
|
/* eslint-disable indent */
|
|
64
68
|
render() {
|
|
65
69
|
var _this$data, _this$data2, _this$data3, _this$data3$Props, _this$data4, _this$data4$Props, _this$data5;
|
|
66
70
|
const title = ((_this$data = this.data) === null || _this$data === void 0 ? void 0 : _this$data['::title']) || ((_this$data2 = this.data) === null || _this$data2 === void 0 ? void 0 : _this$data2['::type']) === 'array' && ((_this$data3 = this.data) === null || _this$data3 === void 0 ? void 0 : (_this$data3$Props = _this$data3['::props']) === null || _this$data3$Props === void 0 ? void 0 : _this$data3$Props['::title']) && `[${(_this$data4 = this.data) === null || _this$data4 === void 0 ? void 0 : (_this$data4$Props = _this$data4['::props']) === null || _this$data4$Props === void 0 ? void 0 : _this$data4$Props['::title']}]`;
|
|
67
|
-
const displayLine = [title, (_this$data5 = this.data) === null || _this$data5 === void 0 ? void 0 : _this$data5['::description']].filter(d => d).join(' - ');
|
|
71
|
+
const displayLine = [!this.hideComponentTitle && title, (_this$data5 = this.data) === null || _this$data5 === void 0 ? void 0 : _this$data5['::description']].filter(d => d).join(' - ');
|
|
68
72
|
const {
|
|
69
73
|
result,
|
|
70
74
|
keyLabelMaxCharacterLength,
|
|
71
75
|
typeMaxCharacterLength
|
|
72
76
|
} = this.data ? this.generateTree(this.data['::type'] === 'array' ? this.data['::props'] : this.data, this.data['::type']) : {};
|
|
73
|
-
return (0, _lit.html)` ${displayLine ? (0, _lit.html)`<span class="m-markdown" style="padding-bottom:8px"> ${(0, _unsafeHtml.unsafeHTML)((0, _commonUtils.toMarkdown)(displayLine))}</span>` : ''} <style>.table .key{width
|
|
77
|
+
return (0, _lit.html)` ${displayLine ? (0, _lit.html)`<span class="m-markdown" style="padding-bottom:8px"> ${(0, _unsafeHtml.unsafeHTML)((0, _commonUtils.toMarkdown)(displayLine))}</span>` : ''} <style>.table .key{width:calc(var(--font-size-small) * ${Math.max(16, keyLabelMaxCharacterLength || 0)});max-width:Min(400px,75%)}.table .key-type{width:calc(var(--font-size-small) * ${Math.max(16, typeMaxCharacterLength || 0)});max-width:25%}</style> <div class="table ${this.interactive ? 'interactive' : ''}"> <div style="border:1px solid var(--light-border-color)"> <div style="display:flex;background-color:var(--bg2);padding:8px 4px;border-bottom:1px solid var(--light-border-color)"> <div class="key" part="schema-key schema-table-header" style="font-family:var(--font-regular);font-weight:700;color:var(--fg);padding-left:${firstColumnInitialPadding}px"> Field </div> <div class="key-type" part="schema-type schema-table-header" style="font-family:var(--font-regular);font-weight:700;color:var(--fg)"> Type </div> <div class="key-descr" part="schema-description schema-table-header" style="font-family:var(--font-regular);font-weight:700;color:var(--fg)"> Description </div> </div> ${result || ''} </div> </div> `;
|
|
74
78
|
}
|
|
75
79
|
scrollToSchemaComponentByName(componentName) {
|
|
76
80
|
this.dispatchEvent(new CustomEvent('scrollToSchemaComponentByName', {
|
|
@@ -155,24 +159,25 @@ class SchemaTable extends _lit.LitElement {
|
|
|
155
159
|
} else {
|
|
156
160
|
recursiveResult = Object.keys(data).filter(dataKey => {
|
|
157
161
|
var _data$dataKey;
|
|
158
|
-
return !['::metadata', '::title', '::description', '::type', '::link', '::props', '::deprecated', '::array-type', '::dataTypeLabel', '::flags'].includes(dataKey) || ((_data$dataKey = data[dataKey]) === null || _data$dataKey === void 0 ? void 0 : _data$dataKey['::type']) && !data[dataKey]['::type'].includes('xxx-of');
|
|
162
|
+
return !['::metadata', '::title', '::description', '::type', '::link', '::circular', '::props', '::deprecated', '::array-type', '::dataTypeLabel', '::flags'].includes(dataKey) || ((_data$dataKey = data[dataKey]) === null || _data$dataKey === void 0 ? void 0 : _data$dataKey['::type']) && !data[dataKey]['::type'].includes('xxx-of');
|
|
159
163
|
}).map(dataKey => {
|
|
160
164
|
const {
|
|
161
165
|
result: innerResult,
|
|
162
|
-
keyLabelMaxCharacterLength:
|
|
166
|
+
keyLabelMaxCharacterLength: innerObjectLevelIndentationLevel,
|
|
163
167
|
typeMaxCharacterLength: innerObjectLevelTypeMaxCharacterLength
|
|
164
168
|
} = this.generateTree(data[dataKey]['::type'] === 'array' ? data[dataKey]['::props'] : data[dataKey], data[dataKey]['::type'], dataKey, data[dataKey]['::title'], data[dataKey]['::description'], newSchemaLevel, newIndentLevel) || {};
|
|
165
|
-
innerMaxIndentationLevel = Math.max(innerMaxIndentationLevel,
|
|
169
|
+
innerMaxIndentationLevel = Math.max(innerMaxIndentationLevel, innerObjectLevelIndentationLevel);
|
|
166
170
|
innerTypeMaxCharacterLength = Math.max(innerTypeMaxCharacterLength, innerObjectLevelTypeMaxCharacterLength);
|
|
167
171
|
return innerResult;
|
|
168
172
|
});
|
|
169
173
|
}
|
|
170
|
-
const displayLine = [title && `**${title}${description ? ':' : ''}**`, description].filter(v => v).join(' ');
|
|
171
|
-
const
|
|
174
|
+
const displayLine = [title && !data['::link'] && `**${title}${description ? ':' : ''}**`, description].filter(v => v).join(' ');
|
|
175
|
+
const detailObjTypeDisplay = data['::circular'] ? `{ Recursive: ${detailObjType} }` : detailObjType;
|
|
176
|
+
const outerResult = (0, _lit.html)` ${newSchemaLevel >= 0 && key ? (0, _lit.html)` <div class="tr ${newSchemaLevel <= this.schemaExpandLevel ? '' : 'collapsed'} ${data['::circular'] ? 'circular-object' : 'object'} ${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)}"> <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="key-label xxx-of-key">${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" title="Required"> ${keyLabel.substring(0, keyLabel.length - 1)}</span>` : (0, _lit.html)`<span class="key-label" style="display:inline-block">${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(--secondary-color)">${detailObjTypeDisplay}</span>${dataType === 'array' ? ']' : ''} </div>` : (0, _lit.html)`<div>${(data['::type'] || '').includes('xxx-of') ? '' : `${dataType === 'array' ? '[' : ''}${detailObjTypeDisplay}${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, _commonUtils.toMarkdown)(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
177
|
return {
|
|
173
178
|
result: outerResult,
|
|
174
179
|
keyLabelMaxCharacterLength: Math.max(innerMaxIndentationLevel, (keyLabel || keyDescr).length),
|
|
175
|
-
typeMaxCharacterLength: Math.max(innerTypeMaxCharacterLength,
|
|
180
|
+
typeMaxCharacterLength: Math.max(innerTypeMaxCharacterLength, detailObjTypeDisplay.length)
|
|
176
181
|
};
|
|
177
182
|
}
|
|
178
183
|
|