rapidoc 9.1.8 → 9.3.2
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/LICENSE.txt +3 -1
- package/README.md +24 -6
- package/dist/index.html +1 -1
- package/dist/index.html.gz +0 -0
- package/dist/rapidoc-min.js +3776 -2
- package/dist/rapidoc-min.js.LICENSE.txt +12 -33
- 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 -0
- package/dist/rapidoc-min.js.map.gz +0 -0
- package/dist/rapidoc.js +4561 -3303
- package/dist/report.html +2 -2
- package/index.html +6 -4
- package/package.json +15 -15
- package/src/components/api-request.js +104 -78
- package/src/components/api-response.js +11 -8
- package/src/components/dialog-box.js +1 -1
- package/src/components/json-tree.js +15 -4
- package/src/components/schema-table.js +40 -18
- package/src/components/schema-tree.js +44 -15
- package/src/components/tag-input.js +1 -1
- package/src/json-schema-viewer.js +2 -2
- package/src/rapidoc-mini.js +27 -2
- package/src/rapidoc.js +41 -3
- package/src/styles/border-styles.js +1 -1
- package/src/styles/custom-styles.js +1 -1
- package/src/styles/dialog-box-styles.js +1 -1
- package/src/styles/endpoint-styles.js +10 -10
- package/src/styles/flex-styles.js +1 -1
- package/src/styles/font-styles.js +1 -1
- package/src/styles/info-styles.js +1 -1
- package/src/styles/input-styles.js +1 -1
- package/src/styles/nav-styles.js +4 -2
- package/src/styles/prism-styles.js +1 -1
- package/src/styles/schema-styles.js +4 -2
- package/src/styles/tab-styles.js +2 -1
- package/src/styles/table-styles.js +1 -1
- package/src/templates/advance-search-template.js +1 -1
- package/src/templates/callback-template.js +11 -4
- package/src/templates/code-samples-template.js +2 -2
- package/src/templates/components-template.js +4 -2
- package/src/templates/endpoint-template.js +23 -16
- package/src/templates/expanded-endpoint-template.js +77 -71
- package/src/templates/focused-endpoint-template.js +2 -2
- package/src/templates/header-template.js +2 -2
- package/src/templates/json-schema-viewer-template.js +3 -3
- package/src/templates/logo-template.js +1 -1
- package/src/templates/main-body-template.js +2 -2
- package/src/templates/navbar-template.js +22 -9
- package/src/templates/overview-template.js +3 -3
- package/src/templates/security-scheme-template.js +54 -44
- package/src/templates/server-template.js +4 -4
- package/src/utils/schema-utils.js +74 -27
- package/src/utils/spec-parser.js +1 -1
- package/src/utils/theme.js +12 -5
- package/webpack.config.js +1 -1
- package/.vscode/settings.json +0 -12
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { LitElement, html, css } from 'lit
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
import { unsafeHTML } from 'lit/directives/unsafe-html.js'; // eslint-disable-line import/extensions
|
|
2
3
|
import { marked } from 'marked';
|
|
3
|
-
import { unsafeHTML } from 'lit-html/directives/unsafe-html';
|
|
4
4
|
import FontStyles from '~/styles/font-styles';
|
|
5
5
|
import SchemaStyles from '~/styles/schema-styles';
|
|
6
6
|
import CustomStyles from '~/styles/custom-styles';
|
|
@@ -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
|
}
|
|
@@ -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
|
-
${['::description', '::type', '::props', '::deprecated', '::array-type', '::readwrite'].includes(dataKey)
|
|
247
|
+
${['::title', '::description', '::type', '::props', '::deprecated', '::array-type', '::readwrite'].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(schemaDescription))}</span>` : ''}
|
|
307
329
|
</div>
|
|
308
330
|
</div>
|
|
309
331
|
`;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { LitElement, html, css } from 'lit
|
|
1
|
+
import { LitElement, html, css } from 'lit';
|
|
2
|
+
import { unsafeHTML } from 'lit/directives/unsafe-html.js'; // eslint-disable-line import/extensions
|
|
2
3
|
import { marked } from 'marked';
|
|
3
|
-
import { unsafeHTML } from 'lit-html/directives/unsafe-html';
|
|
4
4
|
import FontStyles from '~/styles/font-styles';
|
|
5
5
|
import SchemaStyles from '~/styles/schema-styles';
|
|
6
6
|
import BorderStyles from '~/styles/border-styles';
|
|
@@ -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
|
-
${['::description', '::type', '::props', '::deprecated', '::array-type', '::readwrite'].includes(dataKey)
|
|
249
|
+
${['::title', '::description', '::type', '::props', '::deprecated', '::array-type', '::readwrite'].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],
|
|
@@ -263,7 +282,7 @@ export default class SchemaTree extends LitElement {
|
|
|
263
282
|
}
|
|
264
283
|
|
|
265
284
|
// For Primitive types and array of Primitives
|
|
266
|
-
const [type, primitiveReadOrWrite, constraint, defaultValue, allowedValues, pattern, schemaDescription, , deprecated] = data.split('~|~');
|
|
285
|
+
const [type, primitiveReadOrWrite, constraint, defaultValue, allowedValues, pattern, schemaDescription, schemaTitle, deprecated] = data.split('~|~');
|
|
267
286
|
if (primitiveReadOrWrite === '🆁' && this.schemaHideReadOnly === 'true') {
|
|
268
287
|
return;
|
|
269
288
|
}
|
|
@@ -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(schemaDescription))}</span>` : ''}
|
|
314
343
|
</div>
|
|
315
344
|
</div>
|
|
316
345
|
`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { css, LitElement } from 'lit
|
|
1
|
+
import { css, LitElement } from 'lit';
|
|
2
2
|
import { marked } from 'marked';
|
|
3
3
|
import Prism from 'prismjs';
|
|
4
4
|
import 'prismjs/components/prism-css';
|
|
@@ -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%;
|
package/src/rapidoc-mini.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { css, LitElement } from 'lit
|
|
1
|
+
import { css, LitElement } from 'lit';
|
|
2
2
|
import { marked } from 'marked';
|
|
3
3
|
import Prism from 'prismjs';
|
|
4
4
|
import 'prismjs/components/prism-css';
|
|
@@ -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() {
|
|
@@ -49,6 +51,7 @@ export default class RapiDocMini extends LitElement {
|
|
|
49
51
|
responseAreaHeight: { type: String, attribute: 'response-area-height' },
|
|
50
52
|
showSummaryWhenCollapsed: { type: String, attribute: 'show-summary-when-collapsed' },
|
|
51
53
|
fillRequestFieldsWithExample: { type: String, attribute: 'fill-request-fields-with-example' },
|
|
54
|
+
useSummaryToListExamples: { type: String, attribute: 'use-summary-to-list-example' },
|
|
52
55
|
persistAuth: { type: String, attribute: 'persist-auth' },
|
|
53
56
|
|
|
54
57
|
// Schema Styles
|
|
@@ -159,7 +162,7 @@ export default class RapiDocMini extends LitElement {
|
|
|
159
162
|
this.theme = (window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches) ? 'light' : 'dark';
|
|
160
163
|
}
|
|
161
164
|
if (!this.defaultSchemaTab || !'example, schema, model,'.includes(`${this.defaultSchemaTab},`)) {
|
|
162
|
-
this.defaultSchemaTab = '
|
|
165
|
+
this.defaultSchemaTab = 'example';
|
|
163
166
|
} else if (this.defaultSchemaTab === 'model') {
|
|
164
167
|
this.defaultSchemaTab = 'schema';
|
|
165
168
|
}
|
|
@@ -167,6 +170,7 @@ export default class RapiDocMini extends LitElement {
|
|
|
167
170
|
if (!this.schemaExpandLevel || this.schemaExpandLevel < 1) { this.schemaExpandLevel = 99999; }
|
|
168
171
|
if (!this.schemaDescriptionExpanded || !'true, false,'.includes(`${this.schemaDescriptionExpanded},`)) { this.schemaDescriptionExpanded = 'false'; }
|
|
169
172
|
if (!this.fillRequestFieldsWithExample || !'true, false,'.includes(`${this.fillRequestFieldsWithExample},`)) { this.fillRequestFieldsWithExample = 'true'; }
|
|
173
|
+
if (!this.useSummaryToListExamples || !'true, false,'.includes(`${this.useSummaryToListExamples},`)) { this.useSummaryToListExamples = 'false'; }
|
|
170
174
|
if (!this.persistAuth || !'true, false,'.includes(`${this.persistAuth},`)) { this.persistAuth = 'false'; }
|
|
171
175
|
if (!this.responseAreaHeight) { this.responseAreaHeight = '300px'; }
|
|
172
176
|
|
|
@@ -301,6 +305,27 @@ export default class RapiDocMini extends LitElement {
|
|
|
301
305
|
}
|
|
302
306
|
}
|
|
303
307
|
|
|
308
|
+
// Public Method - to update security-scheme of type http
|
|
309
|
+
setHttpUserNameAndPassword(securitySchemeId, username, password) {
|
|
310
|
+
return applyApiKey.call(this, securitySchemeId, username, password);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// Public Method - to update security-scheme of type apiKey or OAuth
|
|
314
|
+
setApiKey(securitySchemeId, apiKeyValue) {
|
|
315
|
+
return applyApiKey.call(this, securitySchemeId, '', '', apiKeyValue);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// Public Method
|
|
319
|
+
removeAllSecurityKeys() {
|
|
320
|
+
return onClearAllApiKeys.call(this);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// Public Method
|
|
324
|
+
setApiServer(apiServerUrl) {
|
|
325
|
+
// return apiServerUrl;
|
|
326
|
+
return setApiServer.call(this, apiServerUrl);
|
|
327
|
+
}
|
|
328
|
+
|
|
304
329
|
async afterSpecParsedAndValidated(spec) {
|
|
305
330
|
this.resolvedSpec = spec;
|
|
306
331
|
this.selectedServer = undefined;
|
package/src/rapidoc.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { css, LitElement, unsafeCSS } from 'lit
|
|
1
|
+
import { css, LitElement, unsafeCSS } from 'lit';
|
|
2
2
|
import { marked } from 'marked';
|
|
3
3
|
import Prism from 'prismjs';
|
|
4
4
|
import 'prismjs/components/prism-css';
|
|
@@ -63,6 +63,7 @@ export default class RapiDoc extends LitElement {
|
|
|
63
63
|
defaultSchemaTab: { type: String, attribute: 'default-schema-tab' },
|
|
64
64
|
responseAreaHeight: { type: String, attribute: 'response-area-height' },
|
|
65
65
|
fillRequestFieldsWithExample: { type: String, attribute: 'fill-request-fields-with-example' },
|
|
66
|
+
useSummaryToListExamples: { type: String, attribute: 'use-summary-to-list-example' },
|
|
66
67
|
persistAuth: { type: String, attribute: 'persist-auth' },
|
|
67
68
|
onNavTagClick: { type: String, attribute: 'on-nav-tag-click' },
|
|
68
69
|
|
|
@@ -107,6 +108,8 @@ export default class RapiDoc extends LitElement {
|
|
|
107
108
|
regularFont: { type: String, attribute: 'regular-font' },
|
|
108
109
|
monoFont: { type: String, attribute: 'mono-font' },
|
|
109
110
|
loadFonts: { type: String, attribute: 'load-fonts' },
|
|
111
|
+
cssFile: { type: String, attribute: 'css-file' },
|
|
112
|
+
cssClasses: { type: String, attribute: 'css-classes' },
|
|
110
113
|
|
|
111
114
|
// Nav Bar Colors
|
|
112
115
|
navBgColor: { type: String, attribute: 'nav-bg-color' },
|
|
@@ -115,6 +118,7 @@ export default class RapiDoc extends LitElement {
|
|
|
115
118
|
navHoverTextColor: { type: String, attribute: 'nav-hover-text-color' },
|
|
116
119
|
navAccentColor: { type: String, attribute: 'nav-accent-color' },
|
|
117
120
|
navItemSpacing: { type: String, attribute: 'nav-item-spacing' },
|
|
121
|
+
showMethodInNavBar: { type: String, attribute: 'show-method-in-nav-bar' },
|
|
118
122
|
usePathInNavBar: { type: String, attribute: 'use-path-in-nav-bar' },
|
|
119
123
|
infoDescriptionHeadingsInNavBar: { type: String, attribute: 'info-description-headings-in-navbar' },
|
|
120
124
|
|
|
@@ -250,7 +254,7 @@ export default class RapiDoc extends LitElement {
|
|
|
250
254
|
.tag.title {
|
|
251
255
|
text-transform: uppercase;
|
|
252
256
|
}
|
|
253
|
-
.header {
|
|
257
|
+
.main-header {
|
|
254
258
|
background-color:var(--header-bg);
|
|
255
259
|
color:var(--header-fg);
|
|
256
260
|
width:100%;
|
|
@@ -327,6 +331,30 @@ export default class RapiDoc extends LitElement {
|
|
|
327
331
|
100% { transform: rotate(360deg); }
|
|
328
332
|
}
|
|
329
333
|
|
|
334
|
+
.nav-method { font-weight: bold; margin-right: 4px; font-size: calc(var(--font-size-small) - 2px); white-space: nowrap; }
|
|
335
|
+
.nav-method.false { display: none; }
|
|
336
|
+
|
|
337
|
+
.nav-method.as-colored-text.get { color:var(--nav-get-color); }
|
|
338
|
+
.nav-method.as-colored-text.put { color:var(--nav-put-color); }
|
|
339
|
+
.nav-method.as-colored-text.post { color:var(--nav-post-color); }
|
|
340
|
+
.nav-method.as-colored-text.delete { color:var(--nav-delete-color); }
|
|
341
|
+
.nav-method.as-colored-text.head, .nav-method.as-colored-text.patch, .nav-method.as-colored-text.options { color:var(--nav-head-color); }
|
|
342
|
+
|
|
343
|
+
.nav-method.as-colored-block {
|
|
344
|
+
padding: 1px 4px;
|
|
345
|
+
min-width: 30px;
|
|
346
|
+
border-radius: 4px 0 0 4px;
|
|
347
|
+
color: #000;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
.nav-method.as-colored-block.get { background-color: var(--blue); }
|
|
351
|
+
.nav-method.as-colored-block.put { background-color: var(--orange); }
|
|
352
|
+
.nav-method.as-colored-block.post { background-color: var(--green); }
|
|
353
|
+
.nav-method.as-colored-block.delete { background-color: var(--red); }
|
|
354
|
+
.nav-method.as-colored-block.head, .nav-method.as-colored-block.patch , .nav-method.as-colored-block.options {
|
|
355
|
+
background-color: var(--yellow);
|
|
356
|
+
}
|
|
357
|
+
|
|
330
358
|
@media only screen and (min-width: 768px) {
|
|
331
359
|
.nav-bar {
|
|
332
360
|
width: 260px;
|
|
@@ -417,7 +445,7 @@ export default class RapiDoc extends LitElement {
|
|
|
417
445
|
this.theme = (window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches) ? 'light' : 'dark';
|
|
418
446
|
}
|
|
419
447
|
if (!this.defaultSchemaTab || !'example, schema, model,'.includes(`${this.defaultSchemaTab},`)) {
|
|
420
|
-
this.defaultSchemaTab = '
|
|
448
|
+
this.defaultSchemaTab = 'example';
|
|
421
449
|
} else if (this.defaultSchemaTab === 'model') {
|
|
422
450
|
this.defaultSchemaTab = 'schema';
|
|
423
451
|
}
|
|
@@ -435,6 +463,7 @@ export default class RapiDoc extends LitElement {
|
|
|
435
463
|
this.schemaHideReadOnly += ['get', 'head', 'delete', 'options'];
|
|
436
464
|
this.schemaHideWriteOnly = this.schemaHideWriteOnly !== 'never';
|
|
437
465
|
if (!this.fillRequestFieldsWithExample || !'true, false,'.includes(`${this.fillRequestFieldsWithExample},`)) { this.fillRequestFieldsWithExample = 'true'; }
|
|
466
|
+
if (!this.useSummaryToListExamples || !'true, false,'.includes(`${this.useSummaryToListExamples},`)) { this.useSummaryToListExamples = 'false'; }
|
|
438
467
|
if (!this.persistAuth || !'true, false,'.includes(`${this.persistAuth},`)) { this.persistAuth = 'false'; }
|
|
439
468
|
if (!this.onNavTagClick || !'expand-collapse, show-description,'.includes(`${this.onNavTagClick},`)) { this.onNavTagClick = 'expand-collapse'; }
|
|
440
469
|
if (!this.responseAreaHeight) {
|
|
@@ -456,6 +485,7 @@ export default class RapiDoc extends LitElement {
|
|
|
456
485
|
if (!this.generateMissingTags || !'true, false,'.includes(`${this.generateMissingTags},`)) { this.generateMissingTags = 'false'; }
|
|
457
486
|
if (!this.sortEndpointsBy || !'method, path, summary, none,'.includes(`${this.sortEndpointsBy},`)) { this.sortEndpointsBy = 'path'; }
|
|
458
487
|
if (!this.navItemSpacing || !'compact, relaxed, default,'.includes(`${this.navItemSpacing},`)) { this.navItemSpacing = 'default'; }
|
|
488
|
+
if (!this.showMethodInNavBar || !'false, as-plain-text, as-colored-text, as-colored-block,'.includes(`${this.showMethodInNavBar},`)) { this.showMethodInNavBar = 'false'; }
|
|
459
489
|
if (!this.usePathInNavBar || !'true, false,'.includes(`${this.usePathInNavBar},`)) { this.usePathInNavBar = 'false'; }
|
|
460
490
|
if (!this.fontSize || !'default, large, largest,'.includes(`${this.fontSize},`)) { this.fontSize = 'default'; }
|
|
461
491
|
|
|
@@ -472,6 +502,9 @@ export default class RapiDoc extends LitElement {
|
|
|
472
502
|
|
|
473
503
|
if (!this.showAdvancedSearchDialog) { this.showAdvancedSearchDialog = false; }
|
|
474
504
|
|
|
505
|
+
if (!this.cssFile) { this.cssFile = null; }
|
|
506
|
+
if (!this.cssClasses) { this.cssClasses = ''; }
|
|
507
|
+
|
|
475
508
|
marked.setOptions({
|
|
476
509
|
highlight: (code, lang) => {
|
|
477
510
|
if (Prism.languages[lang]) {
|
|
@@ -504,6 +537,11 @@ export default class RapiDoc extends LitElement {
|
|
|
504
537
|
|
|
505
538
|
render() {
|
|
506
539
|
// return render(mainBodyTemplate(this), this.shadowRoot, { eventContext: this });
|
|
540
|
+
const cssLinkEl = document.querySelector(`link[href*="${this.cssFile}"]`);
|
|
541
|
+
// adding custom style for RapiDoc
|
|
542
|
+
if (cssLinkEl) {
|
|
543
|
+
this.shadowRoot.appendChild(cssLinkEl.cloneNode());
|
|
544
|
+
}
|
|
507
545
|
return mainBodyTemplate.call(this);
|
|
508
546
|
}
|
|
509
547
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { css } from 'lit
|
|
1
|
+
import { css } from 'lit';
|
|
2
2
|
|
|
3
3
|
export default css`
|
|
4
4
|
.only-large-screen { display:none; }
|
|
@@ -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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { css } from 'lit
|
|
1
|
+
import { css } from 'lit';
|
|
2
2
|
|
|
3
3
|
export default css`
|
|
4
4
|
.nav-bar {
|
|
@@ -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);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { css } from 'lit
|
|
1
|
+
import { css } from 'lit';
|
|
2
2
|
|
|
3
3
|
export default css`
|
|
4
4
|
|
|
@@ -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);
|