rapidoc 9.2.0 → 9.3.3
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/FUNDING.yml +13 -0
- package/CONTRIBUTING.md +1 -1
- package/README.md +13 -6
- package/dist/index.html +1 -1
- package/dist/index.html.gz +0 -0
- package/dist/rapidoc-min.js +472 -353
- package/dist/rapidoc-min.js.LICENSE.txt +9 -11
- 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 +1839 -3420
- package/dist/report.html +2 -2
- package/index.html +6 -5
- package/package.json +22 -20
- package/src/components/api-request.js +184 -85
- package/src/components/api-response.js +8 -4
- package/src/components/json-tree.js +13 -2
- package/src/components/schema-table.js +40 -18
- package/src/components/schema-tree.js +41 -12
- package/src/json-schema-viewer.js +1 -2
- package/src/rapidoc-mini.js +23 -0
- package/src/rapidoc.js +54 -17
- package/src/styles/endpoint-styles.js +9 -9
- package/src/styles/font-styles.js +1 -1
- package/src/styles/nav-styles.js +3 -1
- package/src/styles/schema-styles.js +3 -1
- package/src/styles/tab-styles.js +1 -0
- package/src/templates/callback-template.js +8 -4
- package/src/templates/components-template.js +2 -0
- package/src/templates/endpoint-template.js +20 -15
- package/src/templates/expanded-endpoint-template.js +76 -71
- package/src/templates/header-template.js +1 -1
- package/src/templates/json-schema-viewer-template.js +1 -1
- package/src/templates/main-body-template.js +1 -1
- package/src/templates/navbar-template.js +21 -8
- package/src/templates/overview-template.js +1 -1
- package/src/templates/security-scheme-template.js +30 -20
- package/src/templates/server-template.js +2 -2
- package/src/utils/common-utils.js +1 -4
- package/src/utils/schema-utils.js +96 -57
- package/src/utils/spec-parser.js +1 -1
- package/src/utils/theme.js +13 -6
- package/webpack.config.js +1 -1
- package/.vscode/settings.json +0 -12
|
@@ -47,7 +47,7 @@ export default class SchemaTable extends LitElement {
|
|
|
47
47
|
width: 240px;
|
|
48
48
|
}
|
|
49
49
|
.key.deprecated .key-label {
|
|
50
|
-
|
|
50
|
+
color: var(--red);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
.table .key-type {
|
|
@@ -92,7 +92,7 @@ export default class SchemaTable extends LitElement {
|
|
|
92
92
|
${this.allowSchemaDescriptionExpandToggle === 'true'
|
|
93
93
|
? html`
|
|
94
94
|
<div style="flex:1"></div>
|
|
95
|
-
<div class='toolbar-item' @click='${() => { this.schemaDescriptionExpanded = (this.schemaDescriptionExpanded === 'true' ? 'false' : 'true'); }}'>
|
|
95
|
+
<div part="schema-multiline-toggle" class='toolbar-item' @click='${() => { this.schemaDescriptionExpanded = (this.schemaDescriptionExpanded === 'true' ? 'false' : 'true'); }}'>
|
|
96
96
|
${this.schemaDescriptionExpanded === 'true' ? 'Single line description' : 'Multiline description'}
|
|
97
97
|
</div>
|
|
98
98
|
`
|
|
@@ -100,7 +100,7 @@ export default class SchemaTable extends LitElement {
|
|
|
100
100
|
}
|
|
101
101
|
</div>
|
|
102
102
|
${this.data?.['::description']
|
|
103
|
-
? html`<span class='m-markdown'> ${unsafeHTML(marked(this.data['::description'] || ''))}</span>`
|
|
103
|
+
? html`<span part="schema-description" class='m-markdown'> ${unsafeHTML(marked(this.data['::description'] || ''))}</span>`
|
|
104
104
|
: ''
|
|
105
105
|
}
|
|
106
106
|
<div style = 'border:1px solid var(--light-border-color)'>
|
|
@@ -130,7 +130,7 @@ export default class SchemaTable extends LitElement {
|
|
|
130
130
|
return;
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
if (data['::readwrite'] === 'readonly') {
|
|
133
|
+
if (data && data['::readwrite'] === 'readonly') {
|
|
134
134
|
return;
|
|
135
135
|
}
|
|
136
136
|
}
|
|
@@ -140,17 +140,27 @@ export default class SchemaTable extends LitElement {
|
|
|
140
140
|
return;
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
|
-
if (data['::readwrite'] === 'writeonly') {
|
|
143
|
+
if (data && data['::readwrite'] === 'writeonly') {
|
|
144
144
|
return;
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
|
+
if (!data) {
|
|
148
|
+
return html`<div class="null" style="display:inline;">
|
|
149
|
+
<span style='margin-left:${(schemaLevel + 1) * 16}px'> </span>
|
|
150
|
+
<span class="key-label xxx-of-key"> ${key.replace('::OPTION~', '')}</span>
|
|
151
|
+
${
|
|
152
|
+
dataType === 'array'
|
|
153
|
+
? html`<span class='mono-font'> [ ] </span>`
|
|
154
|
+
: dataType === 'object'
|
|
155
|
+
? html`<span class='mono-font'> { } </span>`
|
|
156
|
+
: html`<span class='mono-font'> schema undefined </span>`
|
|
157
|
+
}
|
|
158
|
+
</div>`;
|
|
159
|
+
}
|
|
147
160
|
|
|
148
161
|
const newSchemaLevel = data['::type']?.startsWith('xxx-of') ? schemaLevel : (schemaLevel + 1);
|
|
149
162
|
const newIndentLevel = dataType === 'xxx-of-option' || data['::type'] === 'xxx-of-option' || key.startsWith('::OPTION') ? indentLevel : (indentLevel + 1);
|
|
150
163
|
const leftPadding = 16 * newIndentLevel; // 2 space indentation at each level
|
|
151
|
-
if (!data) {
|
|
152
|
-
return html`<div class="null" style="display:inline;">null</div>`;
|
|
153
|
-
}
|
|
154
164
|
if (Object.keys(data).length === 0) {
|
|
155
165
|
return html`<span class="td key object" style='padding-left:${leftPadding}px'>${key}</span>`;
|
|
156
166
|
}
|
|
@@ -173,14 +183,14 @@ export default class SchemaTable extends LitElement {
|
|
|
173
183
|
if (dataType === 'array') {
|
|
174
184
|
detailObjType = 'array of object'; // Array of Object
|
|
175
185
|
} else {
|
|
176
|
-
detailObjType = '
|
|
186
|
+
detailObjType = data['::dataTypeLabel'] || data['::type'];
|
|
177
187
|
}
|
|
178
188
|
} else if (data['::type'] === 'array') {
|
|
179
189
|
if (dataType === 'array') {
|
|
180
190
|
// detailObjType = 'array of array'; // Array of array
|
|
181
191
|
detailObjType = `array of array ${arrayType !== 'object' ? `of ${arrayType}` : ''}`; // Array of array
|
|
182
192
|
} else {
|
|
183
|
-
detailObjType = '
|
|
193
|
+
detailObjType = data['::dataTypeLabel'] || data['::type'];
|
|
184
194
|
}
|
|
185
195
|
}
|
|
186
196
|
|
|
@@ -188,7 +198,7 @@ export default class SchemaTable extends LitElement {
|
|
|
188
198
|
return html`
|
|
189
199
|
${newSchemaLevel >= 0 && key
|
|
190
200
|
? html`
|
|
191
|
-
<div class='tr ${newSchemaLevel <= this.schemaExpandLevel ? 'expanded' : 'collapsed'} ${data['::type']}' data-obj='${keyLabel}'>
|
|
201
|
+
<div class='tr ${newSchemaLevel <= this.schemaExpandLevel ? 'expanded' : 'collapsed'} ${data['::type']}' data-obj='${keyLabel}' title="${data['::deprecated'] ? 'Deprecated' : ''}">
|
|
192
202
|
<div class="td key ${data['::deprecated'] ? 'deprecated' : ''}" style='padding-left:${leftPadding}px'>
|
|
193
203
|
${(keyLabel || keyDescr)
|
|
194
204
|
? html`
|
|
@@ -204,8 +214,8 @@ export default class SchemaTable extends LitElement {
|
|
|
204
214
|
${data['::type'] === 'xxx-of-option' || data['::type'] === 'xxx-of-array' || key.startsWith('::OPTION')
|
|
205
215
|
? html`<span class="xxx-of-key" style="margin-left:-6px">${keyLabel}</span><span class="${isOneOfLabel ? 'xxx-of-key' : 'xxx-of-descr'}">${keyDescr}</span>`
|
|
206
216
|
: keyLabel.endsWith('*')
|
|
207
|
-
? html`<span class="key-label" style="display:inline-block; margin-left:-6px;"
|
|
208
|
-
: html`<span class="key-label" style="display:inline-block; margin-left:-6px;">${keyLabel === '::props' ? '' : keyLabel}</span>`
|
|
217
|
+
? html`<span class="key-label" style="display:inline-block; margin-left:-6px;">${data['::deprecated'] ? '✗' : ''} ${keyLabel.substring(0, keyLabel.length - 1)}</span><span style='color:var(--red);'>*</span>`
|
|
218
|
+
: html`<span class="key-label" style="display:inline-block; margin-left:-6px;">${data['::deprecated'] ? '✗' : ''} ${keyLabel === '::props' ? '' : keyLabel}</span>`
|
|
209
219
|
}
|
|
210
220
|
${data['::type'] === 'xxx-of' && dataType === 'array' ? html`<span style="color:var(--primary-color)">ARRAY</span>` : ''}
|
|
211
221
|
</div>
|
|
@@ -234,7 +244,7 @@ export default class SchemaTable extends LitElement {
|
|
|
234
244
|
? html`${this.generateTree(data[0], 'xxx-of-option', '', '::ARRAY~OF', '', newSchemaLevel, newIndentLevel, '')}`
|
|
235
245
|
: html`
|
|
236
246
|
${Object.keys(data).map((dataKey) => html`
|
|
237
|
-
${['::title', '::description', '::type', '::props', '::deprecated', '::array-type', '::readwrite'].includes(dataKey)
|
|
247
|
+
${['::title', '::description', '::type', '::props', '::deprecated', '::array-type', '::readwrite', '::dataTypeLabel'].includes(dataKey)
|
|
238
248
|
? data[dataKey]['::type'] === 'array' || data[dataKey]['::type'] === 'object'
|
|
239
249
|
? html`${this.generateTree(
|
|
240
250
|
data[dataKey]['::type'] === 'array' ? data[dataKey]['::props'] : data[dataKey],
|
|
@@ -287,23 +297,35 @@ export default class SchemaTable extends LitElement {
|
|
|
287
297
|
</div>`;
|
|
288
298
|
}
|
|
289
299
|
return html`
|
|
290
|
-
<div class = "tr primitive">
|
|
300
|
+
<div class = "tr primitive" title="${deprecated ? 'Deprecated' : ''}">
|
|
291
301
|
<div class="td key ${deprecated}" style='padding-left:${leftPadding}px'>
|
|
302
|
+
${deprecated ? html`<span style='color:var(--red);'>✗</span>` : ''}
|
|
292
303
|
${keyLabel?.endsWith('*')
|
|
293
|
-
? html
|
|
304
|
+
? html`
|
|
305
|
+
<span class="key-label">${keyLabel.substring(0, keyLabel.length - 1)}</span>
|
|
306
|
+
<span style='color:var(--red);'>*</span>`
|
|
294
307
|
: key.startsWith('::OPTION')
|
|
295
308
|
? html`<span class='xxx-of-key'>${keyLabel}</span><span class="xxx-of-descr">${keyDescr}</span>`
|
|
296
309
|
: html`${keyLabel ? html`<span class="key-label"> ${keyLabel}</span>` : html`<span class="xxx-of-descr">${schemaTitle}</span>`}`
|
|
297
310
|
}
|
|
298
311
|
</div>
|
|
299
312
|
${dataTypeHtml}
|
|
300
|
-
<div class='td key-descr'>
|
|
313
|
+
<div class='td key-descr' @click="${() => { this.schemaDescriptionExpanded = 'true'; }}">
|
|
301
314
|
${dataType === 'array' ? html`<span class="m-markdown-small">${unsafeHTML(marked(description))}</span>` : ''}
|
|
315
|
+
${schemaDescription
|
|
316
|
+
? html`<span class="m-markdown-small">
|
|
317
|
+
${unsafeHTML(marked(`${schemaTitle ? `**${schemaTitle}:**` : ''} ${schemaDescription} ${constraint || defaultValue || allowedValues || pattern ? '<span class="more-content">⤵</span>' : ''}`))}
|
|
318
|
+
</span>`
|
|
319
|
+
: schemaTitle
|
|
320
|
+
? html`${schemaTitle} ${constraint || defaultValue || allowedValues || pattern
|
|
321
|
+
? html`<span class="more-content">⤵</span>`
|
|
322
|
+
: ''}`
|
|
323
|
+
: ''
|
|
324
|
+
}
|
|
302
325
|
${constraint ? html`<div style='display:inline-block; line-break:anywhere; margin-right:8px;'> <span class='bold-text'>Constraints: </span> ${constraint}</div>` : ''}
|
|
303
326
|
${defaultValue ? html`<div style='display:inline-block; line-break:anywhere; margin-right:8px;'> <span class='bold-text'>Default: </span>${defaultValue}</div>` : ''}
|
|
304
327
|
${allowedValues ? html`<div style='display:inline-block; line-break:anywhere; margin-right:8px;'> <span class='bold-text'>Allowed: </span>${allowedValues}</div>` : ''}
|
|
305
328
|
${pattern ? html`<div style='display:inline-block; line-break:anywhere; margin-right:8px;'> <span class='bold-text'>Pattern: </span>${pattern}</div>` : ''}
|
|
306
|
-
${schemaDescription ? html`<span class="m-markdown-small">${unsafeHTML(marked(`${schemaTitle ? `**${schemaTitle}:**` : ''} ${schemaDescription}`))}</span>` : ''}
|
|
307
329
|
</div>
|
|
308
330
|
</div>
|
|
309
331
|
`;
|
|
@@ -52,7 +52,16 @@ export default class SchemaTree extends LitElement {
|
|
|
52
52
|
max-width: 300px;
|
|
53
53
|
}
|
|
54
54
|
.key.deprecated .key-label {
|
|
55
|
-
|
|
55
|
+
color: var(--red);
|
|
56
|
+
}
|
|
57
|
+
.tr.expanded:hover > .td.key > .open-bracket {
|
|
58
|
+
color: var(--primary-color);
|
|
59
|
+
}
|
|
60
|
+
.tr.expanded:hover + .inside-bracket {
|
|
61
|
+
border-left: 1px solid var(--fg3);
|
|
62
|
+
}
|
|
63
|
+
.tr.expanded:hover + .inside-bracket + .close-bracket {
|
|
64
|
+
color: var(--primary-color);
|
|
56
65
|
}
|
|
57
66
|
|
|
58
67
|
.open-bracket{
|
|
@@ -98,7 +107,7 @@ export default class SchemaTree extends LitElement {
|
|
|
98
107
|
${this.allowSchemaDescriptionExpandToggle === 'true'
|
|
99
108
|
? html`
|
|
100
109
|
<div style="flex:1"></div>
|
|
101
|
-
<div class='toolbar-item' @click='${() => { this.schemaDescriptionExpanded = (this.schemaDescriptionExpanded === 'true' ? 'false' : 'true'); }}'>
|
|
110
|
+
<div part="schema-toolbar-item schema-multiline-toggle" class='toolbar-item' @click='${() => { this.schemaDescriptionExpanded = (this.schemaDescriptionExpanded === 'true' ? 'false' : 'true'); }}'>
|
|
102
111
|
${this.schemaDescriptionExpanded === 'true' ? 'Single line description' : 'Multiline description'}
|
|
103
112
|
</div>
|
|
104
113
|
`
|
|
@@ -106,7 +115,7 @@ export default class SchemaTree extends LitElement {
|
|
|
106
115
|
}
|
|
107
116
|
</div>
|
|
108
117
|
${this.data?.['::description']
|
|
109
|
-
? html`<span class='m-markdown'> ${unsafeHTML(marked(this.data['::description'] || ''))}</span>`
|
|
118
|
+
? html`<span part="schema-description" class='m-markdown'> ${unsafeHTML(marked(this.data['::description'] || ''))}</span>`
|
|
110
119
|
: ''
|
|
111
120
|
}
|
|
112
121
|
${this.data
|
|
@@ -129,7 +138,7 @@ export default class SchemaTree extends LitElement {
|
|
|
129
138
|
return;
|
|
130
139
|
}
|
|
131
140
|
}
|
|
132
|
-
if (data['::readwrite'] === 'readonly') {
|
|
141
|
+
if (data && data['::readwrite'] === 'readonly') {
|
|
133
142
|
return;
|
|
134
143
|
}
|
|
135
144
|
}
|
|
@@ -139,13 +148,22 @@ export default class SchemaTree extends LitElement {
|
|
|
139
148
|
return;
|
|
140
149
|
}
|
|
141
150
|
}
|
|
142
|
-
if (data['::readwrite'] === 'writeonly') {
|
|
151
|
+
if (data && data['::readwrite'] === 'writeonly') {
|
|
143
152
|
return;
|
|
144
153
|
}
|
|
145
154
|
}
|
|
146
155
|
|
|
147
156
|
if (!data) {
|
|
148
|
-
return html`<div class="null" style="display:inline;">
|
|
157
|
+
return html`<div class="null" style="display:inline;">
|
|
158
|
+
<span class="key-label xxx-of-key"> ${key.replace('::OPTION~', '')}</span>
|
|
159
|
+
${
|
|
160
|
+
dataType === 'array'
|
|
161
|
+
? html`<span class='mono-font'> [ ] </span>`
|
|
162
|
+
: dataType === 'object'
|
|
163
|
+
? html`<span class='mono-font'> { } </span>`
|
|
164
|
+
: html`<span class='mono-font'> schema undefined </span>`
|
|
165
|
+
}
|
|
166
|
+
</div>`;
|
|
149
167
|
}
|
|
150
168
|
if (Object.keys(data).length === 0) {
|
|
151
169
|
return html`<span class="key object">${key}:{ }</span>`;
|
|
@@ -205,14 +223,15 @@ export default class SchemaTree extends LitElement {
|
|
|
205
223
|
}
|
|
206
224
|
if (typeof data === 'object') {
|
|
207
225
|
return html`
|
|
208
|
-
<div class="tr ${schemaLevel < this.schemaExpandLevel || data['::type']?.startsWith('xxx-of') ? 'expanded' : 'collapsed'} ${data['::type'] || 'no-type-info'}">
|
|
226
|
+
<div class="tr ${schemaLevel < this.schemaExpandLevel || data['::type']?.startsWith('xxx-of') ? 'expanded' : 'collapsed'} ${data['::type'] || 'no-type-info'}" title="${data['::deprecated'] ? 'Deprecated' : ''}">
|
|
209
227
|
<div class="td key ${data['::deprecated'] ? 'deprecated' : ''}" style='min-width:${minFieldColWidth}px'>
|
|
210
228
|
${data['::type'] === 'xxx-of-option' || data['::type'] === 'xxx-of-array' || key.startsWith('::OPTION')
|
|
211
|
-
? html`<span class='key-label xxx-of-key'
|
|
229
|
+
? html`<span class='key-label xxx-of-key'> ${keyLabel}</span><span class="xxx-of-descr">${keyDescr}</span>`
|
|
212
230
|
: keyLabel === '::props' || keyLabel === '::ARRAY~OF'
|
|
213
231
|
? ''
|
|
214
232
|
: schemaLevel > 0
|
|
215
233
|
? html`<span class="key-label" title="${readOrWrite === 'readonly' ? 'Read-Only' : readOrWrite === 'writeonly' ? 'Write-Only' : ''}">
|
|
234
|
+
${data['::deprecated'] ? '✗' : ''}
|
|
216
235
|
${keyLabel.replace(/\*$/, '')}${keyLabel.endsWith('*') ? html`<span style="color:var(--red)">*</span>` : ''}${readOrWrite === 'readonly' ? html` 🆁` : readOrWrite === 'writeonly' ? html` 🆆` : readOrWrite}:
|
|
217
236
|
</span>`
|
|
218
237
|
: ''
|
|
@@ -227,7 +246,7 @@ export default class SchemaTree extends LitElement {
|
|
|
227
246
|
? html`${this.generateTree(data[0], 'xxx-of-option', '', '::ARRAY~OF', '', newSchemaLevel, newIndentLevel, data[0]['::readwrite'])}`
|
|
228
247
|
: html`
|
|
229
248
|
${Object.keys(data).map((dataKey) => html`
|
|
230
|
-
${['::title', '::description', '::type', '::props', '::deprecated', '::array-type', '::readwrite'].includes(dataKey)
|
|
249
|
+
${['::title', '::description', '::type', '::props', '::deprecated', '::array-type', '::readwrite', '::dataTypeLabel'].includes(dataKey)
|
|
231
250
|
? data[dataKey]['::type'] === 'array' || data[dataKey]['::type'] === 'object'
|
|
232
251
|
? html`${this.generateTree(
|
|
233
252
|
data[dataKey]['::type'] === 'array' ? data[dataKey]['::props'] : data[dataKey],
|
|
@@ -291,8 +310,9 @@ export default class SchemaTree extends LitElement {
|
|
|
291
310
|
}
|
|
292
311
|
|
|
293
312
|
return html`
|
|
294
|
-
<div class = "tr primitive">
|
|
295
|
-
<div class="td key ${deprecated}" style='min-width:${minFieldColWidth}px'
|
|
313
|
+
<div class = "tr primitive" title="${deprecated ? 'Deprecated' : ''}">
|
|
314
|
+
<div class="td key ${deprecated}" style='min-width:${minFieldColWidth}px'>
|
|
315
|
+
${deprecated ? html`<span style='color:var(--red);'>✗</span>` : ''}
|
|
296
316
|
${keyLabel.endsWith('*')
|
|
297
317
|
? html`<span class="key-label">${keyLabel.substring(0, keyLabel.length - 1)}</span><span style='color:var(--red);'>*</span>:`
|
|
298
318
|
: key.startsWith('::OPTION')
|
|
@@ -306,11 +326,20 @@ export default class SchemaTree extends LitElement {
|
|
|
306
326
|
</div>
|
|
307
327
|
<div class='td key-descr'>
|
|
308
328
|
${dataType === 'array' ? html`<span class="m-markdown-small">${unsafeHTML(marked(description))}</span>` : ''}
|
|
329
|
+
${schemaDescription
|
|
330
|
+
? html`<span class="m-markdown-small">
|
|
331
|
+
${unsafeHTML(marked(`${schemaTitle ? `**${schemaTitle}:**` : ''} ${schemaDescription} ${constraint || defaultValue || allowedValues || pattern ? '<span class="more-content">⤵</span>' : ''}`))}
|
|
332
|
+
</span>`
|
|
333
|
+
: schemaTitle
|
|
334
|
+
? html`${schemaTitle} ${constraint || defaultValue || allowedValues || pattern
|
|
335
|
+
? html`<span class="more-content">⤵</span>`
|
|
336
|
+
: ''}`
|
|
337
|
+
: ''
|
|
338
|
+
}
|
|
309
339
|
${constraint ? html`<div style='display:inline-block; line-break:anywhere; margin-right:8px'><span class='bold-text'>Constraints: </span>${constraint}</div>` : ''}
|
|
310
340
|
${defaultValue ? html`<div style='display:inline-block; line-break:anywhere; margin-right:8px'><span class='bold-text'>Default: </span>${defaultValue}</div>` : ''}
|
|
311
341
|
${allowedValues ? html`<div style='display:inline-block; line-break:anywhere; margin-right:8px'><span class='bold-text'>Allowed: </span>${allowedValues}</div>` : ''}
|
|
312
342
|
${pattern ? html`<div style='display:inline-block; line-break: anywhere; margin-right:8px'><span class='bold-text'>Pattern: </span>${pattern}</div>` : ''}
|
|
313
|
-
${schemaDescription ? html`<span class="m-markdown-small">${unsafeHTML(marked(`${schemaTitle ? `**${schemaTitle}:**` : ''} ${schemaDescription}`))}</span>` : ''}
|
|
314
343
|
</div>
|
|
315
344
|
</div>
|
|
316
345
|
`;
|
|
@@ -134,7 +134,7 @@ export default class JsonSchemaViewer extends LitElement {
|
|
|
134
134
|
.main-content::-webkit-scrollbar-thumb {
|
|
135
135
|
background-color: var(--border-color);
|
|
136
136
|
}
|
|
137
|
-
.header {
|
|
137
|
+
.main-header {
|
|
138
138
|
background-color:var(--header-bg);
|
|
139
139
|
color:var(--header-fg);
|
|
140
140
|
width:100%;
|
|
@@ -229,7 +229,6 @@ export default class JsonSchemaViewer extends LitElement {
|
|
|
229
229
|
if (!this.allowSearch || !'true, false,'.includes(`${this.allowSearch},`)) { this.allowSearch = 'true'; }
|
|
230
230
|
if (!this.schemaExpandLevel || this.schemaExpandLevel < 1) { this.schemaExpandLevel = 99999; }
|
|
231
231
|
if (!this.schemaDescriptionExpanded || !'true, false,'.includes(`${this.schemaDescriptionExpanded},`)) { this.schemaDescriptionExpanded = 'false'; }
|
|
232
|
-
if (!this.responseAreaHeight) { this.responseAreaHeight = '300px'; }
|
|
233
232
|
if (!this.fontSize || !'default, large, largest,'.includes(`${this.fontSize},`)) { this.fontSize = 'default'; }
|
|
234
233
|
if (!this.matchType || !'includes regex'.includes(this.matchType)) { this.matchType = 'includes'; }
|
|
235
234
|
if (!this.allowSchemaDescriptionExpandToggle || !'true, false,'.includes(`${this.allowSchemaDescriptionExpandToggle},`)) { this.allowSchemaDescriptionExpandToggle = 'true'; }
|
package/src/rapidoc-mini.js
CHANGED
|
@@ -25,6 +25,8 @@ import EndpointStyles from '~/styles/endpoint-styles';
|
|
|
25
25
|
import { rapidocApiKey } from '~/utils/common-utils';
|
|
26
26
|
import ProcessSpec from '~/utils/spec-parser';
|
|
27
27
|
import mainBodyTemplate from '~/templates/main-body-template';
|
|
28
|
+
import { applyApiKey, onClearAllApiKeys } from '~/templates/security-scheme-template';
|
|
29
|
+
import { setApiServer } from '~/templates/server-template';
|
|
28
30
|
|
|
29
31
|
export default class RapiDocMini extends LitElement {
|
|
30
32
|
constructor() {
|
|
@@ -301,6 +303,27 @@ export default class RapiDocMini extends LitElement {
|
|
|
301
303
|
}
|
|
302
304
|
}
|
|
303
305
|
|
|
306
|
+
// Public Method - to update security-scheme of type http
|
|
307
|
+
setHttpUserNameAndPassword(securitySchemeId, username, password) {
|
|
308
|
+
return applyApiKey.call(this, securitySchemeId, username, password);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// Public Method - to update security-scheme of type apiKey or OAuth
|
|
312
|
+
setApiKey(securitySchemeId, apiKeyValue) {
|
|
313
|
+
return applyApiKey.call(this, securitySchemeId, '', '', apiKeyValue);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// Public Method
|
|
317
|
+
removeAllSecurityKeys() {
|
|
318
|
+
return onClearAllApiKeys.call(this);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// Public Method
|
|
322
|
+
setApiServer(apiServerUrl) {
|
|
323
|
+
// return apiServerUrl;
|
|
324
|
+
return setApiServer.call(this, apiServerUrl);
|
|
325
|
+
}
|
|
326
|
+
|
|
304
327
|
async afterSpecParsedAndValidated(spec) {
|
|
305
328
|
this.resolvedSpec = spec;
|
|
306
329
|
this.selectedServer = undefined;
|
package/src/rapidoc.js
CHANGED
|
@@ -107,6 +107,8 @@ export default class RapiDoc extends LitElement {
|
|
|
107
107
|
regularFont: { type: String, attribute: 'regular-font' },
|
|
108
108
|
monoFont: { type: String, attribute: 'mono-font' },
|
|
109
109
|
loadFonts: { type: String, attribute: 'load-fonts' },
|
|
110
|
+
cssFile: { type: String, attribute: 'css-file' },
|
|
111
|
+
cssClasses: { type: String, attribute: 'css-classes' },
|
|
110
112
|
|
|
111
113
|
// Nav Bar Colors
|
|
112
114
|
navBgColor: { type: String, attribute: 'nav-bg-color' },
|
|
@@ -115,6 +117,7 @@ export default class RapiDoc extends LitElement {
|
|
|
115
117
|
navHoverTextColor: { type: String, attribute: 'nav-hover-text-color' },
|
|
116
118
|
navAccentColor: { type: String, attribute: 'nav-accent-color' },
|
|
117
119
|
navItemSpacing: { type: String, attribute: 'nav-item-spacing' },
|
|
120
|
+
showMethodInNavBar: { type: String, attribute: 'show-method-in-nav-bar' },
|
|
118
121
|
usePathInNavBar: { type: String, attribute: 'use-path-in-nav-bar' },
|
|
119
122
|
infoDescriptionHeadingsInNavBar: { type: String, attribute: 'info-description-headings-in-navbar' },
|
|
120
123
|
|
|
@@ -250,7 +253,7 @@ export default class RapiDoc extends LitElement {
|
|
|
250
253
|
.tag.title {
|
|
251
254
|
text-transform: uppercase;
|
|
252
255
|
}
|
|
253
|
-
.header {
|
|
256
|
+
.main-header {
|
|
254
257
|
background-color:var(--header-bg);
|
|
255
258
|
color:var(--header-fg);
|
|
256
259
|
width:100%;
|
|
@@ -327,6 +330,30 @@ export default class RapiDoc extends LitElement {
|
|
|
327
330
|
100% { transform: rotate(360deg); }
|
|
328
331
|
}
|
|
329
332
|
|
|
333
|
+
.nav-method { font-weight: bold; margin-right: 4px; font-size: calc(var(--font-size-small) - 2px); white-space: nowrap; }
|
|
334
|
+
.nav-method.false { display: none; }
|
|
335
|
+
|
|
336
|
+
.nav-method.as-colored-text.get { color:var(--nav-get-color); }
|
|
337
|
+
.nav-method.as-colored-text.put { color:var(--nav-put-color); }
|
|
338
|
+
.nav-method.as-colored-text.post { color:var(--nav-post-color); }
|
|
339
|
+
.nav-method.as-colored-text.delete { color:var(--nav-delete-color); }
|
|
340
|
+
.nav-method.as-colored-text.head, .nav-method.as-colored-text.patch, .nav-method.as-colored-text.options { color:var(--nav-head-color); }
|
|
341
|
+
|
|
342
|
+
.nav-method.as-colored-block {
|
|
343
|
+
padding: 1px 4px;
|
|
344
|
+
min-width: 30px;
|
|
345
|
+
border-radius: 4px 0 0 4px;
|
|
346
|
+
color: #000;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
.nav-method.as-colored-block.get { background-color: var(--blue); }
|
|
350
|
+
.nav-method.as-colored-block.put { background-color: var(--orange); }
|
|
351
|
+
.nav-method.as-colored-block.post { background-color: var(--green); }
|
|
352
|
+
.nav-method.as-colored-block.delete { background-color: var(--red); }
|
|
353
|
+
.nav-method.as-colored-block.head, .nav-method.as-colored-block.patch , .nav-method.as-colored-block.options {
|
|
354
|
+
background-color: var(--yellow);
|
|
355
|
+
}
|
|
356
|
+
|
|
330
357
|
@media only screen and (min-width: 768px) {
|
|
331
358
|
.nav-bar {
|
|
332
359
|
width: 260px;
|
|
@@ -423,22 +450,15 @@ export default class RapiDoc extends LitElement {
|
|
|
423
450
|
}
|
|
424
451
|
if (!this.schemaExpandLevel || this.schemaExpandLevel < 1) { this.schemaExpandLevel = 99999; }
|
|
425
452
|
if (!this.schemaDescriptionExpanded || !'true, false,'.includes(`${this.schemaDescriptionExpanded},`)) { this.schemaDescriptionExpanded = 'false'; }
|
|
426
|
-
|
|
427
|
-
if (!this.schemaHideReadOnly) {
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
this.schemaHideReadOnly = writeMethodsWithBody.filter((value) => this.schemaHideReadOnly.includes(value));
|
|
431
|
-
if (this.schemaHideReadOnly.length === 0) {
|
|
432
|
-
this.schemaHideReadOnly = writeMethodsWithBody;
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
this.schemaHideReadOnly += ['get', 'head', 'delete', 'options'];
|
|
436
|
-
this.schemaHideWriteOnly = this.schemaHideWriteOnly !== 'never';
|
|
453
|
+
|
|
454
|
+
if (!this.schemaHideReadOnly || !'default, never,'.includes(`${this.schemaHideReadOnly},`)) { this.schemaHideReadOnly = 'default'; }
|
|
455
|
+
if (!this.schemaHideWriteOnly || !'default, never,'.includes(`${this.schemaHideWriteOnly},`)) { this.schemaHideWriteOnly = 'default'; }
|
|
456
|
+
|
|
437
457
|
if (!this.fillRequestFieldsWithExample || !'true, false,'.includes(`${this.fillRequestFieldsWithExample},`)) { this.fillRequestFieldsWithExample = 'true'; }
|
|
438
458
|
if (!this.persistAuth || !'true, false,'.includes(`${this.persistAuth},`)) { this.persistAuth = 'false'; }
|
|
439
459
|
if (!this.onNavTagClick || !'expand-collapse, show-description,'.includes(`${this.onNavTagClick},`)) { this.onNavTagClick = 'expand-collapse'; }
|
|
440
460
|
if (!this.responseAreaHeight) {
|
|
441
|
-
this.responseAreaHeight = '
|
|
461
|
+
this.responseAreaHeight = '400px';
|
|
442
462
|
}
|
|
443
463
|
|
|
444
464
|
if (!this.allowSearch || !'true, false,'.includes(`${this.allowSearch},`)) { this.allowSearch = 'true'; }
|
|
@@ -456,6 +476,7 @@ export default class RapiDoc extends LitElement {
|
|
|
456
476
|
if (!this.generateMissingTags || !'true, false,'.includes(`${this.generateMissingTags},`)) { this.generateMissingTags = 'false'; }
|
|
457
477
|
if (!this.sortEndpointsBy || !'method, path, summary, none,'.includes(`${this.sortEndpointsBy},`)) { this.sortEndpointsBy = 'path'; }
|
|
458
478
|
if (!this.navItemSpacing || !'compact, relaxed, default,'.includes(`${this.navItemSpacing},`)) { this.navItemSpacing = 'default'; }
|
|
479
|
+
if (!this.showMethodInNavBar || !'false, as-plain-text, as-colored-text, as-colored-block,'.includes(`${this.showMethodInNavBar},`)) { this.showMethodInNavBar = 'false'; }
|
|
459
480
|
if (!this.usePathInNavBar || !'true, false,'.includes(`${this.usePathInNavBar},`)) { this.usePathInNavBar = 'false'; }
|
|
460
481
|
if (!this.fontSize || !'default, large, largest,'.includes(`${this.fontSize},`)) { this.fontSize = 'default'; }
|
|
461
482
|
|
|
@@ -472,6 +493,9 @@ export default class RapiDoc extends LitElement {
|
|
|
472
493
|
|
|
473
494
|
if (!this.showAdvancedSearchDialog) { this.showAdvancedSearchDialog = false; }
|
|
474
495
|
|
|
496
|
+
if (!this.cssFile) { this.cssFile = null; }
|
|
497
|
+
if (!this.cssClasses) { this.cssClasses = ''; }
|
|
498
|
+
|
|
475
499
|
marked.setOptions({
|
|
476
500
|
highlight: (code, lang) => {
|
|
477
501
|
if (Prism.languages[lang]) {
|
|
@@ -504,6 +528,11 @@ export default class RapiDoc extends LitElement {
|
|
|
504
528
|
|
|
505
529
|
render() {
|
|
506
530
|
// return render(mainBodyTemplate(this), this.shadowRoot, { eventContext: this });
|
|
531
|
+
const cssLinkEl = document.querySelector(`link[href*="${this.cssFile}"]`);
|
|
532
|
+
// adding custom style for RapiDoc
|
|
533
|
+
if (cssLinkEl) {
|
|
534
|
+
this.shadowRoot.appendChild(cssLinkEl.cloneNode());
|
|
535
|
+
}
|
|
507
536
|
return mainBodyTemplate.call(this);
|
|
508
537
|
}
|
|
509
538
|
|
|
@@ -736,8 +765,11 @@ export default class RapiDoc extends LitElement {
|
|
|
736
765
|
this.scrollTo(elementId);
|
|
737
766
|
}
|
|
738
767
|
} else if (this.renderStyle === 'focused') {
|
|
739
|
-
|
|
740
|
-
this.
|
|
768
|
+
// If goto-path is provided and no location-hash is present then try to scroll to default element
|
|
769
|
+
if (!this.gotoPath) {
|
|
770
|
+
const defaultElementId = this.showInfo ? 'overview' : this.resolvedSpec.tags[0]?.paths[0];
|
|
771
|
+
this.scrollTo(defaultElementId);
|
|
772
|
+
}
|
|
741
773
|
}
|
|
742
774
|
}
|
|
743
775
|
|
|
@@ -855,6 +887,12 @@ export default class RapiDoc extends LitElement {
|
|
|
855
887
|
return;
|
|
856
888
|
}
|
|
857
889
|
this.isIntersectionObserverActive = false;
|
|
890
|
+
if (this.renderStyle === 'focused') {
|
|
891
|
+
const requestEl = this.shadowRoot.querySelector('api-request');
|
|
892
|
+
if (requestEl) {
|
|
893
|
+
requestEl.beforerNavigationFocusedMode();
|
|
894
|
+
}
|
|
895
|
+
}
|
|
858
896
|
this.scrollTo(navEl.dataset.contentId, true, scrollNavItemToView);
|
|
859
897
|
setTimeout(() => {
|
|
860
898
|
this.isIntersectionObserverActive = true;
|
|
@@ -867,7 +905,6 @@ export default class RapiDoc extends LitElement {
|
|
|
867
905
|
// for focused mode update this.focusedElementId to update the rendering, else it wont find the needed html elements
|
|
868
906
|
// focusedElementId will get validated in the template
|
|
869
907
|
this.focusedElementId = elementId;
|
|
870
|
-
await sleep(0);
|
|
871
908
|
}
|
|
872
909
|
if (this.renderStyle === 'view') {
|
|
873
910
|
this.expandAndGotoOperation(elementId, expandPath, true);
|
|
@@ -885,7 +922,7 @@ export default class RapiDoc extends LitElement {
|
|
|
885
922
|
if (this.renderStyle === 'focused') {
|
|
886
923
|
const requestEl = this.shadowRoot.querySelector('api-request');
|
|
887
924
|
if (requestEl) {
|
|
888
|
-
requestEl.
|
|
925
|
+
requestEl.afterNavigationFocusedMode();
|
|
889
926
|
}
|
|
890
927
|
const responseEl = this.shadowRoot.querySelector('api-response');
|
|
891
928
|
if (responseEl) {
|
|
@@ -105,7 +105,7 @@ export default css`
|
|
|
105
105
|
word-break: break-all;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
.method{
|
|
108
|
+
.endpoint-head .method{
|
|
109
109
|
padding:2px 5px;
|
|
110
110
|
vertical-align: middle;
|
|
111
111
|
font-size:var(--font-size-small);
|
|
@@ -119,14 +119,14 @@ export default css`
|
|
|
119
119
|
text-transform:uppercase;
|
|
120
120
|
margin-right:5px;
|
|
121
121
|
}
|
|
122
|
-
.method.delete{ border: 2px solid var(--red);}
|
|
123
|
-
.method.put{ border: 2px solid var(--orange); }
|
|
124
|
-
.method.post{ border: 2px solid var(--green); }
|
|
125
|
-
.method.get{ border: 2px solid var(--blue); }
|
|
126
|
-
.method.get.deprecated{ border: 2px solid var(--border-color); }
|
|
127
|
-
.method.head,
|
|
128
|
-
.method.patch,
|
|
129
|
-
.method.options {
|
|
122
|
+
.endpoint-head .method.delete{ border: 2px solid var(--red);}
|
|
123
|
+
.endpoint-head .method.put{ border: 2px solid var(--orange); }
|
|
124
|
+
.endpoint-head .method.post{ border: 2px solid var(--green); }
|
|
125
|
+
.endpoint-head .method.get{ border: 2px solid var(--blue); }
|
|
126
|
+
.endpoint-head .method.get.deprecated{ border: 2px solid var(--border-color); }
|
|
127
|
+
.endpoint-head .method.head,
|
|
128
|
+
.endpoint-head .method.patch,
|
|
129
|
+
.endpoint-head .method.options {
|
|
130
130
|
border: 2px solid var(--yellow);
|
|
131
131
|
}
|
|
132
132
|
|
package/src/styles/nav-styles.js
CHANGED
|
@@ -52,7 +52,8 @@ export default css`
|
|
|
52
52
|
height:16px;
|
|
53
53
|
text-align: center;
|
|
54
54
|
display: inline-block;
|
|
55
|
-
transform: rotate(
|
|
55
|
+
transform: rotate(-90deg);
|
|
56
|
+
transition: transform 0.2s ease-out 0s;
|
|
56
57
|
}
|
|
57
58
|
.nav-bar.focused .nav-bar-tag-and-paths.expanded .nav-bar-tag-icon::after {
|
|
58
59
|
content: '⌵';
|
|
@@ -60,6 +61,7 @@ export default css`
|
|
|
60
61
|
height:16px;
|
|
61
62
|
text-align: center;
|
|
62
63
|
display: inline-block;
|
|
64
|
+
transition: transform 0.2s ease-out 0s;
|
|
63
65
|
}
|
|
64
66
|
.nav-scroll::-webkit-scrollbar {
|
|
65
67
|
width: var(--scroll-bar-width, 8px);
|
|
@@ -21,10 +21,12 @@ export default css`
|
|
|
21
21
|
word-break: break-all;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
.collapsed-descr .key{
|
|
24
|
+
.collapsed-descr .key {
|
|
25
25
|
overflow:hidden;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
.expanded-descr .more-content { display:none; }
|
|
29
|
+
|
|
28
30
|
.key-descr {
|
|
29
31
|
font-family:var(--font-regular);
|
|
30
32
|
color:var(--light-fg);
|
package/src/styles/tab-styles.js
CHANGED
|
@@ -9,7 +9,7 @@ export default function callbackTemplate(callbacks) {
|
|
|
9
9
|
${kv[0]}
|
|
10
10
|
${Object.entries(kv[1]).map((pathObj) => html`
|
|
11
11
|
<div class="mono-font small-font-size" style="display:flex; margin-left:16px;">
|
|
12
|
-
<div>
|
|
12
|
+
<div style="width:100%">
|
|
13
13
|
${Object.entries(pathObj[1]).map((method) => html`
|
|
14
14
|
<div>
|
|
15
15
|
<div style="margin-top:12px;">
|
|
@@ -36,11 +36,12 @@ export default function callbackTemplate(callbacks) {
|
|
|
36
36
|
schema-expand-level = "${this.schemaExpandLevel}"
|
|
37
37
|
schema-description-expanded = "${this.schemaDescriptionExpanded}"
|
|
38
38
|
allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}",
|
|
39
|
-
schema-hide-read-only = "
|
|
39
|
+
schema-hide-read-only = "false"
|
|
40
|
+
schema-hide-write-only = "${this.schemaHideWriteOnly === 'never' ? 'false' : 'true'}"
|
|
40
41
|
fetch-credentials = "${this.fetchCredentials}"
|
|
41
42
|
exportparts = "btn:btn, btn-fill:btn-fill, btn-outline:btn-outline, btn-try:btn-try, btn-clear:btn-clear, btn-clear-resp:btn-clear-resp,
|
|
42
43
|
file-input:file-input, textbox:textbox, textbox-param:textbox-param, textarea:textarea, textarea-param:textarea-param,
|
|
43
|
-
anchor:anchor, anchor-param-example:anchor-param-example"
|
|
44
|
+
anchor:anchor, anchor-param-example:anchor-param-example, schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
|
|
44
45
|
> </api-request>
|
|
45
46
|
|
|
46
47
|
<api-response
|
|
@@ -54,7 +55,10 @@ export default function callbackTemplate(callbacks) {
|
|
|
54
55
|
schema-expand-level = "${this.schemaExpandLevel}"
|
|
55
56
|
schema-description-expanded = "${this.schemaDescriptionExpanded}"
|
|
56
57
|
allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}"
|
|
57
|
-
|
|
58
|
+
schema-hide-read-only = "${this.schemaHideReadOnly === 'never' ? 'false' : 'true'}"
|
|
59
|
+
schema-hide-write-only = "false"
|
|
60
|
+
exportparts = "btn:btn, btn-response-status:btn-response-status, btn-selected-response-status:btn-selected-response-status, btn-fill:btn-fill, btn-copy:btn-copy,
|
|
61
|
+
schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
|
|
58
62
|
> </api-response>
|
|
59
63
|
</div>
|
|
60
64
|
</div>
|
|
@@ -21,6 +21,7 @@ function schemaBodyTemplate(sComponent) {
|
|
|
21
21
|
allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}",
|
|
22
22
|
schema-hide-read-only = "false"
|
|
23
23
|
schema-hide-write-only = "${this.schemaHideWriteOnly}"
|
|
24
|
+
exportparts = "schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
|
|
24
25
|
> </schema-tree> `
|
|
25
26
|
: html`
|
|
26
27
|
<schema-tree
|
|
@@ -31,6 +32,7 @@ function schemaBodyTemplate(sComponent) {
|
|
|
31
32
|
allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}",
|
|
32
33
|
schema-hide-read-only = "false"
|
|
33
34
|
schema-hide-write-only = "${this.schemaHideWriteOnly}"
|
|
35
|
+
exportparts = "schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
|
|
34
36
|
> </schema-tree>`
|
|
35
37
|
}
|
|
36
38
|
</div>`;
|