rapidoc 9.3.7 → 10.0.0

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.
Files changed (69) hide show
  1. package/README.md +193 -61
  2. package/dist/rapidoc-min.js +279 -3912
  3. package/package.json +24 -47
  4. package/.babelrc.json +0 -42
  5. package/.eslintrc +0 -53
  6. package/.github/FUNDING.yml +0 -13
  7. package/.github/workflow/words.yaml +0 -22
  8. package/CONTRIBUTING.md +0 -35
  9. package/dist/index.html +0 -6
  10. package/dist/index.html.gz +0 -0
  11. package/dist/rapidoc-min.js.LICENSE.txt +0 -64
  12. package/dist/rapidoc-min.js.LICENSE.txt.gz +0 -0
  13. package/dist/rapidoc-min.js.gz +0 -0
  14. package/dist/rapidoc-min.js.map +0 -1
  15. package/dist/rapidoc-min.js.map.gz +0 -0
  16. package/dist/rapidoc.js +0 -21594
  17. package/dist/report.html +0 -39
  18. package/index-hashroute.html +0 -65
  19. package/index.html +0 -249
  20. package/index1.html +0 -244
  21. package/jsconfig.json +0 -11
  22. package/logo.png +0 -0
  23. package/performance.html +0 -31
  24. package/src/components/api-request.js +0 -1787
  25. package/src/components/api-response.js +0 -335
  26. package/src/components/dialog-box.js +0 -73
  27. package/src/components/json-tree.js +0 -145
  28. package/src/components/schema-table.js +0 -358
  29. package/src/components/schema-tree.js +0 -378
  30. package/src/components/tag-input.js +0 -135
  31. package/src/index.js +0 -7
  32. package/src/json-schema-viewer.js +0 -345
  33. package/src/oauth-receiver.js +0 -56
  34. package/src/rapidoc-mini.js +0 -380
  35. package/src/rapidoc.js +0 -1082
  36. package/src/styles/border-styles.js +0 -24
  37. package/src/styles/custom-styles.js +0 -10
  38. package/src/styles/dialog-box-styles.js +0 -75
  39. package/src/styles/endpoint-styles.js +0 -202
  40. package/src/styles/flex-styles.js +0 -15
  41. package/src/styles/font-styles.js +0 -268
  42. package/src/styles/info-styles.js +0 -21
  43. package/src/styles/input-styles.js +0 -202
  44. package/src/styles/nav-styles.js +0 -198
  45. package/src/styles/prism-styles.js +0 -105
  46. package/src/styles/schema-styles.js +0 -121
  47. package/src/styles/tab-styles.js +0 -47
  48. package/src/styles/table-styles.js +0 -58
  49. package/src/templates/advance-search-template.js +0 -72
  50. package/src/templates/callback-template.js +0 -73
  51. package/src/templates/code-samples-template.js +0 -34
  52. package/src/templates/components-template.js +0 -76
  53. package/src/templates/endpoint-template.js +0 -249
  54. package/src/templates/expanded-endpoint-template.js +0 -197
  55. package/src/templates/focused-endpoint-template.js +0 -110
  56. package/src/templates/header-template.js +0 -66
  57. package/src/templates/json-schema-viewer-template.js +0 -185
  58. package/src/templates/logo-template.js +0 -18
  59. package/src/templates/main-body-template.js +0 -121
  60. package/src/templates/navbar-template.js +0 -272
  61. package/src/templates/overview-template.js +0 -79
  62. package/src/templates/security-scheme-template.js +0 -610
  63. package/src/templates/server-template.js +0 -115
  64. package/src/utils/color-utils.js +0 -59
  65. package/src/utils/common-utils.js +0 -168
  66. package/src/utils/schema-utils.js +0 -1086
  67. package/src/utils/spec-parser.js +0 -462
  68. package/src/utils/theme.js +0 -288
  69. package/webpack.config.js +0 -142
