rapidoc 9.3.3 → 9.3.5

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 (48) hide show
  1. package/.github/workflow/words.yaml +22 -0
  2. package/README.md +2 -7
  3. package/dist/index.html +1 -1
  4. package/dist/index.html.gz +0 -0
  5. package/dist/rapidoc-min.js +858 -748
  6. package/dist/rapidoc-min.js.LICENSE.txt +14 -9
  7. package/dist/rapidoc-min.js.LICENSE.txt.gz +0 -0
  8. package/dist/rapidoc-min.js.gz +0 -0
  9. package/dist/rapidoc-min.js.map +1 -1
  10. package/dist/rapidoc-min.js.map.gz +0 -0
  11. package/dist/rapidoc.js +11948 -32008
  12. package/dist/report.html +6 -5
  13. package/index.html +2 -1
  14. package/package.json +25 -24
  15. package/src/components/api-request.js +266 -122
  16. package/src/components/api-response.js +11 -10
  17. package/src/components/json-tree.js +17 -12
  18. package/src/components/schema-table.js +58 -49
  19. package/src/components/schema-tree.js +60 -56
  20. package/src/components/tag-input.js +7 -4
  21. package/src/json-schema-viewer.js +2 -1
  22. package/src/rapidoc-mini.js +1 -1
  23. package/src/rapidoc.js +108 -35
  24. package/src/styles/endpoint-styles.js +1 -1
  25. package/src/styles/info-styles.js +2 -1
  26. package/src/styles/input-styles.js +2 -16
  27. package/src/styles/nav-styles.js +57 -10
  28. package/src/styles/schema-styles.js +27 -15
  29. package/src/styles/tab-styles.js +1 -0
  30. package/src/templates/advance-search-template.js +3 -3
  31. package/src/templates/callback-template.js +3 -3
  32. package/src/templates/code-samples-template.js +1 -0
  33. package/src/templates/components-template.js +3 -5
  34. package/src/templates/endpoint-template.js +39 -26
  35. package/src/templates/expanded-endpoint-template.js +58 -9
  36. package/src/templates/focused-endpoint-template.js +5 -2
  37. package/src/templates/header-template.js +2 -2
  38. package/src/templates/json-schema-viewer-template.js +2 -1
  39. package/src/templates/main-body-template.js +19 -18
  40. package/src/templates/navbar-template.js +99 -82
  41. package/src/templates/overview-template.js +1 -1
  42. package/src/templates/security-scheme-template.js +51 -27
  43. package/src/templates/server-template.js +1 -1
  44. package/src/utils/common-utils.js +2 -2
  45. package/src/utils/schema-utils.js +192 -67
  46. package/src/utils/spec-parser.js +9 -3
  47. package/src/utils/theme.js +9 -3
  48. package/webpack.config.js +2 -1
