rapidoc 9.3.3 โ 9.3.4
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/.github/workflow/words.yaml +22 -0
- package/dist/rapidoc-min.js +815 -709
- package/dist/rapidoc-min.js.LICENSE.txt +8 -7
- package/dist/rapidoc-min.js.LICENSE.txt.gz +0 -0
- package/dist/rapidoc-min.js.gz +0 -0
- package/dist/rapidoc-min.js.map +1 -1
- package/dist/rapidoc-min.js.map.gz +0 -0
- package/dist/rapidoc.js +17680 -31489
- package/dist/report.html +5 -4
- package/package.json +18 -18
- package/src/components/api-request.js +218 -112
- package/src/components/api-response.js +11 -10
- package/src/components/json-tree.js +17 -12
- package/src/components/schema-table.js +47 -39
- package/src/components/schema-tree.js +55 -52
- package/src/components/tag-input.js +7 -4
- package/src/json-schema-viewer.js +1 -1
- package/src/rapidoc-mini.js +1 -1
- package/src/rapidoc.js +98 -30
- package/src/styles/endpoint-styles.js +1 -1
- package/src/styles/info-styles.js +2 -1
- package/src/styles/input-styles.js +2 -16
- package/src/styles/nav-styles.js +57 -10
- package/src/styles/schema-styles.js +27 -15
- package/src/styles/tab-styles.js +1 -0
- package/src/templates/callback-template.js +3 -3
- package/src/templates/code-samples-template.js +1 -0
- package/src/templates/components-template.js +3 -5
- package/src/templates/endpoint-template.js +38 -25
- package/src/templates/expanded-endpoint-template.js +57 -8
- package/src/templates/focused-endpoint-template.js +4 -1
- package/src/templates/header-template.js +2 -2
- package/src/templates/json-schema-viewer-template.js +2 -1
- package/src/templates/main-body-template.js +19 -18
- package/src/templates/navbar-template.js +98 -81
- package/src/templates/overview-template.js +1 -1
- package/src/templates/security-scheme-template.js +48 -25
- package/src/templates/server-template.js +1 -1
- package/src/utils/common-utils.js +1 -1
- package/src/utils/schema-utils.js +161 -63
- package/src/utils/spec-parser.js +1 -0
- package/src/utils/theme.js +9 -3
- package/webpack.config.js +2 -1
|
@@ -9,6 +9,7 @@ import InputStyles from '~/styles/input-styles';
|
|
|
9
9
|
import TabStyles from '~/styles/tab-styles';
|
|
10
10
|
import BorderStyles from '~/styles/border-styles';
|
|
11
11
|
import CustomStyles from '~/styles/custom-styles';
|
|
12
|
+
import '~/components/json-tree';
|
|
12
13
|
import '~/components/schema-tree';
|
|
13
14
|
import '~/components/schema-table';
|
|
14
15
|
|
|
@@ -49,6 +50,8 @@ export default class ApiResponse extends LitElement {
|
|
|
49
50
|
InputStyles,
|
|
50
51
|
BorderStyles,
|
|
51
52
|
css`
|
|
53
|
+
:where(button, input[type="checkbox"], [tabindex="0"]):focus-visible { box-shadow: var(--focus-shadow); }
|
|
54
|
+
:where(input[type="text"], input[type="password"], select, textarea):focus-visible { border-color: var(--primary-color); }
|
|
52
55
|
.resp-head{
|
|
53
56
|
vertical-align: middle;
|
|
54
57
|
padding:16px 0 8px;
|
|
@@ -207,20 +210,20 @@ export default class ApiResponse extends LitElement {
|
|
|
207
210
|
responseHeaderListTemplate(respHeaders) {
|
|
208
211
|
return html`
|
|
209
212
|
<div style="padding:16px 0 8px 0" class="resp-headers small-font-size bold-text">RESPONSE HEADERS</div>
|
|
210
|
-
<table style="border-collapse: collapse; margin-bottom:16px; border:1px solid var(--border-color); border-radius: var(--border-radius)" class="small-font-size mono-font">
|
|
213
|
+
<table role="presentation" style="border-collapse: collapse; margin-bottom:16px; border:1px solid var(--border-color); border-radius: var(--border-radius)" class="small-font-size mono-font">
|
|
211
214
|
${respHeaders.map((v) => html`
|
|
212
215
|
<tr>
|
|
213
216
|
<td style="padding:8px; vertical-align: baseline; min-width:120px; border-top: 1px solid var(--light-border-color); text-overflow: ellipsis;">
|
|
214
217
|
${v.name || ''}
|
|
215
218
|
</td>
|
|
216
219
|
<td style="padding:4px; vertical-align: baseline; padding:0 5px; border-top: 1px solid var(--light-border-color); text-overflow: ellipsis;">
|
|
217
|
-
${v.schema
|
|
220
|
+
${v.schema?.type || ''}
|
|
218
221
|
</td>
|
|
219
222
|
<td style="padding:8px; vertical-align: baseline; border-top: 1px solid var(--light-border-color);text-overflow: ellipsis;">
|
|
220
223
|
<div class="m-markdown-small regular-font" >${unsafeHTML(marked(v.description || ''))}</div>
|
|
221
224
|
</td>
|
|
222
225
|
<td style="padding:8px; vertical-align: baseline; border-top: 1px solid var(--light-border-color); text-overflow: ellipsis;">
|
|
223
|
-
${v.schema
|
|
226
|
+
${v.schema?.example || ''}
|
|
224
227
|
</td>
|
|
225
228
|
</tr>
|
|
226
229
|
`)}
|
|
@@ -229,7 +232,7 @@ export default class ApiResponse extends LitElement {
|
|
|
229
232
|
|
|
230
233
|
mimeTypeDropdownTemplate(mimeTypes) {
|
|
231
234
|
return html`
|
|
232
|
-
<select @change="${(e) => { this.selectedMimeType = e.target.value; }}" style='margin-bottom: -1px; z-index:1'>
|
|
235
|
+
<select aria-label='mime types' @change="${(e) => { this.selectedMimeType = e.target.value; }}" style='margin-bottom: -1px; z-index:1'>
|
|
233
236
|
${mimeTypes.map((mimeType) => html`<option value='${mimeType}' ?selected = '${mimeType === this.selectedMimeType}'> ${mimeType} </option>`)}
|
|
234
237
|
</select>`;
|
|
235
238
|
}
|
|
@@ -270,7 +273,7 @@ export default class ApiResponse extends LitElement {
|
|
|
270
273
|
}`
|
|
271
274
|
: html`
|
|
272
275
|
<span class = 'example-panel ${this.renderStyle === 'read' ? 'border pad-8-16' : 'border-top pad-top-8'}'>
|
|
273
|
-
<select style="min-width:100px; max-width:100%" @change='${(e) => this.onSelectExample(e)}'>
|
|
276
|
+
<select aria-label='response examples' style="min-width:100px; max-width:100%" @change='${(e) => this.onSelectExample(e)}'>
|
|
274
277
|
${mimeRespDetails.examples.map((v) => html`<option value="${v.exampleId}" ?selected=${v.exampleId === mimeRespDetails.selectedExample} >
|
|
275
278
|
${v.exampleSummary.length > 80 ? v.exampleId : v.exampleSummary}
|
|
276
279
|
</option>`)}
|
|
@@ -306,22 +309,20 @@ export default class ApiResponse extends LitElement {
|
|
|
306
309
|
${this.schemaStyle === 'table'
|
|
307
310
|
? html`
|
|
308
311
|
<schema-table
|
|
309
|
-
render-style = "${this.renderStyle}"
|
|
310
312
|
.data = "${mimeRespDetails.schemaTree}"
|
|
311
313
|
schema-expand-level = "${this.schemaExpandLevel}"
|
|
312
314
|
schema-description-expanded = "${this.schemaDescriptionExpanded}"
|
|
313
|
-
allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}"
|
|
315
|
+
allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}"
|
|
314
316
|
schema-hide-read-only = "${this.schemaHideReadOnly}"
|
|
315
317
|
schema-hide-write-only = "${this.schemaHideWriteOnly}"
|
|
316
318
|
exportparts = "schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
|
|
317
|
-
> </schema-
|
|
319
|
+
> </schema-table> `
|
|
318
320
|
: html`
|
|
319
321
|
<schema-tree
|
|
320
|
-
render-style = "${this.renderStyle}"
|
|
321
322
|
.data = '${mimeRespDetails.schemaTree}'
|
|
322
323
|
schema-expand-level = "${this.schemaExpandLevel}"
|
|
323
324
|
schema-description-expanded = "${this.schemaDescriptionExpanded}"
|
|
324
|
-
allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}"
|
|
325
|
+
allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}"
|
|
325
326
|
schema-hide-read-only = "${this.schemaHideReadOnly}"
|
|
326
327
|
schema-hide-write-only = "${this.schemaHideWriteOnly}"
|
|
327
328
|
exportparts = "schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
|
|
@@ -22,6 +22,8 @@ export default class JsonTree extends LitElement {
|
|
|
22
22
|
:host{
|
|
23
23
|
display:flex;
|
|
24
24
|
}
|
|
25
|
+
:where(button, input[type="checkbox"], [tabindex="0"]):focus-visible { box-shadow: var(--focus-shadow); }
|
|
26
|
+
:where(input[type="text"], input[type="password"], select, textarea):focus-visible { border-color: var(--primary-color); }
|
|
25
27
|
.json-tree {
|
|
26
28
|
position: relative;
|
|
27
29
|
font-family: var(--font-mono);
|
|
@@ -31,6 +33,7 @@ export default class JsonTree extends LitElement {
|
|
|
31
33
|
word-break: break-all;
|
|
32
34
|
flex:1;
|
|
33
35
|
line-height: calc(var(--font-size-small) + 6px);
|
|
36
|
+
min-height: 40px;
|
|
34
37
|
direction: ltr;
|
|
35
38
|
text-align: left;
|
|
36
39
|
}
|
|
@@ -58,8 +61,9 @@ export default class JsonTree extends LitElement {
|
|
|
58
61
|
.open-bracket.expanded:hover ~ .close-bracket {
|
|
59
62
|
color:var(--primary-color);
|
|
60
63
|
}
|
|
61
|
-
.inside-bracket{
|
|
64
|
+
.inside-bracket {
|
|
62
65
|
padding-left:12px;
|
|
66
|
+
overflow: hidden;
|
|
63
67
|
border-left:1px dotted var(--border-color);
|
|
64
68
|
}
|
|
65
69
|
.open-bracket.collapsed + .inside-bracket,
|
|
@@ -87,11 +91,11 @@ export default class JsonTree extends LitElement {
|
|
|
87
91
|
/* eslint-disable indent */
|
|
88
92
|
render() {
|
|
89
93
|
return html`
|
|
90
|
-
<div class = "json-tree" >
|
|
94
|
+
<div class = "json-tree" @click='${(e) => { if (e.target.classList.contains('btn-copy')) { copyToClipboard(JSON.stringify(this.data, null, 2), e); } else { this.toggleExpand(e); } }}'>
|
|
91
95
|
<div class='toolbar'>
|
|
92
|
-
<button class="toolbar-btn" part="btn btn-fill btn-copy"
|
|
96
|
+
<button class="toolbar-btn btn-copy" part="btn btn-fill btn-copy"> Copy </button>
|
|
93
97
|
</div>
|
|
94
|
-
|
|
98
|
+
${this.generateTree(this.data, true)}
|
|
95
99
|
</div>
|
|
96
100
|
`;
|
|
97
101
|
}
|
|
@@ -106,7 +110,7 @@ export default class JsonTree extends LitElement {
|
|
|
106
110
|
return html`${(Array.isArray(data) ? '[ ],' : '{ },')}`;
|
|
107
111
|
}
|
|
108
112
|
return html`
|
|
109
|
-
<div class="open-bracket expanded ${detailType === 'array' ? 'array' : 'object'}
|
|
113
|
+
<div class="open-bracket expanded ${detailType === 'array' ? 'array' : 'object'}" > ${detailType === 'array' ? '[' : '{'}</div>
|
|
110
114
|
<div class="inside-bracket">
|
|
111
115
|
${Object.keys(data).map((key, i, a) => html`
|
|
112
116
|
<div class="item">
|
|
@@ -118,7 +122,6 @@ export default class JsonTree extends LitElement {
|
|
|
118
122
|
<div class="close-bracket">${detailType === 'array' ? ']' : '}'}${isLast ? '' : ','}</div>
|
|
119
123
|
`;
|
|
120
124
|
}
|
|
121
|
-
|
|
122
125
|
return (typeof data === 'string' || data instanceof Date)
|
|
123
126
|
? html`<span class="${typeof data}">"${data}"</span>${isLast ? '' : ','}`
|
|
124
127
|
: html`<span class="${typeof data}">${data}</span>${isLast ? '' : ','}`;
|
|
@@ -127,12 +130,14 @@ export default class JsonTree extends LitElement {
|
|
|
127
130
|
|
|
128
131
|
toggleExpand(e) {
|
|
129
132
|
const openBracketEl = e.target;
|
|
130
|
-
if (
|
|
131
|
-
openBracketEl.classList.
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
133
|
+
if (e.target.classList.contains('open-bracket')) {
|
|
134
|
+
if (openBracketEl.classList.contains('expanded')) {
|
|
135
|
+
openBracketEl.classList.replace('expanded', 'collapsed');
|
|
136
|
+
e.target.innerHTML = e.target.classList.contains('array') ? '[...]' : '{...}';
|
|
137
|
+
} else {
|
|
138
|
+
openBracketEl.classList.replace('collapsed', 'expanded');
|
|
139
|
+
e.target.innerHTML = e.target.classList.contains('array') ? '[' : '{';
|
|
140
|
+
}
|
|
136
141
|
}
|
|
137
142
|
}
|
|
138
143
|
}
|
|
@@ -46,6 +46,9 @@ export default class SchemaTable extends LitElement {
|
|
|
46
46
|
.table .key {
|
|
47
47
|
width: 240px;
|
|
48
48
|
}
|
|
49
|
+
.key .key-label {
|
|
50
|
+
font-size: var(--font-size-mono);
|
|
51
|
+
}
|
|
49
52
|
.key.deprecated .key-label {
|
|
50
53
|
color: var(--red);
|
|
51
54
|
}
|
|
@@ -54,8 +57,8 @@ export default class SchemaTable extends LitElement {
|
|
|
54
57
|
white-space: normal;
|
|
55
58
|
width: 150px;
|
|
56
59
|
}
|
|
57
|
-
.collapsed-descr .tr {
|
|
58
|
-
max-height: calc(var(--font-size-small) + var(--font-size-small)
|
|
60
|
+
.collapsed-all-descr .tr:not(.expanded-descr) {
|
|
61
|
+
max-height: calc(var(--font-size-small) + var(--font-size-small));
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
.obj-toggle {
|
|
@@ -86,23 +89,20 @@ export default class SchemaTable extends LitElement {
|
|
|
86
89
|
/* eslint-disable indent */
|
|
87
90
|
render() {
|
|
88
91
|
return html`
|
|
89
|
-
<div class="table ${this.schemaDescriptionExpanded === 'true' ? 'expanded-descr' : 'collapsed-descr'}">
|
|
92
|
+
<div class="table ${this.schemaDescriptionExpanded === 'true' ? 'expanded-all-descr' : 'collapsed-all-descr'}" @click="${(e) => this.handleAllEvents(e)}">
|
|
90
93
|
<div class='toolbar'>
|
|
91
94
|
<div class="toolbar-item schema-root-type ${this.data?.['::type'] || ''} "> ${this.data?.['::type'] || ''} </div>
|
|
92
95
|
${this.allowSchemaDescriptionExpandToggle === 'true'
|
|
93
96
|
? html`
|
|
94
97
|
<div style="flex:1"></div>
|
|
95
|
-
<div part="schema-multiline-toggle" class='toolbar-item
|
|
98
|
+
<div part="schema-multiline-toggle" class='toolbar-item schema-multiline-toggle' >
|
|
96
99
|
${this.schemaDescriptionExpanded === 'true' ? 'Single line description' : 'Multiline description'}
|
|
97
100
|
</div>
|
|
98
101
|
`
|
|
99
102
|
: ''
|
|
100
103
|
}
|
|
101
104
|
</div>
|
|
102
|
-
${this.data?.['::description']
|
|
103
|
-
? html`<span part="schema-description" class='m-markdown'> ${unsafeHTML(marked(this.data['::description'] || ''))}</span>`
|
|
104
|
-
: ''
|
|
105
|
-
}
|
|
105
|
+
<span part="schema-description" class='m-markdown'> ${unsafeHTML(marked(this.data?.['::description'] || ''))} </span>
|
|
106
106
|
<div style = 'border:1px solid var(--light-border-color)'>
|
|
107
107
|
<div style='display:flex; background-color: var(--bg2); padding:8px 4px; border-bottom:1px solid var(--light-border-color);'>
|
|
108
108
|
<div class='key' style='font-family:var(--font-regular); font-weight:bold; color:var(--fg);'> Field </div>
|
|
@@ -202,11 +202,7 @@ export default class SchemaTable extends LitElement {
|
|
|
202
202
|
<div class="td key ${data['::deprecated'] ? 'deprecated' : ''}" style='padding-left:${leftPadding}px'>
|
|
203
203
|
${(keyLabel || keyDescr)
|
|
204
204
|
? html`
|
|
205
|
-
<span
|
|
206
|
-
class='obj-toggle ${newSchemaLevel < this.schemaExpandLevel ? 'expanded' : 'collapsed'}'
|
|
207
|
-
data-obj='${keyLabel}'
|
|
208
|
-
@click= ${(e) => this.toggleObjectExpand(e, keyLabel)}
|
|
209
|
-
>
|
|
205
|
+
<span class='obj-toggle ${newSchemaLevel < this.schemaExpandLevel ? 'expanded' : 'collapsed'}' data-obj='${keyLabel}'>
|
|
210
206
|
${schemaLevel < this.schemaExpandLevel ? '-' : '+'}
|
|
211
207
|
</span>`
|
|
212
208
|
: ''
|
|
@@ -226,18 +222,17 @@ export default class SchemaTable extends LitElement {
|
|
|
226
222
|
<div class='td key-descr m-markdown-small' style='line-height:1.7'>${unsafeHTML(marked(description || ''))}</div>
|
|
227
223
|
</div>`
|
|
228
224
|
: html`
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
`
|
|
225
|
+
${data['::type'] === 'array' && dataType === 'array'
|
|
226
|
+
? html`
|
|
227
|
+
<div class='tr'>
|
|
228
|
+
<div class='td key'></div>
|
|
229
|
+
<div class='td key-type'>
|
|
230
|
+
${arrayType && arrayType !== 'object' ? `${dataType} of ${arrayType}` : dataType}
|
|
231
|
+
</div>
|
|
232
|
+
<div class='td key-descr'></div>
|
|
233
|
+
</div>`
|
|
234
|
+
: ''
|
|
235
|
+
}`
|
|
241
236
|
}
|
|
242
237
|
<div class='object-body'>
|
|
243
238
|
${Array.isArray(data) && data[0]
|
|
@@ -262,7 +257,7 @@ export default class SchemaTable extends LitElement {
|
|
|
262
257
|
data[dataKey]['::type'],
|
|
263
258
|
data[dataKey]['::array-type'] || '',
|
|
264
259
|
dataKey,
|
|
265
|
-
data[dataKey]['::description'],
|
|
260
|
+
data[dataKey]?.['::description'] || '',
|
|
266
261
|
newSchemaLevel,
|
|
267
262
|
newIndentLevel,
|
|
268
263
|
data[dataKey]['::readwrite'] ? data[dataKey]['::readwrite'] : '',
|
|
@@ -276,6 +271,7 @@ export default class SchemaTable extends LitElement {
|
|
|
276
271
|
}
|
|
277
272
|
|
|
278
273
|
// For Primitive Data types
|
|
274
|
+
// eslint-disable-next-line no-unused-vars
|
|
279
275
|
const [type, readOrWriteOnly, constraint, defaultValue, allowedValues, pattern, schemaDescription, schemaTitle, deprecated] = data.split('~|~');
|
|
280
276
|
if (readOrWriteOnly === '๐' && this.schemaHideReadOnly === 'true') {
|
|
281
277
|
return;
|
|
@@ -284,6 +280,7 @@ export default class SchemaTable extends LitElement {
|
|
|
284
280
|
return;
|
|
285
281
|
}
|
|
286
282
|
const dataTypeCss = type.replace(/โ.*/g, '').replace(/[^a-zA-Z0-9+]/g, '').substring(0, 4).toLowerCase();
|
|
283
|
+
const descrExpander = `${constraint || defaultValue || allowedValues || pattern ? '<span class="descr-expand-toggle">โ</span>' : ''}`;
|
|
287
284
|
let dataTypeHtml = '';
|
|
288
285
|
if (dataType === 'array') {
|
|
289
286
|
dataTypeHtml = html`
|
|
@@ -310,21 +307,18 @@ export default class SchemaTable extends LitElement {
|
|
|
310
307
|
}
|
|
311
308
|
</div>
|
|
312
309
|
${dataTypeHtml}
|
|
313
|
-
<div class='td key-descr'
|
|
314
|
-
${
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
? html`<span class="more-content">โคต</span>`
|
|
322
|
-
: ''}`
|
|
323
|
-
: ''
|
|
310
|
+
<div class='td key-descr' style='font-size: var(--font-size-small)'>
|
|
311
|
+
${html`<span class="m-markdown-small">
|
|
312
|
+
${unsafeHTML(marked(dataType === 'array'
|
|
313
|
+
? `${descrExpander} ${description}`
|
|
314
|
+
: schemaTitle
|
|
315
|
+
? `${descrExpander} <b>${schemaTitle}:</b> ${schemaDescription}`
|
|
316
|
+
: `${descrExpander} ${schemaDescription}`))}
|
|
317
|
+
</span>`
|
|
324
318
|
}
|
|
325
|
-
${constraint ? html`<div style='display:inline-block; line-break:anywhere; margin-right:8px;'> <span class='bold-text'>Constraints: </span> ${constraint}</div>` : ''}
|
|
319
|
+
${constraint ? html`<div class='' style='display:inline-block; line-break:anywhere; margin-right:8px;'> <span class='bold-text'>Constraints: </span> ${constraint}</div>` : ''}
|
|
326
320
|
${defaultValue ? html`<div style='display:inline-block; line-break:anywhere; margin-right:8px;'> <span class='bold-text'>Default: </span>${defaultValue}</div>` : ''}
|
|
327
|
-
${allowedValues ? html`<div style='display:inline-block; line-break:anywhere; margin-right:8px;'> <span class='bold-text'
|
|
321
|
+
${allowedValues ? html`<div style='display:inline-block; line-break:anywhere; margin-right:8px;'> <span class='bold-text'>${type === 'const' ? 'Value' : 'Allowed'}: </span>${allowedValues}</div>` : ''}
|
|
328
322
|
${pattern ? html`<div style='display:inline-block; line-break:anywhere; margin-right:8px;'> <span class='bold-text'>Pattern: </span>${pattern}</div>` : ''}
|
|
329
323
|
</div>
|
|
330
324
|
</div>
|
|
@@ -332,6 +326,20 @@ export default class SchemaTable extends LitElement {
|
|
|
332
326
|
}
|
|
333
327
|
/* eslint-enable indent */
|
|
334
328
|
|
|
329
|
+
handleAllEvents(e) {
|
|
330
|
+
if (e.target.classList.contains('obj-toggle')) {
|
|
331
|
+
this.toggleObjectExpand(e);
|
|
332
|
+
} else if (e.target.classList.contains('schema-multiline-toggle')) {
|
|
333
|
+
this.schemaDescriptionExpanded = (this.schemaDescriptionExpanded === 'true' ? 'false' : 'true');
|
|
334
|
+
} else if (e.target.classList.contains('descr-expand-toggle')) {
|
|
335
|
+
const trEl = e.target.closest('.tr');
|
|
336
|
+
if (trEl) {
|
|
337
|
+
trEl.classList.toggle('expanded-descr');
|
|
338
|
+
trEl.style.maxHeight = trEl.scrollHeight;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
335
343
|
toggleObjectExpand(e) {
|
|
336
344
|
const rowEl = e.target.closest('.tr');
|
|
337
345
|
if (rowEl.classList.contains('expanded')) {
|
|
@@ -41,13 +41,10 @@ export default class SchemaTree extends LitElement {
|
|
|
41
41
|
.tree .tr:hover{
|
|
42
42
|
background-color:var(--hover-color);
|
|
43
43
|
}
|
|
44
|
-
.collapsed-descr .tr {
|
|
44
|
+
.collapsed-all-descr .tr:not(.expanded-descr) {
|
|
45
|
+
overflow: hidden;
|
|
45
46
|
max-height:calc(var(--font-size-small) + 8px);
|
|
46
47
|
}
|
|
47
|
-
.collapsed-descr .m-markdown-small p {
|
|
48
|
-
line-height:calc(var(--font-size-small) + 6px);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
48
|
.tree .key {
|
|
52
49
|
max-width: 300px;
|
|
53
50
|
}
|
|
@@ -63,7 +60,9 @@ export default class SchemaTree extends LitElement {
|
|
|
63
60
|
.tr.expanded:hover + .inside-bracket + .close-bracket {
|
|
64
61
|
color: var(--primary-color);
|
|
65
62
|
}
|
|
66
|
-
|
|
63
|
+
.inside-bracket.xxx-of-option {
|
|
64
|
+
border-left: 1px solid transparent;
|
|
65
|
+
}
|
|
67
66
|
.open-bracket{
|
|
68
67
|
display:inline-block;
|
|
69
68
|
padding: 0 20px 0 0;
|
|
@@ -82,17 +81,12 @@ export default class SchemaTree extends LitElement {
|
|
|
82
81
|
}
|
|
83
82
|
.tr.collapsed + .inside-bracket,
|
|
84
83
|
.tr.collapsed + .inside-bracket + .close-bracket{
|
|
84
|
+
overflow: hidden;
|
|
85
85
|
display:none;
|
|
86
86
|
}
|
|
87
87
|
.inside-bracket.object,
|
|
88
88
|
.inside-bracket.array {
|
|
89
89
|
border-left: 1px dotted var(--border-color);
|
|
90
|
-
}
|
|
91
|
-
.inside-bracket.xxx-of {
|
|
92
|
-
padding:5px 0px;
|
|
93
|
-
border-style: dotted;
|
|
94
|
-
border-width: 0 0 1px 0;
|
|
95
|
-
border-color:var(--primary-color);
|
|
96
90
|
}`,
|
|
97
91
|
CustomStyles,
|
|
98
92
|
];
|
|
@@ -101,23 +95,19 @@ export default class SchemaTree extends LitElement {
|
|
|
101
95
|
/* eslint-disable indent */
|
|
102
96
|
render() {
|
|
103
97
|
return html`
|
|
104
|
-
<div class="tree ${this.schemaDescriptionExpanded === 'true' ? 'expanded-descr' : 'collapsed-descr'}">
|
|
98
|
+
<div class="tree ${this.schemaDescriptionExpanded === 'true' ? 'expanded-all-descr' : 'collapsed-all-descr'}" @click="${(e) => this.handleAllEvents(e)}">
|
|
105
99
|
<div class="toolbar">
|
|
106
100
|
<div class="toolbar-item schema-root-type ${this.data?.['::type'] || ''} "> ${this.data?.['::type'] || ''} </div>
|
|
107
101
|
${this.allowSchemaDescriptionExpandToggle === 'true'
|
|
108
102
|
? html`
|
|
109
103
|
<div style="flex:1"></div>
|
|
110
|
-
<div part="schema-toolbar-item schema-multiline-toggle" class='toolbar-item
|
|
104
|
+
<div part="schema-toolbar-item schema-multiline-toggle" class='toolbar-item schema-multiline-toggle'>
|
|
111
105
|
${this.schemaDescriptionExpanded === 'true' ? 'Single line description' : 'Multiline description'}
|
|
112
|
-
</div
|
|
113
|
-
`
|
|
106
|
+
</div>`
|
|
114
107
|
: ''
|
|
115
108
|
}
|
|
116
109
|
</div>
|
|
117
|
-
${this.data?.['::description']
|
|
118
|
-
? html`<span part="schema-description" class='m-markdown'> ${unsafeHTML(marked(this.data['::description'] || ''))}</span>`
|
|
119
|
-
: ''
|
|
120
|
-
}
|
|
110
|
+
<span part="schema-description" class='m-markdown'> ${unsafeHTML(marked(this.data?.['::description'] || ''))}</span>
|
|
121
111
|
${this.data
|
|
122
112
|
? html`
|
|
123
113
|
${this.generateTree(
|
|
@@ -138,7 +128,7 @@ export default class SchemaTree extends LitElement {
|
|
|
138
128
|
return;
|
|
139
129
|
}
|
|
140
130
|
}
|
|
141
|
-
if (data
|
|
131
|
+
if (data?.['::readwrite'] === 'readonly') {
|
|
142
132
|
return;
|
|
143
133
|
}
|
|
144
134
|
}
|
|
@@ -148,7 +138,7 @@ export default class SchemaTree extends LitElement {
|
|
|
148
138
|
return;
|
|
149
139
|
}
|
|
150
140
|
}
|
|
151
|
-
if (data
|
|
141
|
+
if (data?.['::readwrite'] === 'writeonly') {
|
|
152
142
|
return;
|
|
153
143
|
}
|
|
154
144
|
}
|
|
@@ -174,8 +164,7 @@ export default class SchemaTree extends LitElement {
|
|
|
174
164
|
keyLabel = key.replace('::', '').replace('~', ' ');
|
|
175
165
|
} else if (key.startsWith('::OPTION')) {
|
|
176
166
|
const parts = key.split('~');
|
|
177
|
-
keyLabel = parts
|
|
178
|
-
keyDescr = parts[2]; // eslint-disable-line prefer-destructuring
|
|
167
|
+
[, keyLabel, keyDescr] = parts;
|
|
179
168
|
} else {
|
|
180
169
|
keyLabel = key;
|
|
181
170
|
}
|
|
@@ -190,16 +179,16 @@ export default class SchemaTree extends LitElement {
|
|
|
190
179
|
if (data['::type'] === 'object') {
|
|
191
180
|
if (dataType === 'array') {
|
|
192
181
|
if (schemaLevel < this.schemaExpandLevel) {
|
|
193
|
-
openBracket = html`<span class="open-bracket array-of-object"
|
|
182
|
+
openBracket = html`<span class="open-bracket array-of-object" >[{</span>`;
|
|
194
183
|
} else {
|
|
195
|
-
openBracket = html`<span class="open-bracket array-of-object"
|
|
184
|
+
openBracket = html`<span class="open-bracket array-of-object">[{...}]</span>`;
|
|
196
185
|
}
|
|
197
186
|
closeBracket = '}]';
|
|
198
187
|
} else {
|
|
199
188
|
if (schemaLevel < this.schemaExpandLevel) {
|
|
200
|
-
openBracket = html`<span class="open-bracket object"
|
|
189
|
+
openBracket = html`<span class="open-bracket object">{</span>`;
|
|
201
190
|
} else {
|
|
202
|
-
openBracket = html`<span class="open-bracket object"
|
|
191
|
+
openBracket = html`<span class="open-bracket object">{...}</span>`;
|
|
203
192
|
}
|
|
204
193
|
closeBracket = '}';
|
|
205
194
|
}
|
|
@@ -207,16 +196,16 @@ export default class SchemaTree extends LitElement {
|
|
|
207
196
|
if (dataType === 'array') {
|
|
208
197
|
const arrType = arrayType !== 'object' ? arrayType : '';
|
|
209
198
|
if (schemaLevel < this.schemaExpandLevel) {
|
|
210
|
-
openBracket = html`<span class="open-bracket array-of-array" data-array-type="${arrType}"
|
|
199
|
+
openBracket = html`<span class="open-bracket array-of-array" data-array-type="${arrType}">[[ ${arrType} </span>`;
|
|
211
200
|
} else {
|
|
212
|
-
openBracket = html`<span class="open-bracket array-of-array" data-array-type="${arrType}"
|
|
201
|
+
openBracket = html`<span class="open-bracket array-of-array" data-array-type="${arrType}">[[...]]</span>`;
|
|
213
202
|
}
|
|
214
203
|
closeBracket = ']]';
|
|
215
204
|
} else {
|
|
216
205
|
if (schemaLevel < this.schemaExpandLevel) {
|
|
217
|
-
openBracket = html`<span class="open-bracket array"
|
|
206
|
+
openBracket = html`<span class="open-bracket array">[</span>`;
|
|
218
207
|
} else {
|
|
219
|
-
openBracket = html`<span class="open-bracket array"
|
|
208
|
+
openBracket = html`<span class="open-bracket array">[...]</span>`;
|
|
220
209
|
}
|
|
221
210
|
closeBracket = ']';
|
|
222
211
|
}
|
|
@@ -236,7 +225,6 @@ export default class SchemaTree extends LitElement {
|
|
|
236
225
|
</span>`
|
|
237
226
|
: ''
|
|
238
227
|
}
|
|
239
|
-
${data['::type'] === 'xxx-of' && dataType === 'array' ? html`<span style="color:var(--primary-color)">ARRAY</span>` : ''}
|
|
240
228
|
${openBracket}
|
|
241
229
|
</div>
|
|
242
230
|
<div class='td key-descr m-markdown-small'>${unsafeHTML(marked(description || ''))}</div>
|
|
@@ -264,7 +252,7 @@ export default class SchemaTree extends LitElement {
|
|
|
264
252
|
data[dataKey]['::type'],
|
|
265
253
|
data[dataKey]['::array-type'] || '',
|
|
266
254
|
dataKey,
|
|
267
|
-
data[dataKey]['::description'],
|
|
255
|
+
data[dataKey]?.['::description'] || '',
|
|
268
256
|
newSchemaLevel,
|
|
269
257
|
newIndentLevel,
|
|
270
258
|
data[dataKey]['::readwrite'] ? data[dataKey]['::readwrite'] : '',
|
|
@@ -282,6 +270,7 @@ export default class SchemaTree extends LitElement {
|
|
|
282
270
|
}
|
|
283
271
|
|
|
284
272
|
// For Primitive types and array of Primitives
|
|
273
|
+
// eslint-disable-next-line no-unused-vars
|
|
285
274
|
const [type, primitiveReadOrWrite, constraint, defaultValue, allowedValues, pattern, schemaDescription, schemaTitle, deprecated] = data.split('~|~');
|
|
286
275
|
if (primitiveReadOrWrite === '๐' && this.schemaHideReadOnly === 'true') {
|
|
287
276
|
return;
|
|
@@ -290,7 +279,7 @@ export default class SchemaTree extends LitElement {
|
|
|
290
279
|
return;
|
|
291
280
|
}
|
|
292
281
|
const dataTypeCss = type.replace(/โ.*/g, '').replace(/[^a-zA-Z0-9+]/g, '').substring(0, 4).toLowerCase();
|
|
293
|
-
|
|
282
|
+
const descrExpander = `${constraint || defaultValue || allowedValues || pattern ? `<span class="descr-expand-toggle ${this.schemaDescriptionExpanded === 'true' ? 'expanded-descr' : ''}">โ</span>` : ''}`;
|
|
294
283
|
let finalReadWriteText = '';
|
|
295
284
|
let finalReadWriteTip = '';
|
|
296
285
|
if (dataType === 'array') {
|
|
@@ -302,12 +291,12 @@ export default class SchemaTree extends LitElement {
|
|
|
302
291
|
finalReadWriteTip = 'Write-Only';
|
|
303
292
|
}
|
|
304
293
|
} else if (primitiveReadOrWrite === '๐') {
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
294
|
+
finalReadWriteText = '๐';
|
|
295
|
+
finalReadWriteTip = 'Read-Only';
|
|
296
|
+
} else if (primitiveReadOrWrite === '๐') {
|
|
297
|
+
finalReadWriteText = '๐';
|
|
298
|
+
finalReadWriteTip = 'Write-Only';
|
|
299
|
+
}
|
|
311
300
|
|
|
312
301
|
return html`
|
|
313
302
|
<div class = "tr primitive" title="${deprecated ? 'Deprecated' : ''}">
|
|
@@ -325,20 +314,20 @@ export default class SchemaTree extends LitElement {
|
|
|
325
314
|
</span>
|
|
326
315
|
</div>
|
|
327
316
|
<div class='td key-descr'>
|
|
328
|
-
${
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
317
|
+
${description || schemaTitle || schemaDescription
|
|
318
|
+
? html`${html`<span class="m-markdown-small">
|
|
319
|
+
${unsafeHTML(marked(dataType === 'array'
|
|
320
|
+
? `${descrExpander} ${description}`
|
|
321
|
+
: schemaTitle
|
|
322
|
+
? `${descrExpander} <b>${schemaTitle}:</b> ${schemaDescription}`
|
|
323
|
+
: `${descrExpander} ${schemaDescription}`))}
|
|
332
324
|
</span>`
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
: ''}`
|
|
337
|
-
: ''
|
|
338
|
-
}
|
|
325
|
+
}`
|
|
326
|
+
: ''
|
|
327
|
+
}
|
|
339
328
|
${constraint ? html`<div style='display:inline-block; line-break:anywhere; margin-right:8px'><span class='bold-text'>Constraints: </span>${constraint}</div>` : ''}
|
|
340
329
|
${defaultValue ? html`<div style='display:inline-block; line-break:anywhere; margin-right:8px'><span class='bold-text'>Default: </span>${defaultValue}</div>` : ''}
|
|
341
|
-
${allowedValues ? html`<div style='display:inline-block; line-break:anywhere; margin-right:8px'><span class='bold-text'
|
|
330
|
+
${allowedValues ? html`<div style='display:inline-block; line-break:anywhere; margin-right:8px'><span class='bold-text'>${type === 'const' ? 'Value' : 'Allowed'}: </span>${allowedValues}</div>` : ''}
|
|
342
331
|
${pattern ? html`<div style='display:inline-block; line-break: anywhere; margin-right:8px'><span class='bold-text'>Pattern: </span>${pattern}</div>` : ''}
|
|
343
332
|
</div>
|
|
344
333
|
</div>
|
|
@@ -346,6 +335,20 @@ export default class SchemaTree extends LitElement {
|
|
|
346
335
|
}
|
|
347
336
|
/* eslint-enable indent */
|
|
348
337
|
|
|
338
|
+
handleAllEvents(e) {
|
|
339
|
+
if (e.target.classList.contains('open-bracket')) {
|
|
340
|
+
this.toggleObjectExpand(e);
|
|
341
|
+
} else if (e.target.classList.contains('schema-multiline-toggle')) {
|
|
342
|
+
this.schemaDescriptionExpanded = (this.schemaDescriptionExpanded === 'true' ? 'false' : 'true');
|
|
343
|
+
} else if (e.target.classList.contains('descr-expand-toggle')) {
|
|
344
|
+
const trEl = e.target.closest('.tr');
|
|
345
|
+
if (trEl) {
|
|
346
|
+
trEl.classList.toggle('expanded-descr');
|
|
347
|
+
trEl.style.maxHeight = trEl.scrollHeight;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
349
352
|
toggleObjectExpand(e) {
|
|
350
353
|
const rowEl = e.target.closest('.tr');
|
|
351
354
|
if (rowEl.classList.contains('expanded')) {
|
|
@@ -6,12 +6,12 @@ export default class TagInput extends LitElement {
|
|
|
6
6
|
let tagItemTmpl = '';
|
|
7
7
|
if (Array.isArray(this.value)) {
|
|
8
8
|
tagItemTmpl = html`${this.value
|
|
9
|
-
.filter((v) => v.trim() !== '')
|
|
9
|
+
.filter((v) => typeof v === 'string' && v.trim() !== '')
|
|
10
10
|
.map((v) => html`<span class='tag'>${v}</span>`)
|
|
11
11
|
}`;
|
|
12
12
|
}
|
|
13
13
|
return html`
|
|
14
|
-
<div class='tags'
|
|
14
|
+
<div class='tags'>
|
|
15
15
|
${tagItemTmpl}
|
|
16
16
|
<input type="text" class='editor' @paste="${(e) => this.afterPaste(e)}" @keydown="${this.afterKeyDown}" @blur="${this.onBlur}" placeholder="${this.placeholder || ''}">
|
|
17
17
|
</div>
|
|
@@ -84,7 +84,7 @@ export default class TagInput extends LitElement {
|
|
|
84
84
|
|
|
85
85
|
static get styles() {
|
|
86
86
|
return [css`
|
|
87
|
-
.tags{
|
|
87
|
+
.tags {
|
|
88
88
|
display:flex;
|
|
89
89
|
flex-wrap: wrap;
|
|
90
90
|
outline: none;
|
|
@@ -110,7 +110,7 @@ export default class TagInput extends LitElement {
|
|
|
110
110
|
.tag:hover ~ #cursor {
|
|
111
111
|
display: block;
|
|
112
112
|
}
|
|
113
|
-
.editor{
|
|
113
|
+
.editor {
|
|
114
114
|
flex:1;
|
|
115
115
|
border:1px solid transparent;
|
|
116
116
|
color:var(--fg);
|
|
@@ -121,6 +121,9 @@ export default class TagInput extends LitElement {
|
|
|
121
121
|
background:transparent;
|
|
122
122
|
font-size: calc(var(--font-size-small) + 1px);
|
|
123
123
|
}
|
|
124
|
+
.editor:focus-visible {
|
|
125
|
+
outline: 1px solid;
|
|
126
|
+
}
|
|
124
127
|
.editor::placeholder {
|
|
125
128
|
color: var(--placeholder-color);
|
|
126
129
|
opacity:1;
|
|
@@ -259,7 +259,7 @@ export default class JsonSchemaViewer extends LitElement {
|
|
|
259
259
|
super.attributeChangedCallback(name, oldVal, newVal);
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
-
|
|
262
|
+
onSpecUrlChange() {
|
|
263
263
|
this.setAttribute('spec-url', this.shadowRoot.getElementById('spec-url').value);
|
|
264
264
|
}
|
|
265
265
|
|
package/src/rapidoc-mini.js
CHANGED
|
@@ -264,7 +264,7 @@ export default class RapiDocMini extends LitElement {
|
|
|
264
264
|
super.attributeChangedCallback(name, oldVal, newVal);
|
|
265
265
|
}
|
|
266
266
|
|
|
267
|
-
|
|
267
|
+
onSpecUrlChange() {
|
|
268
268
|
this.setAttribute('spec-url', this.shadowRoot.getElementById('spec-url').value);
|
|
269
269
|
}
|
|
270
270
|
|