@@ -1,358 +0,0 @@
1
- import { LitElement, html, css } from 'lit';
2
- import { unsafeHTML } from 'lit/directives/unsafe-html.js'; // eslint-disable-line import/extensions
3
- import { marked } from 'marked';
4
- import FontStyles from '~/styles/font-styles';
5
- import SchemaStyles from '~/styles/schema-styles';
6
- import CustomStyles from '~/styles/custom-styles';
7
-
8
- export default class SchemaTable extends LitElement {
9
- static get properties() {
10
- return {
11
- schemaExpandLevel: { type: Number, attribute: 'schema-expand-level' },
12
- schemaDescriptionExpanded: { type: String, attribute: 'schema-description-expanded' },
13
- allowSchemaDescriptionExpandToggle: { type: String, attribute: 'allow-schema-description-expand-toggle' },
14
- schemaHideReadOnly: { type: String, attribute: 'schema-hide-read-only' },
15
- schemaHideWriteOnly: { type: String, attribute: 'schema-hide-write-only' },
16
- data: { type: Object },
17
- };
18
- }
19
-
20
- connectedCallback() {
21
- super.connectedCallback();
22
- if (!this.schemaExpandLevel || this.schemaExpandLevel < 1) { this.schemaExpandLevel = 99999; }
23
- if (!this.schemaDescriptionExpanded || !'true false'.includes(this.schemaDescriptionExpanded)) { this.schemaDescriptionExpanded = 'false'; }
24
- if (!this.schemaHideReadOnly || !'true false'.includes(this.schemaHideReadOnly)) { this.schemaHideReadOnly = 'true'; }
25
- if (!this.schemaHideWriteOnly || !'true false'.includes(this.schemaHideWriteOnly)) { this.schemaHideWriteOnly = 'true'; }
26
- }
27
-
28
- static get styles() {
29
- return [
30
- FontStyles,
31
- SchemaStyles,
32
- css`
33
- .table {
34
- font-size: var(--font-size-small);
35
- text-align: left;
36
- line-height: calc(var(--font-size-small) + 6px);
37
- }
38
- .table .tr {
39
- width: calc(100% - 5px);
40
- padding: 0 0 0 5px;
41
- border-bottom: 1px dotted var(--light-border-color);
42
- }
43
- .table .td {
44
- padding: 4px 0;
45
- }
46
- .table .key {
47
- width: 240px;
48
- }
49
- .key .key-label {
50
- font-size: var(--font-size-mono);
51
- }
52
- .key.deprecated .key-label {
53
- color: var(--red);
54
- }
55
-
56
- .table .key-type {
57
- white-space: normal;
58
- width: 150px;
59
- }
60
- .collapsed-all-descr .tr:not(.expanded-descr) {
61
- max-height: calc(var(--font-size-small) + var(--font-size-small));
62
- }
63
-
64
- .obj-toggle {
65
- padding: 0 2px;
66
- border-radius:2px;
67
- border: 1px solid transparent;
68
- display: inline-block;
69
- margin-left: -16px;
70
- color:var(--primary-color);
71
- cursor:pointer;
72
- font-size: calc(var(--font-size-small) + 4px);
73
- font-family: var(--font-mono);
74
- background-clip: border-box;
75
- }
76
- .obj-toggle:hover {
77
- border-color: var(--primary-color);
78
- }
79
- .tr.expanded + .object-body {
80
- display:block;
81
- }
82
- .tr.collapsed + .object-body {
83
- display:none;
84
- }`,
85
- CustomStyles,
86
- ];
87
- }
88
-
89
- /* eslint-disable indent */
90
- render() {
91
- return html`
92
- <div class="table ${this.schemaDescriptionExpanded === 'true' ? 'expanded-all-descr' : 'collapsed-all-descr'}" @click="${(e) => this.handleAllEvents(e)}">
93
- <div class='toolbar'>
94
- <div class="toolbar-item schema-root-type ${this.data?.['::type'] || ''} "> ${this.data?.['::type'] || ''} </div>
95
- ${this.allowSchemaDescriptionExpandToggle === 'true'
96
- ? html`
97
- <div style="flex:1"></div>
98
- <div part="schema-multiline-toggle" class='toolbar-item schema-multiline-toggle' >
99
- ${this.schemaDescriptionExpanded === 'true' ? 'Single line description' : 'Multiline description'}
100
- </div>
101
- `
102
- : ''
103
- }
104
- </div>
105
- <span part="schema-description" class='m-markdown'> ${unsafeHTML(marked(this.data?.['::description'] || ''))} </span>
106
- <div style = 'border:1px solid var(--light-border-color)'>
107
- <div style='display:flex; background-color: var(--bg2); padding:8px 4px; border-bottom:1px solid var(--light-border-color);'>
108
- <div class='key' style='font-family:var(--font-regular); font-weight:bold; color:var(--fg);'> Field </div>
109
- <div class='key-type' style='font-family:var(--font-regular); font-weight:bold; color:var(--fg);'> Type </div>
110
- <div class='key-descr' style='font-family:var(--font-regular); font-weight:bold; color:var(--fg);'> Description </div>
111
- </div>
112
- ${this.data
113
- ? html`
114
- ${this.generateTree(
115
- this.data['::type'] === 'array' ? this.data['::props'] : this.data,
116
- this.data['::type'],
117
- this.data['::array-type'],
118
- )}`
119
- : ''
120
- }
121
- </div>
122
- </div>
123
- `;
124
- }
125
-
126
- generateTree(data, dataType = 'object', arrayType = '', key = '', description = '', schemaLevel = 0, indentLevel = 0, readOrWrite = '', isDeprecated = false) {
127
- if (this.schemaHideReadOnly === 'true') {
128
- if (dataType === 'array') {
129
- if (readOrWrite === 'readonly') {
130
- return;
131
- }
132
- }
133
- if (data && data['::readwrite'] === 'readonly') {
134
- return;
135
- }
136
- }
137
- if (this.schemaHideWriteOnly === 'true') {
138
- if (dataType === 'array') {
139
- if (readOrWrite === 'writeonly') {
140
- return;
141
- }
142
- }
143
- if (data && data['::readwrite'] === 'writeonly') {
144
- return;
145
- }
146
- }
147
- if (!data) {
148
- return html`<div class="null" style="display:inline;">
149
- <span style='margin-left:${(schemaLevel + 1) * 16}px'> &nbsp; </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
- }
160
-
161
- const newSchemaLevel = data['::type']?.startsWith('xxx-of') ? schemaLevel : (schemaLevel + 1);
162
- const newIndentLevel = dataType === 'xxx-of-option' || data['::type'] === 'xxx-of-option' || key.startsWith('::OPTION') ? indentLevel : (indentLevel + 1);
163
- const leftPadding = 16 * newIndentLevel; // 2 space indentation at each level
164
- if (Object.keys(data).length === 0) {
165
- return html`<span class="td key object" style='padding-left:${leftPadding}px'>${key}</span>`;
166
- }
167
- let keyLabel = '';
168
- let keyDescr = '';
169
- let isOneOfLabel = false;
170
- if (key.startsWith('::ONE~OF') || key.startsWith('::ANY~OF')) {
171
- keyLabel = key.replace('::', '').replace('~', ' ');
172
- isOneOfLabel = true;
173
- } else if (key.startsWith('::OPTION')) {
174
- const parts = key.split('~');
175
- keyLabel = parts[1]; // eslint-disable-line prefer-destructuring
176
- keyDescr = parts[2]; // eslint-disable-line prefer-destructuring
177
- } else {
178
- keyLabel = key;
179
- }
180
-
181
- let detailObjType = '';
182
- if (data['::type'] === 'object') {
183
- if (dataType === 'array') {
184
- detailObjType = 'array of object'; // Array of Object
185
- } else {
186
- detailObjType = data['::dataTypeLabel'] || data['::type'];
187
- }
188
- } else if (data['::type'] === 'array') {
189
- if (dataType === 'array') {
190
- // detailObjType = 'array of array'; // Array of array
191
- detailObjType = `array of array ${arrayType !== 'object' ? `of ${arrayType}` : ''}`; // Array of array
192
- } else {
193
- detailObjType = data['::dataTypeLabel'] || data['::type'];
194
- }
195
- }
196
-
197
- if (typeof data === 'object') {
198
- return html`
199
- ${newSchemaLevel >= 0 && key
200
- ? html`
201
- <div class='tr ${newSchemaLevel <= this.schemaExpandLevel ? 'expanded' : 'collapsed'} ${data['::type']}' data-obj='${keyLabel}' title="${isDeprecated || data['::deprecated'] ? 'Deprecated' : ''}">
202
- <div class="td key ${(isDeprecated || data['::deprecated']) ? 'deprecated' : ''}" style='padding-left:${leftPadding}px'>
203
- ${(keyLabel || keyDescr)
204
- ? html`
205
- <span class='obj-toggle ${newSchemaLevel < this.schemaExpandLevel ? 'expanded' : 'collapsed'}' data-obj='${keyLabel}'>
206
- ${schemaLevel < this.schemaExpandLevel ? '-' : '+'}
207
- </span>`
208
- : ''
209
- }
210
- ${data['::type'] === 'xxx-of-option' || data['::type'] === 'xxx-of-array' || key.startsWith('::OPTION')
211
- ? html`<span class="xxx-of-key" style="margin-left:-6px">${keyLabel}</span><span class="${isOneOfLabel ? 'xxx-of-key' : 'xxx-of-descr'}">${keyDescr}</span>`
212
- : keyLabel.endsWith('*')
213
- ? html`<span class="key-label" style="display:inline-block; margin-left:-6px;">${(isDeprecated || data['::deprecated']) ? '✗' : ''} ${keyLabel.substring(0, keyLabel.length - 1)}</span><span style='color:var(--red);'>*</span>`
214
- : html`<span class="key-label" style="display:inline-block; margin-left:-6px;">${(isDeprecated || data['::deprecated']) ? '✗' : ''} ${keyLabel === '::props' ? '' : keyLabel}</span>`
215
- }
216
- ${data['::type'] === 'xxx-of' && dataType === 'array' ? html`<span style="color:var(--primary-color)">ARRAY</span>` : ''}
217
- </div>
218
- <div class='td key-type' title="${data['::readwrite'] === 'readonly' ? 'Read-Only' : data['::readwrite'] === 'writeonly' ? 'Write-Only' : ''}">
219
- ${(data['::type'] || '').includes('xxx-of') ? '' : detailObjType}
220
- ${data['::readwrite'] === 'readonly' ? ' 🆁' : data['::readwrite'] === 'writeonly' ? ' 🆆' : ''}
221
- </div>
222
- <div class='td key-descr m-markdown-small' style='line-height:1.7'>${unsafeHTML(marked(description || ''))}</div>
223
- </div>`
224
- : html`
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
- }`
236
- }
237
- <div class='object-body'>
238
- ${Array.isArray(data) && data[0]
239
- ? html`${this.generateTree(data[0], 'xxx-of-option', '', '::ARRAY~OF', '', newSchemaLevel, newIndentLevel, '')}`
240
- : html`
241
- ${Object.keys(data).map((dataKey) => html`
242
- ${['::title', '::description', '::type', '::props', '::deprecated', '::array-type', '::readwrite', '::dataTypeLabel', '::nullable'].includes(dataKey)
243
- ? data[dataKey]['::type'] === 'array' || data[dataKey]['::type'] === 'object'
244
- ? html`${this.generateTree(
245
- data[dataKey]['::type'] === 'array' ? data[dataKey]['::props'] : data[dataKey],
246
- data[dataKey]['::type'],
247
- data[dataKey]['::array-type'] || '',
248
- dataKey,
249
- data[dataKey]['::description'],
250
- newSchemaLevel,
251
- newIndentLevel,
252
- data[dataKey]['::readwrite'] ? data[dataKey]['::readwrite'] : '',
253
- (isDeprecated || data[dataKey]['::deprecated']),
254
- )}`
255
- : ''
256
- : html`${this.generateTree(
257
- data[dataKey]['::type'] === 'array' ? data[dataKey]['::props'] : data[dataKey],
258
- data[dataKey]['::type'],
259
- data[dataKey]['::array-type'] || '',
260
- dataKey,
261
- data[dataKey]?.['::description'] || '',
262
- newSchemaLevel,
263
- newIndentLevel,
264
- data[dataKey]['::readwrite'] ? data[dataKey]['::readwrite'] : '',
265
- (isDeprecated || data[dataKey]['::deprecated']),
266
- )}`
267
- }
268
- `)}
269
- `
270
- }
271
- </div>
272
- `;
273
- }
274
-
275
- // For Primitive Data types
276
- // eslint-disable-next-line no-unused-vars
277
- const [type, readOrWriteOnly, constraint, defaultValue, allowedValues, pattern, schemaDescription, schemaTitle, deprecated] = data.split('~|~');
278
- if (readOrWriteOnly === '🆁' && this.schemaHideReadOnly === 'true') {
279
- return;
280
- }
281
- if (readOrWriteOnly === '🆆' && this.schemaHideWriteOnly === 'true') {
282
- return;
283
- }
284
- const dataTypeCss = type.replace(/┃.*/g, '').replace(/[^a-zA-Z0-9+]/g, '').substring(0, 4).toLowerCase();
285
- const descrExpander = `${constraint || defaultValue || allowedValues || pattern ? '<span class="descr-expand-toggle">➔</span>' : ''}`;
286
- let dataTypeHtml = '';
287
- if (dataType === 'array') {
288
- dataTypeHtml = html`
289
- <div class='td key-type ${dataTypeCss}' title="${readOrWrite === 'readonly' ? 'Read-Only' : readOrWriteOnly === 'writeonly' ? 'Write-Only' : ''}">
290
- [${type}] ${readOrWrite === 'readonly' ? '🆁' : readOrWrite === 'writeonly' ? '🆆' : ''}
291
- </div>`;
292
- } else {
293
- dataTypeHtml = html`
294
- <div class='td key-type ${dataTypeCss}' title="${readOrWriteOnly === '🆁' ? 'Read-Only' : readOrWriteOnly === '🆆' ? 'Write-Only' : ''}">
295
- ${type} ${readOrWriteOnly}
296
- </div>`;
297
- }
298
- return html`
299
- <div class = "tr primitive" title="${isDeprecated || deprecated ? 'Deprecated' : ''}">
300
- <div class="td key ${isDeprecated || deprecated ? 'deprecated' : ''}" style='padding-left:${leftPadding}px'>
301
- ${isDeprecated || deprecated ? html`<span style='color:var(--red);'>✗</span>` : ''}
302
- ${keyLabel?.endsWith('*')
303
- ? html`
304
- <span class="key-label">${keyLabel.substring(0, keyLabel.length - 1)}</span>
305
- <span style='color:var(--red);'>*</span>`
306
- : key.startsWith('::OPTION')
307
- ? html`<span class='xxx-of-key'>${keyLabel}</span><span class="xxx-of-descr">${keyDescr}</span>`
308
- : html`${keyLabel ? html`<span class="key-label"> ${keyLabel}</span>` : html`<span class="xxx-of-descr">${schemaTitle}</span>`}`
309
- }
310
- </div>
311
- ${dataTypeHtml}
312
- <div class='td key-descr' style='font-size: var(--font-size-small)'>
313
- ${html`<span class="m-markdown-small">
314
- ${unsafeHTML(marked(dataType === 'array'
315
- ? `${descrExpander} ${description}`
316
- : schemaTitle
317
- ? `${descrExpander} <b>${schemaTitle}:</b> ${schemaDescription}`
318
- : `${descrExpander} ${schemaDescription}`))}
319
- </span>`
320
- }
321
- ${constraint ? html`<div class='' style='display:inline-block; line-break:anywhere; margin-right:8px;'> <span class='bold-text'>Constraints: </span> ${constraint}</div>` : ''}
322
- ${defaultValue ? html`<div style='display:inline-block; line-break:anywhere; margin-right:8px;'> <span class='bold-text'>Default: </span>${defaultValue}</div>` : ''}
323
- ${allowedValues ? html`<div style='display:inline-block; line-break:anywhere; margin-right:8px;'> <span class='bold-text'>${type === 'const' ? 'Value' : 'Allowed'}: </span>${allowedValues}</div>` : ''}
324
- ${pattern ? html`<div style='display:inline-block; line-break:anywhere; margin-right:8px;'> <span class='bold-text'>Pattern: </span>${pattern}</div>` : ''}
325
- </div>
326
- </div>
327
- `;
328
- }
329
- /* eslint-enable indent */
330
-
331
- handleAllEvents(e) {
332
- if (e.target.classList.contains('obj-toggle')) {
333
- this.toggleObjectExpand(e);
334
- } else if (e.target.classList.contains('schema-multiline-toggle')) {
335
- this.schemaDescriptionExpanded = (this.schemaDescriptionExpanded === 'true' ? 'false' : 'true');
336
- } else if (e.target.classList.contains('descr-expand-toggle')) {
337
- const trEl = e.target.closest('.tr');
338
- if (trEl) {
339
- trEl.classList.toggle('expanded-descr');
340
- trEl.style.maxHeight = trEl.scrollHeight;
341
- }
342
- }
343
- }
344
-
345
- toggleObjectExpand(e) {
346
- const rowEl = e.target.closest('.tr');
347
- if (rowEl.classList.contains('expanded')) {
348
- rowEl.classList.add('collapsed');
349
- rowEl.classList.remove('expanded');
350
- e.target.innerText = '+';
351
- } else {
352
- rowEl.classList.remove('collapsed');
353
- rowEl.classList.add('expanded');
354
- e.target.innerText = '-';
355
- }
356
- }
357
- }
358
- customElements.define('schema-table', SchemaTable);