@@ -41,13 +41,10 @@ export default class SchemaTree extends LitElement {
41
41
  .tree .tr:hover{
42
42
  background-color:var(--hover-color);
43
43
  }
44
- .collapsed-descr .tr {
44
+ .collapsed-all-descr .tr:not(.expanded-descr) {
45
+ overflow: hidden;
45
46
  max-height:calc(var(--font-size-small) + 8px);
46
47
  }
47
- .collapsed-descr .m-markdown-small p {
48
- line-height:calc(var(--font-size-small) + 6px);
49
- }
50
-
51
48
  .tree .key {
52
49
  max-width: 300px;
53
50
  }
@@ -63,7 +60,9 @@ export default class SchemaTree extends LitElement {
63
60
  .tr.expanded:hover + .inside-bracket + .close-bracket {
64
61
  color: var(--primary-color);
65
62
  }
66
-
63
+ .inside-bracket.xxx-of-option {
64
+ border-left: 1px solid transparent;
65
+ }
67
66
  .open-bracket{
68
67
  display:inline-block;
69
68
  padding: 0 20px 0 0;
@@ -82,17 +81,12 @@ export default class SchemaTree extends LitElement {
82
81
  }
83
82
  .tr.collapsed + .inside-bracket,
84
83
  .tr.collapsed + .inside-bracket + .close-bracket{
84
+ overflow: hidden;
85
85
  display:none;
86
86
  }
87
87
  .inside-bracket.object,
88
88
  .inside-bracket.array {
89
89
  border-left: 1px dotted var(--border-color);
90
- }
91
- .inside-bracket.xxx-of {
92
- padding:5px 0px;
93
- border-style: dotted;
94
- border-width: 0 0 1px 0;
95
- border-color:var(--primary-color);
96
90
  }`,
97
91
  CustomStyles,
98
92
  ];
@@ -101,23 +95,19 @@ export default class SchemaTree extends LitElement {
101
95
  /* eslint-disable indent */
102
96
  render() {
103
97
  return html`
104
- <div class="tree ${this.schemaDescriptionExpanded === 'true' ? 'expanded-descr' : 'collapsed-descr'}">
98
+ <div class="tree ${this.schemaDescriptionExpanded === 'true' ? 'expanded-all-descr' : 'collapsed-all-descr'}" @click="${(e) => this.handleAllEvents(e)}">
105
99
  <div class="toolbar">
106
100
  <div class="toolbar-item schema-root-type ${this.data?.['::type'] || ''} "> ${this.data?.['::type'] || ''} </div>
107
101
  ${this.allowSchemaDescriptionExpandToggle === 'true'
108
102
  ? html`
109
103
  <div style="flex:1"></div>
110
- <div part="schema-toolbar-item schema-multiline-toggle" class='toolbar-item' @click='${() => { this.schemaDescriptionExpanded = (this.schemaDescriptionExpanded === 'true' ? 'false' : 'true'); }}'>
104
+ <div part="schema-toolbar-item schema-multiline-toggle" class='toolbar-item schema-multiline-toggle'>
111
105
  ${this.schemaDescriptionExpanded === 'true' ? 'Single line description' : 'Multiline description'}
112
- </div>
113
- `
106
+ </div>`
114
107
  : ''
115
108
  }
116
109
  </div>
117
- ${this.data?.['::description']
118
- ? html`<span part="schema-description" class='m-markdown'> ${unsafeHTML(marked(this.data['::description'] || ''))}</span>`
119
- : ''
120
- }
110
+ <span part="schema-description" class='m-markdown'> ${unsafeHTML(marked(this.data?.['::description'] || ''))}</span>
121
111
  ${this.data
122
112
  ? html`
123
113
  ${this.generateTree(
@@ -138,7 +128,7 @@ export default class SchemaTree extends LitElement {
138
128
  return;
139
129
  }
140
130
  }
141
- if (data && data['::readwrite'] === 'readonly') {
131
+ if (data?.['::readwrite'] === 'readonly') {
142
132
  return;
143
133
  }
144
134
  }
@@ -148,7 +138,7 @@ export default class SchemaTree extends LitElement {
148
138
  return;
149
139
  }
150
140
  }
151
- if (data && data['::readwrite'] === 'writeonly') {
141
+ if (data?.['::readwrite'] === 'writeonly') {
152
142
  return;
153
143
  }
154
144
  }
@@ -174,8 +164,7 @@ export default class SchemaTree extends LitElement {
174
164
  keyLabel = key.replace('::', '').replace('~', ' ');
175
165
  } else if (key.startsWith('::OPTION')) {
176
166
  const parts = key.split('~');
177
- keyLabel = parts[1]; // eslint-disable-line prefer-destructuring
178
- keyDescr = parts[2]; // eslint-disable-line prefer-destructuring
167
+ [, keyLabel, keyDescr] = parts;
179
168
  } else {
180
169
  keyLabel = key;
181
170
  }
@@ -190,16 +179,16 @@ export default class SchemaTree extends LitElement {
190
179
  if (data['::type'] === 'object') {
191
180
  if (dataType === 'array') {
192
181
  if (schemaLevel < this.schemaExpandLevel) {
193
- openBracket = html`<span class="open-bracket array-of-object" @click="${this.toggleObjectExpand}">[{</span>`;
182
+ openBracket = html`<span class="open-bracket array-of-object" >[{</span>`;
194
183
  } else {
195
- openBracket = html`<span class="open-bracket array-of-object" @click="${this.toggleObjectExpand}">[{...}]</span>`;
184
+ openBracket = html`<span class="open-bracket array-of-object">[{...}]</span>`;
196
185
  }
197
186
  closeBracket = '}]';
198
187
  } else {
199
188
  if (schemaLevel < this.schemaExpandLevel) {
200
- openBracket = html`<span class="open-bracket object" @click="${this.toggleObjectExpand}">{</span>`;
189
+ openBracket = html`<span class="open-bracket object">${data['::nullable'] ? 'null┃' : ''}{</span>`;
201
190
  } else {
202
- openBracket = html`<span class="open-bracket object" @click="${this.toggleObjectExpand}">{...}</span>`;
191
+ openBracket = html`<span class="open-bracket object">${data['::nullable'] ? 'null┃' : ''}{...}</span>`;
203
192
  }
204
193
  closeBracket = '}';
205
194
  }
@@ -207,23 +196,23 @@ export default class SchemaTree extends LitElement {
207
196
  if (dataType === 'array') {
208
197
  const arrType = arrayType !== 'object' ? arrayType : '';
209
198
  if (schemaLevel < this.schemaExpandLevel) {
210
- openBracket = html`<span class="open-bracket array-of-array" data-array-type="${arrType}" @click="${this.toggleObjectExpand}">[[ ${arrType} </span>`;
199
+ openBracket = html`<span class="open-bracket array-of-array" data-array-type="${arrType}">[[ ${arrType} </span>`;
211
200
  } else {
212
- openBracket = html`<span class="open-bracket array-of-array" data-array-type="${arrType}" @click="${this.toggleObjectExpand}">[[...]]</span>`;
201
+ openBracket = html`<span class="open-bracket array-of-array" data-array-type="${arrType}">[[...]]</span>`;
213
202
  }
214
203
  closeBracket = ']]';
215
204
  } else {
216
205
  if (schemaLevel < this.schemaExpandLevel) {
217
- openBracket = html`<span class="open-bracket array" @click="${this.toggleObjectExpand}">[</span>`;
206
+ openBracket = html`<span class="open-bracket array">[</span>`;
218
207
  } else {
219
- openBracket = html`<span class="open-bracket array" @click="${this.toggleObjectExpand}">[...]</span>`;
208
+ openBracket = html`<span class="open-bracket array">[...]</span>`;
220
209
  }
221
210
  closeBracket = ']';
222
211
  }
223
212
  }
224
213
  if (typeof data === 'object') {
225
214
  return html`
226
- <div class="tr ${schemaLevel < this.schemaExpandLevel || data['::type']?.startsWith('xxx-of') ? 'expanded' : 'collapsed'} ${data['::type'] || 'no-type-info'}" title="${data['::deprecated'] ? 'Deprecated' : ''}">
215
+ <div class="tr ${schemaLevel < this.schemaExpandLevel || data['::type']?.startsWith('xxx-of') ? 'expanded' : 'collapsed'} ${data['::type'] || 'no-type-info'}${data['::nullable'] ? ' nullable' : ''}" title="${data['::deprecated'] ? 'Deprecated' : ''}">
227
216
  <div class="td key ${data['::deprecated'] ? 'deprecated' : ''}" style='min-width:${minFieldColWidth}px'>
228
217
  ${data['::type'] === 'xxx-of-option' || data['::type'] === 'xxx-of-array' || key.startsWith('::OPTION')
229
218
  ? html`<span class='key-label xxx-of-key'> ${keyLabel}</span><span class="xxx-of-descr">${keyDescr}</span>`
@@ -236,7 +225,6 @@ export default class SchemaTree extends LitElement {
236
225
  </span>`
237
226
  : ''
238
227
  }
239
- ${data['::type'] === 'xxx-of' && dataType === 'array' ? html`<span style="color:var(--primary-color)">ARRAY</span>` : ''}
240
228
  ${openBracket}
241
229
  </div>
242
230
  <div class='td key-descr m-markdown-small'>${unsafeHTML(marked(description || ''))}</div>
@@ -246,7 +234,7 @@ export default class SchemaTree extends LitElement {
246
234
  ? html`${this.generateTree(data[0], 'xxx-of-option', '', '::ARRAY~OF', '', newSchemaLevel, newIndentLevel, data[0]['::readwrite'])}`
247
235
  : html`
248
236
  ${Object.keys(data).map((dataKey) => html`
249
- ${['::title', '::description', '::type', '::props', '::deprecated', '::array-type', '::readwrite', '::dataTypeLabel'].includes(dataKey)
237
+ ${['::title', '::description', '::type', '::props', '::deprecated', '::array-type', '::readwrite', '::dataTypeLabel', '::nullable'].includes(dataKey)
250
238
  ? data[dataKey]['::type'] === 'array' || data[dataKey]['::type'] === 'object'
251
239
  ? html`${this.generateTree(
252
240
  data[dataKey]['::type'] === 'array' ? data[dataKey]['::props'] : data[dataKey],
@@ -264,7 +252,7 @@ export default class SchemaTree extends LitElement {
264
252
  data[dataKey]['::type'],
265
253
  data[dataKey]['::array-type'] || '',
266
254
  dataKey,
267
- data[dataKey]['::description'],
255
+ data[dataKey]?.['::description'] || '',
268
256
  newSchemaLevel,
269
257
  newIndentLevel,
270
258
  data[dataKey]['::readwrite'] ? data[dataKey]['::readwrite'] : '',
@@ -282,6 +270,7 @@ export default class SchemaTree extends LitElement {
282
270
  }
283
271
 
284
272
  // For Primitive types and array of Primitives
273
+ // eslint-disable-next-line no-unused-vars
285
274
  const [type, primitiveReadOrWrite, constraint, defaultValue, allowedValues, pattern, schemaDescription, schemaTitle, deprecated] = data.split('~|~');
286
275
  if (primitiveReadOrWrite === '🆁' && this.schemaHideReadOnly === 'true') {
287
276
  return;
@@ -290,7 +279,7 @@ export default class SchemaTree extends LitElement {
290
279
  return;
291
280
  }
292
281
  const dataTypeCss = type.replace(/┃.*/g, '').replace(/[^a-zA-Z0-9+]/g, '').substring(0, 4).toLowerCase();
293
-
282
+ const descrExpander = `${constraint || defaultValue || allowedValues || pattern ? `<span class="descr-expand-toggle ${this.schemaDescriptionExpanded === 'true' ? 'expanded-descr' : ''}">➔</span>` : ''}`;
294
283
  let finalReadWriteText = '';
295
284
  let finalReadWriteTip = '';
296
285
  if (dataType === 'array') {
@@ -302,12 +291,12 @@ export default class SchemaTree extends LitElement {
302
291
  finalReadWriteTip = 'Write-Only';
303
292
  }
304
293
  } else if (primitiveReadOrWrite === '🆁') {
305
- finalReadWriteText = '🆁';
306
- finalReadWriteTip = 'Read-Only';
307
- } else if (primitiveReadOrWrite === '🆆') {
308
- finalReadWriteText = '🆆';
309
- finalReadWriteTip = 'Write-Only';
310
- }
294
+ finalReadWriteText = '🆁';
295
+ finalReadWriteTip = 'Read-Only';
296
+ } else if (primitiveReadOrWrite === '🆆') {
297
+ finalReadWriteText = '🆆';
298
+ finalReadWriteTip = 'Write-Only';
299
+ }
311
300
 
312
301
  return html`
313
302
  <div class = "tr primitive" title="${deprecated ? 'Deprecated' : ''}">
@@ -325,20 +314,20 @@ export default class SchemaTree extends LitElement {
325
314
  </span>
326
315
  </div>
327
316
  <div class='td key-descr'>
328
- ${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>' : ''}`))}
317
+ ${description || schemaTitle || schemaDescription
318
+ ? html`${html`<span class="m-markdown-small">
319
+ ${unsafeHTML(marked(dataType === 'array'
320
+ ? `${descrExpander} ${description}`
321
+ : schemaTitle
322
+ ? `${descrExpander} <b>${schemaTitle}:</b> ${schemaDescription}`
323
+ : `${descrExpander} ${schemaDescription}`))}
332
324
  </span>`
333
- : schemaTitle
334
- ? html`${schemaTitle} ${constraint || defaultValue || allowedValues || pattern
335
- ? html`<span class="more-content">⤵</span>`
336
- : ''}`
337
- : ''
338
- }
325
+ }`
326
+ : ''
327
+ }
339
328
  ${constraint ? html`<div style='display:inline-block; line-break:anywhere; margin-right:8px'><span class='bold-text'>Constraints: </span>${constraint}</div>` : ''}
340
329
  ${defaultValue ? html`<div style='display:inline-block; line-break:anywhere; margin-right:8px'><span class='bold-text'>Default: </span>${defaultValue}</div>` : ''}
341
- ${allowedValues ? html`<div style='display:inline-block; line-break:anywhere; margin-right:8px'><span class='bold-text'>Allowed: </span>${allowedValues}</div>` : ''}
330
+ ${allowedValues ? html`<div style='display:inline-block; line-break:anywhere; margin-right:8px'><span class='bold-text'>${type === 'const' ? 'Value' : 'Allowed'}: </span>${allowedValues}</div>` : ''}
342
331
  ${pattern ? html`<div style='display:inline-block; line-break: anywhere; margin-right:8px'><span class='bold-text'>Pattern: </span>${pattern}</div>` : ''}
343
332
  </div>
344
333
  </div>
@@ -346,8 +335,23 @@ export default class SchemaTree extends LitElement {
346
335
  }
347
336
  /* eslint-enable indent */
348
337
 
338
+ handleAllEvents(e) {
339
+ if (e.target.classList.contains('open-bracket')) {
340
+ this.toggleObjectExpand(e);
341
+ } else if (e.target.classList.contains('schema-multiline-toggle')) {
342
+ this.schemaDescriptionExpanded = (this.schemaDescriptionExpanded === 'true' ? 'false' : 'true');
343
+ } else if (e.target.classList.contains('descr-expand-toggle')) {
344
+ const trEl = e.target.closest('.tr');
345
+ if (trEl) {
346
+ trEl.classList.toggle('expanded-descr');
347
+ trEl.style.maxHeight = trEl.scrollHeight;
348
+ }
349
+ }
350
+ }
351
+
349
352
  toggleObjectExpand(e) {
350
353
  const rowEl = e.target.closest('.tr');
354
+ const nullable = rowEl.classList.contains('nullable');
351
355
  if (rowEl.classList.contains('expanded')) {
352
356
  rowEl.classList.replace('expanded', 'collapsed');
353
357
  e.target.innerHTML = e.target.classList.contains('array-of-object')
@@ -356,7 +360,7 @@ export default class SchemaTree extends LitElement {
356
360
  ? '[[...]]'
357
361
  : e.target.classList.contains('array')
358
362
  ? '[...]'
359
- : '{...}';
363
+ : `${nullable ? 'null┃' : ''}{...}`;
360
364
  } else {
361
365
  rowEl.classList.replace('collapsed', 'expanded');
362
366
  e.target.innerHTML = e.target.classList.contains('array-of-object')
@@ -364,7 +368,7 @@ export default class SchemaTree extends LitElement {
364
368
  : e.target.classList.contains('array-of-array')
365
369
  ? `[[ ${e.target.dataset.arrayType}`
366
370
  : e.target.classList.contains('object')
367
- ? '{'
371
+ ? `${nullable ? 'null┃' : ''}{`
368
372
  : '[';
369
373
  }
370
374
  }
@@ -6,12 +6,12 @@ export default class TagInput extends LitElement {
6
6
  let tagItemTmpl = '';
7
7
  if (Array.isArray(this.value)) {
8
8
  tagItemTmpl = html`${this.value
9
- .filter((v) => v.trim() !== '')
9
+ .filter((v) => typeof v === 'string' && v.trim() !== '')
10
10
  .map((v) => html`<span class='tag'>${v}</span>`)
11
11
  }`;
12
12
  }
13
13
  return html`
14
- <div class='tags' tabindex="0">
14
+ <div class='tags'>
15
15
  ${tagItemTmpl}
16
16
  <input type="text" class='editor' @paste="${(e) => this.afterPaste(e)}" @keydown="${this.afterKeyDown}" @blur="${this.onBlur}" placeholder="${this.placeholder || ''}">
17
17
  </div>
@@ -84,7 +84,7 @@ export default class TagInput extends LitElement {
84
84
 
85
85
  static get styles() {
86
86
  return [css`
87
- .tags{
87
+ .tags {
88
88
  display:flex;
89
89
  flex-wrap: wrap;
90
90
  outline: none;
@@ -110,7 +110,7 @@ export default class TagInput extends LitElement {
110
110
  .tag:hover ~ #cursor {
111
111
  display: block;
112
112
  }
113
- .editor{
113
+ .editor {
114
114
  flex:1;
115
115
  border:1px solid transparent;
116
116
  color:var(--fg);
@@ -121,6 +121,9 @@ export default class TagInput extends LitElement {
121
121
  background:transparent;
122
122
  font-size: calc(var(--font-size-small) + 1px);
123
123
  }
124
+ .editor:focus-visible {
125
+ outline: 1px solid;
126
+ }
124
127
  .editor::placeholder {
125
128
  color: var(--placeholder-color);
126
129
  opacity:1;
@@ -259,7 +259,7 @@ export default class JsonSchemaViewer extends LitElement {
259
259
  super.attributeChangedCallback(name, oldVal, newVal);
260
260
  }
261
261
 
262
- onSepcUrlChange() {
262
+ onSpecUrlChange() {
263
263
  this.setAttribute('spec-url', this.shadowRoot.getElementById('spec-url').value);
264
264
  }
265
265
 
@@ -287,6 +287,7 @@ export default class JsonSchemaViewer extends LitElement {
287
287
  specUrl,
288
288
  this.generateMissingTags === 'true',
289
289
  this.sortTags === 'true',
290
+ this.sortSchemas === 'true',
290
291
  this.getAttribute('sort-endpoints-by'),
291
292
  );
292
293
  this.loading = false;
@@ -264,7 +264,7 @@ export default class RapiDocMini extends LitElement {
264
264
  super.attributeChangedCallback(name, oldVal, newVal);
265
265
  }
266
266
 
267
- onSepcUrlChange() {
267
+ onSpecUrlChange() {
268
268
  this.setAttribute('spec-url', this.shadowRoot.getElementById('spec-url').value);
269
269
  }
270
270