rapidoc 9.1.7 → 9.3.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 (57) hide show
  1. package/.github/FUNDING.yml +13 -0
  2. package/CONTRIBUTING.md +1 -1
  3. package/LICENSE.txt +3 -1
  4. package/README.md +24 -6
  5. package/index.html +6 -4
  6. package/package.json +16 -16
  7. package/src/components/api-request.js +104 -78
  8. package/src/components/api-response.js +11 -8
  9. package/src/components/dialog-box.js +1 -1
  10. package/src/components/json-tree.js +15 -4
  11. package/src/components/schema-table.js +40 -18
  12. package/src/components/schema-tree.js +44 -15
  13. package/src/components/tag-input.js +1 -1
  14. package/src/json-schema-viewer.js +2 -2
  15. package/src/rapidoc-mini.js +27 -2
  16. package/src/rapidoc.js +41 -3
  17. package/src/styles/border-styles.js +1 -1
  18. package/src/styles/custom-styles.js +1 -1
  19. package/src/styles/dialog-box-styles.js +1 -1
  20. package/src/styles/endpoint-styles.js +10 -10
  21. package/src/styles/flex-styles.js +1 -1
  22. package/src/styles/font-styles.js +1 -1
  23. package/src/styles/info-styles.js +1 -1
  24. package/src/styles/input-styles.js +1 -1
  25. package/src/styles/nav-styles.js +4 -2
  26. package/src/styles/prism-styles.js +1 -1
  27. package/src/styles/schema-styles.js +4 -2
  28. package/src/styles/tab-styles.js +2 -1
  29. package/src/styles/table-styles.js +1 -1
  30. package/src/templates/advance-search-template.js +1 -1
  31. package/src/templates/callback-template.js +11 -4
  32. package/src/templates/code-samples-template.js +2 -2
  33. package/src/templates/components-template.js +4 -2
  34. package/src/templates/endpoint-template.js +23 -16
  35. package/src/templates/expanded-endpoint-template.js +77 -71
  36. package/src/templates/focused-endpoint-template.js +2 -2
  37. package/src/templates/header-template.js +2 -2
  38. package/src/templates/json-schema-viewer-template.js +3 -3
  39. package/src/templates/logo-template.js +1 -1
  40. package/src/templates/main-body-template.js +2 -2
  41. package/src/templates/navbar-template.js +22 -9
  42. package/src/templates/overview-template.js +3 -3
  43. package/src/templates/security-scheme-template.js +54 -44
  44. package/src/templates/server-template.js +4 -4
  45. package/src/utils/schema-utils.js +74 -27
  46. package/src/utils/spec-parser.js +1 -1
  47. package/src/utils/theme.js +12 -5
  48. package/webpack.config.js +1 -1
  49. package/.vscode/settings.json +0 -12
  50. package/dist/index.html +0 -6
  51. package/dist/index.html.gz +0 -0
  52. package/dist/rapidoc-min.js +0 -2
  53. package/dist/rapidoc-min.js.LICENSE.txt +0 -87
  54. package/dist/rapidoc-min.js.LICENSE.txt.gz +0 -0
  55. package/dist/rapidoc-min.js.gz +0 -0
  56. package/dist/rapidoc.js +0 -35243
  57. package/dist/report.html +0 -38
@@ -1,10 +1,9 @@
1
- import { LitElement, html, css } from 'lit-element';
1
+ import { LitElement, html, css } from 'lit';
2
+ import { unsafeHTML } from 'lit/directives/unsafe-html.js'; // eslint-disable-line import/extensions
3
+ import { guard } from 'lit/directives/guard.js'; // eslint-disable-line import/extensions
4
+ import { live } from 'lit/directives/live.js'; // eslint-disable-line import/extensions
2
5
  import { marked } from 'marked';
3
6
  import Prism from 'prismjs';
4
-
5
- import { unsafeHTML } from 'lit-html/directives/unsafe-html';
6
- import { guard } from 'lit-html/directives/guard';
7
- import { live } from 'lit-html/directives/live';
8
7
  import TableStyles from '~/styles/table-styles';
9
8
  import FlexStyles from '~/styles/flex-styles';
10
9
  import InputStyles from '~/styles/input-styles';
@@ -53,6 +52,7 @@ export default class ApiRequest extends LitElement {
53
52
  responseStatus: { type: String, attribute: false },
54
53
  responseUrl: { type: String, attribute: false },
55
54
  fillRequestFieldsWithExample: { type: String, attribute: 'fill-request-fields-with-example' },
55
+ useSummaryToListExamples: { type: String, attribute: 'use-summary-to-list-example' },
56
56
  allowTry: { type: String, attribute: 'allow-try' },
57
57
  renderStyle: { type: String, attribute: 'render-style' },
58
58
  schemaStyle: { type: String, attribute: 'schema-style' },
@@ -69,6 +69,7 @@ export default class ApiRequest extends LitElement {
69
69
  schemaDescriptionExpanded: { type: String, attribute: 'schema-description-expanded' },
70
70
  allowSchemaDescriptionExpandToggle: { type: String, attribute: 'allow-schema-description-expand-toggle' },
71
71
  schemaHideReadOnly: { type: String, attribute: 'schema-hide-read-only' },
72
+ schemaHideWriteOnly: { type: String, attribute: 'schema-hide-write-only' },
72
73
  fetchCredentials: { type: String, attribute: 'fetch-credentials' },
73
74
 
74
75
  // properties for internal tracking
@@ -99,12 +100,12 @@ export default class ApiRequest extends LitElement {
99
100
  text-align: right;
100
101
  line-height: var(--font-size-small);
101
102
  }
102
- .param-name{
103
+ .param-name {
103
104
  color: var(--fg);
104
105
  font-family: var(--font-mono);
105
106
  }
106
107
  .param-name.deprecated {
107
- text-decoration: line-through;
108
+ color: var(--red);
108
109
  }
109
110
  .param-type{
110
111
  color: var(--light-fg);
@@ -193,11 +194,11 @@ export default class ApiRequest extends LitElement {
193
194
  ${this.callback === 'true' ? 'CALLBACK REQUEST' : 'REQUEST'}
194
195
  </div>
195
196
  <div>
196
- ${guard([this.parameters, this.activeParameterSchemaTabs], () => this.inputParametersTemplate('path'))}
197
- ${guard([this.parameters, this.activeParameterSchemaTabs], () => this.inputParametersTemplate('query'))}
197
+ ${guard([this.allowTry, this.parameters, this.activeParameterSchemaTabs], () => this.inputParametersTemplate('path'))}
198
+ ${guard([this.allowTry, this.parameters, this.activeParameterSchemaTabs], () => this.inputParametersTemplate('query'))}
198
199
  ${this.requestBodyTemplate()}
199
- ${guard([this.parameters, this.activeParameterSchemaTabs], () => this.inputParametersTemplate('header'))}
200
- ${guard([this.parameters, this.activeParameterSchemaTabs], () => this.inputParametersTemplate('cookie'))}
200
+ ${guard([this.allowTry, this.parameters, this.activeParameterSchemaTabs], () => this.inputParametersTemplate('header'))}
201
+ ${guard([this.allowTry, this.parameters, this.activeParameterSchemaTabs], () => this.inputParametersTemplate('cookie'))}
201
202
  ${this.allowTry === 'false' ? '' : html`${this.apiCallTemplate()}`}
202
203
  </div>
203
204
  </div>
@@ -246,7 +247,12 @@ export default class ApiRequest extends LitElement {
246
247
  }
247
248
  }
248
249
  }"
249
- >${v.value && Array.isArray(v.value) ? (v.value?.join(', ')) : (v.value || '')}</a>
250
+ >
251
+ ${this.useSummaryToListExamples === 'true'
252
+ ? v.description || v.summary || (v.value && Array.isArray(v.value) ? (v.value?.join(', ')) : (v.value || ''))
253
+ : v.value && Array.isArray(v.value) ? (v.value?.join(', ')) : (v.value || '')
254
+ }
255
+ </a>
250
256
  ${paramType === 'array' ? '] ' : ''}
251
257
  `)}
252
258
  `
@@ -317,18 +323,20 @@ export default class ApiRequest extends LitElement {
317
323
  serializeStyle || 'json',
318
324
  '',
319
325
  '',
320
- true,
321
- true,
326
+ !(this.schemaHideReadOnly && (this.schemaHideReadOnly.includes(this.method) || this.schemaHideReadOnly === 'true')),
327
+ !(this.schemaHideWriteOnly && (this.schemaHideWriteOnly.includes(this.method) || this.schemaHideWriteOnly === 'true')),
322
328
  'text',
323
329
  false,
324
330
  )[0].exampleValue;
325
331
  }
326
332
  const labelColWidth = 'read focused'.includes(this.renderStyle) ? '200px' : '160px';
327
333
  tableRows.push(html`
328
- <tr>
334
+ <tr title="${param.deprecated ? 'Deprecated' : ''}">
329
335
  <td rowspan="${this.allowTry === 'true' ? '1' : '2'}" style="width:${labelColWidth}; min-width:100px;">
330
- <div class="param-name">
331
- ${param.required ? html`<span style='color:var(--red)'>*</span>` : ''}${param.name}
336
+ <div class="param-name ${param.deprecated ? 'deprecated' : ''}" >
337
+ ${param.deprecated ? html`<span style='color:var(--red);'>✗</span>` : ''}
338
+ ${param.required ? html`<span style='color:var(--red)'>*</span>` : ''}
339
+ ${param.name}
332
340
  </div>
333
341
  <div class="param-type">
334
342
  ${paramSchema.type === 'array'
@@ -339,7 +347,7 @@ export default class ApiRequest extends LitElement {
339
347
  </td>
340
348
  ${this.allowTry === 'true'
341
349
  ? html`
342
- <td style="min-width:100px;">
350
+ <td style="min-width:100px;" colspan="${paramSchema.default || paramSchema.constrain || paramSchema.allowedValues || paramSchema.pattern ? '1' : '2'}">
343
351
  ${paramSchema.type === 'array'
344
352
  ? html`
345
353
  <tag-input class="request-param"
@@ -365,8 +373,8 @@ export default class ApiRequest extends LitElement {
365
373
  this.activeParameterSchemaTabs = newState;
366
374
  }
367
375
  }}">
368
- <button class="tab-btn ${this.activeParameterSchemaTabs[param.name] !== 'example' ? 'active' : ''}" data-tab = 'schema'>SCHEMA</button>
369
376
  <button class="tab-btn ${this.activeParameterSchemaTabs[param.name] === 'example' ? 'active' : ''}" data-tab = 'example'>EXAMPLE </button>
377
+ <button class="tab-btn ${this.activeParameterSchemaTabs[param.name] !== 'example' ? 'active' : ''}" data-tab = 'schema'>SCHEMA</button>
370
378
  </div>
371
379
  ${this.activeParameterSchemaTabs[param.name] === 'example'
372
380
  ? html`<div class="tab-content col">
@@ -394,7 +402,10 @@ export default class ApiRequest extends LitElement {
394
402
  schema-description-expanded = "${this.schemaDescriptionExpanded}"
395
403
  allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}",
396
404
  schema-hide-read-only = "${this.schemaHideReadOnly.includes(this.method)}"
397
- schema-hide-write-only = "false"
405
+ schema-hide-write-only = "${this.schemaHideWriteOnly.includes(this.method)}"
406
+ 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,
407
+ file-input:file-input, textbox:textbox, textbox-param:textbox-param, textarea:textarea, textarea-param:textarea-param,
408
+ anchor:anchor, anchor-param-example:anchor-param-example"
398
409
  > </schema-tree>
399
410
  </div>`
400
411
  }
@@ -407,16 +418,17 @@ export default class ApiRequest extends LitElement {
407
418
  data-pname="${param.name}"
408
419
  data-example="${Array.isArray(example.exampleVal) ? example.exampleVal.join('~|~') : example.exampleVal}"
409
420
  data-param-allow-reserved = "${paramAllowReserved}"
421
+ data-x-fill-example = "${param['x-fill-example'] || 'yes'}"
410
422
  data-array="false"
411
- .value="${live(this.fillRequestFieldsWithExample === 'true' ? example.exampleVal : '')}"
423
+ .value="${param['x-fill-example'] === 'no' ? '' : live(this.fillRequestFieldsWithExample === 'true' ? example.exampleVal : '')}"
412
424
  />`
413
425
  }
414
426
  </td>`
415
427
  : ''
416
428
  }
417
- <td colspan="${(this.allowTry === 'true') ? '1' : '2'}">
418
- ${paramSchema.default || paramSchema.constrain || paramSchema.allowedValues || paramSchema.pattern
419
- ? html`
429
+ ${paramSchema.default || paramSchema.constrain || paramSchema.allowedValues || paramSchema.pattern
430
+ ? html`
431
+ <td colspan="${(this.allowTry === 'true') ? '1' : '2'}">
420
432
  <div class="param-constraint">
421
433
  ${paramSchema.default ? html`<span style="font-weight:bold">Default: </span>${paramSchema.default}<br/>` : ''}
422
434
  ${paramSchema.pattern ? html`<span style="font-weight:bold">Pattern: </span>${paramSchema.pattern}<br/>` : ''}
@@ -439,14 +451,14 @@ export default class ApiRequest extends LitElement {
439
451
  }}"
440
452
  >${v}</a>`
441
453
  }`)}
442
- </div>`
443
- : ''
444
- }
445
- </td>
454
+ </div>
455
+ </td>`
456
+ : html`<td></td>`
457
+ }
446
458
  </tr>
447
459
  <tr>
448
460
  ${this.allowTry === 'true' ? html`<td style="border:none"> </td>` : ''}
449
- <td colspan="2" style="border:none; margin-top:0; padding:0 5px 8px 5px;">
461
+ <td colspan="2" style="border:none">
450
462
  <span class="m-markdown-small">${unsafeHTML(marked(param.description || ''))}</span>
451
463
  ${this.exampleListTemplate.call(this, param.name, paramSchema.type, example.exampleList)}
452
464
  </td>
@@ -539,7 +551,7 @@ export default class ApiRequest extends LitElement {
539
551
  let schemaAsObj;
540
552
  let reqBodyExamples = [];
541
553
 
542
- if (this.selectedRequestBodyType.includes('json') || this.selectedRequestBodyType.includes('xml') || this.selectedRequestBodyType.includes('text')) {
554
+ if (this.selectedRequestBodyType.includes('json') || this.selectedRequestBodyType.includes('xml') || this.selectedRequestBodyType.includes('text') || this.selectedRequestBodyType.includes('jose')) {
543
555
  // Generate Example
544
556
  if (reqBody.mimeType === this.selectedRequestBodyType) {
545
557
  reqBodyExamples = generateExample(
@@ -547,8 +559,8 @@ export default class ApiRequest extends LitElement {
547
559
  reqBody.mimeType,
548
560
  reqBody.examples,
549
561
  reqBody.example,
550
- false,
551
- true,
562
+ !(this.schemaHideReadOnly && (this.schemaHideReadOnly.includes(this.method) || this.schemaHideReadOnly === 'true')),
563
+ !(this.schemaHideWriteOnly && (this.schemaHideWriteOnly.includes(this.method) || this.schemaHideWriteOnly === 'true')),
552
564
  'text',
553
565
  false,
554
566
  );
@@ -606,8 +618,8 @@ export default class ApiRequest extends LitElement {
606
618
  reqBody.mimeType,
607
619
  reqBody.examples,
608
620
  reqBody.example,
609
- false,
610
- true,
621
+ !(this.schemaHideReadOnly && (this.schemaHideReadOnly.includes(this.method) || this.schemaHideReadOnly === 'true')),
622
+ !(this.schemaHideWriteOnly && (this.schemaHideWriteOnly.includes(this.method) || this.schemaHideWriteOnly === 'true')),
611
623
  'text',
612
624
  false,
613
625
  );
@@ -626,7 +638,7 @@ export default class ApiRequest extends LitElement {
626
638
  }
627
639
 
628
640
  // Generate Schema
629
- if (reqBody.mimeType.includes('json') || reqBody.mimeType.includes('xml') || reqBody.mimeType.includes('text')) {
641
+ if (reqBody.mimeType.includes('json') || reqBody.mimeType.includes('xml') || reqBody.mimeType.includes('text') || this.selectedRequestBodyType.includes('jose')) {
630
642
  schemaAsObj = schemaInObjectNotation(reqBody.schema, {});
631
643
  if (this.schemaStyle === 'table') {
632
644
  reqBodySchemaHtml = html`
@@ -638,8 +650,9 @@ export default class ApiRequest extends LitElement {
638
650
  schema-expand-level = "${this.schemaExpandLevel}"
639
651
  schema-description-expanded = "${this.schemaDescriptionExpanded}"
640
652
  allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}",
641
- schema-hide-read-only = "${this.schemaHideReadOnly.includes(this.method)}"
642
- schema-hide-write-only = "false"
653
+ schema-hide-read-only = "${this.schemaHideReadOnly}"
654
+ schema-hide-write-only = "${this.schemaHideWriteOnly}"
655
+ exportparts = "schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
643
656
  > </schema-table>
644
657
  `;
645
658
  } else if (this.schemaStyle === 'tree') {
@@ -652,8 +665,9 @@ export default class ApiRequest extends LitElement {
652
665
  schema-expand-level = "${this.schemaExpandLevel}"
653
666
  schema-description-expanded = "${this.schemaDescriptionExpanded}"
654
667
  allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}",
655
- schema-hide-read-only = "true"
656
- schema-hide-write-only = "false"
668
+ schema-hide-read-only = "${this.schemaHideReadOnly}"
669
+ schema-hide-write-only = "${this.schemaHideWriteOnly}"
670
+ exportparts = "schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
657
671
  > </schema-tree>
658
672
  `;
659
673
  }
@@ -670,12 +684,12 @@ export default class ApiRequest extends LitElement {
670
684
  </div>
671
685
  ${this.request_body.description ? html`<div class="m-markdown" style="margin-bottom:12px">${unsafeHTML(marked(this.request_body.description))}</div>` : ''}
672
686
 
673
- ${(this.selectedRequestBodyType.includes('json') || this.selectedRequestBodyType.includes('xml') || this.selectedRequestBodyType.includes('text'))
687
+ ${(this.selectedRequestBodyType.includes('json') || this.selectedRequestBodyType.includes('xml') || this.selectedRequestBodyType.includes('text') || this.selectedRequestBodyType.includes('jose'))
674
688
  ? html`
675
689
  <div class="tab-panel col" style="border-width:0 0 1px 0;">
676
690
  <div class="tab-buttons row" @click="${(e) => { if (e.target.tagName.toLowerCase() === 'button') { this.activeSchemaTab = e.target.dataset.tab; } }}">
677
- <button class="tab-btn ${this.activeSchemaTab !== 'example' ? 'active' : ''}" data-tab = 'schema'>SCHEMA</button>
678
691
  <button class="tab-btn ${this.activeSchemaTab === 'example' ? 'active' : ''}" data-tab = 'example'>EXAMPLE</button>
692
+ <button class="tab-btn ${this.activeSchemaTab !== 'example' ? 'active' : ''}" data-tab = 'schema'>SCHEMA</button>
679
693
  </div>
680
694
  ${this.activeSchemaTab === 'example'
681
695
  ? html`<div class="tab-content col"> ${reqBodyExampleHtml}</div>`
@@ -698,8 +712,8 @@ export default class ApiRequest extends LitElement {
698
712
  'json',
699
713
  fieldSchema.examples,
700
714
  fieldSchema.example,
701
- false,
702
- true,
715
+ !(this.schemaHideReadOnly && (this.schemaHideReadOnly.includes(this.method) || this.schemaHideReadOnly === 'true')),
716
+ !(this.schemaHideWriteOnly && (this.schemaHideWriteOnly.includes(this.method) || this.schemaHideWriteOnly === 'true')),
703
717
  'text',
704
718
  false,
705
719
  );
@@ -724,20 +738,10 @@ export default class ApiRequest extends LitElement {
724
738
  }
725
739
  if (e.target.tagName.toLowerCase() === 'button') { this.activeSchemaTab = e.target.dataset.tab; }
726
740
  }}">
727
- <button class="v-tab-btn ${this.activeSchemaTab !== 'example' ? 'active' : ''}" data-tab = 'schema'>SCHEMA</button>
728
741
  <button class="v-tab-btn ${this.activeSchemaTab === 'example' ? 'active' : ''}" data-tab = 'example'>EXAMPLE</button>
742
+ <button class="v-tab-btn ${this.activeSchemaTab !== 'example' ? 'active' : ''}" data-tab = 'schema'>SCHEMA</button>
729
743
  </div>
730
744
  </div>
731
- ${html`
732
- <div class="tab-content col" data-tab = 'schema' style="display:${this.activeSchemaTab !== 'example' ? 'block' : 'none'}; padding-left:5px; width:100%;">
733
- <schema-tree
734
- .data = '${formdataPartSchema}'
735
- schema-expand-level = "${this.schemaExpandLevel}"
736
- schema-description-expanded = "${this.schemaDescriptionExpanded}"
737
- allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}",
738
- > </schema-tree>
739
- </div>`
740
- }
741
745
  ${html`
742
746
  <div class="tab-content col" data-tab = 'example' style="display:${this.activeSchemaTab === 'example' ? 'block' : 'none'}; padding-left:5px; width:100%">
743
747
  <textarea
@@ -755,6 +759,16 @@ export default class ApiRequest extends LitElement {
755
759
  <textarea data-pname = "hidden-${fieldName}" data-ptype = "${mimeType.includes('form-urlencode') ? 'hidden-form-urlencode' : 'hidden-form-data'}" class="is-hidden" style="display:none">${formdataPartExample[0].exampleValue}</textarea>
756
760
  </div>`
757
761
  }
762
+ ${html`
763
+ <div class="tab-content col" data-tab = 'schema' style="display:${this.activeSchemaTab !== 'example' ? 'block' : 'none'}; padding-left:5px; width:100%;">
764
+ <schema-tree
765
+ .data = '${formdataPartSchema}'
766
+ schema-expand-level = "${this.schemaExpandLevel}"
767
+ schema-description-expanded = "${this.schemaDescriptionExpanded}"
768
+ allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}",
769
+ > </schema-tree>
770
+ </div>`
771
+ }
758
772
  </div>
759
773
  `;
760
774
  }
@@ -773,7 +787,7 @@ export default class ApiRequest extends LitElement {
773
787
  const labelColWidth = 'read focused'.includes(this.renderStyle) ? '200px' : '160px';
774
788
  const example = normalizeExamples((paramSchema.examples || paramSchema.example), paramSchema.type);
775
789
  formDataTableRows.push(html`
776
- <tr>
790
+ <tr title="${fieldSchema.deprecated ? 'Deprecated' : ''}">
777
791
  <td style="width:${labelColWidth}; min-width:100px;">
778
792
  <div class="param-name ${fieldSchema.deprecated ? 'deprecated' : ''}">
779
793
  ${fieldName}${(schema.required?.includes(fieldName) || fieldSchema.required) ? html`<span style='color:var(--red);'>*</span>` : ''}
@@ -913,7 +927,7 @@ export default class ApiRequest extends LitElement {
913
927
  <div class="row" style="font-size:var(--font-size-small); margin:5px 0">
914
928
  <div class="response-message ${this.responseStatus}">Response Status: ${this.responseMessage}</div>
915
929
  <div style="flex:1"></div>
916
- <button class="m-btn" part="btn btn-outline" @click="${this.clearResponseData}">CLEAR RESPONSE</button>
930
+ <button class="m-btn" part="btn btn-outline btn-clear-response" @click="${this.clearResponseData}">CLEAR RESPONSE</button>
917
931
  </div>
918
932
  <div class="tab-panel col" style="border-width:0 0 1px 0;">
919
933
  <div id="tab_buttons" class="tab-buttons row" @click="${(e) => {
@@ -936,19 +950,19 @@ export default class ApiRequest extends LitElement {
936
950
  }
937
951
  </div>`
938
952
  : html`
939
- <div class="tab-content col m-markdown" style="flex:1;display:${this.activeResponseTab === 'response' ? 'flex' : 'none'};" >
953
+ <div class="tab-content col m-markdown" style="flex:1; display:${this.activeResponseTab === 'response' ? 'flex' : 'none'};" >
940
954
  <button class="toolbar-btn" style="position:absolute; top:12px; right:8px" @click='${(e) => { copyToClipboard(this.responseText, e); }}' part="btn btn-fill"> Copy </button>
941
- <pre style="white-space:pre; max-height:400px; overflow:auto">${responseFormat
955
+ <pre style="white-space:pre; min-height:50px; height:400px; resize:vertical; overflow:auto">${responseFormat
942
956
  ? html`<code>${unsafeHTML(Prism.highlight(this.responseText, Prism.languages[responseFormat], responseFormat))}</code>`
943
957
  : `${this.responseText}`
944
958
  }</pre>
945
959
  </div>`
946
960
  }
947
- <div class="tab-content col m-markdown" style="flex:1;display:${this.activeResponseTab === 'headers' ? 'flex' : 'none'};" >
961
+ <div class="tab-content col m-markdown" style="flex:1; display:${this.activeResponseTab === 'headers' ? 'flex' : 'none'};" >
948
962
  <button class="toolbar-btn" style = "position:absolute; top:12px; right:8px" @click='${(e) => { copyToClipboard(this.responseHeaders, e); }}' part="btn btn-fill"> Copy </button>
949
963
  <pre style="white-space:pre"><code>${unsafeHTML(Prism.highlight(this.responseHeaders, Prism.languages.css, 'css'))}</code></pre>
950
964
  </div>
951
- <div class="tab-content col m-markdown" style="flex:1;display:${this.activeResponseTab === 'curl' ? 'flex' : 'none'};">
965
+ <div class="tab-content col m-markdown" style="flex:1; display:${this.activeResponseTab === 'curl' ? 'flex' : 'none'};">
952
966
  <button class="toolbar-btn" style = "position:absolute; top:12px; right:8px" @click='${(e) => { copyToClipboard(this.curlSyntax.replace(/\\$/, ''), e); }}' part="btn btn-fill"> Copy </button>
953
967
  <pre style="white-space:pre"><code>${unsafeHTML(Prism.highlight(this.curlSyntax.trim().replace(/\\$/, ''), Prism.languages.shell, 'shell'))}</code></pre>
954
968
  </div>
@@ -1006,15 +1020,15 @@ export default class ApiRequest extends LitElement {
1006
1020
  ${
1007
1021
  this.parameters.length > 0 || this.request_body
1008
1022
  ? html`
1009
- <button class="m-btn thin-border" part="btn btn-outline" style="margin-right:5px;" @click="${this.onFillRequestData}" title="Fills with example data (if provided)">
1023
+ <button class="m-btn thin-border" part="btn btn-outline btn-fill" style="margin-right:5px;" @click="${this.onFillRequestData}" title="Fills with example data (if provided)">
1010
1024
  FILL EXAMPLE
1011
1025
  </button>
1012
- <button class="m-btn thin-border" part="btn btn-outline" style="margin-right:5px;" @click="${this.onClearRequestData}">
1026
+ <button class="m-btn thin-border" part="btn btn-outline btn-clear" style="margin-right:5px;" @click="${this.onClearRequestData}">
1013
1027
  CLEAR
1014
1028
  </button>`
1015
1029
  : ''
1016
1030
  }
1017
- <button class="m-btn primary thin-border" part="btn btn-fill btn-try" @click="${this.onTryClick}">TRY</button>
1031
+ <button class="m-btn primary thin-border" part="btn btn-try" @click="${this.onTryClick}">TRY</button>
1018
1032
  </div>
1019
1033
  ${this.responseMessage === '' ? '' : this.apiResponseTabTemplate()}
1020
1034
  `;
@@ -1058,7 +1072,6 @@ export default class ApiRequest extends LitElement {
1058
1072
  const queryParamObjTypeEls = [...requestPanelEl.querySelectorAll("[data-ptype='query-object']")];
1059
1073
  const headerParamEls = [...requestPanelEl.querySelectorAll("[data-ptype='header']")];
1060
1074
  const requestBodyContainerEl = requestPanelEl.querySelector('.request-body-container');
1061
-
1062
1075
  fetchUrl = this.path;
1063
1076
  const fetchOptions = {
1064
1077
  method: this.method.toUpperCase(),
@@ -1111,7 +1124,7 @@ export default class ApiRequest extends LitElement {
1111
1124
  const queryParam = new URLSearchParams();
1112
1125
  try {
1113
1126
  let queryParamObj = {};
1114
- const { paramSerializeStyle, paramSerializeExplode } = el.dataset.paramSerializeStyle;
1127
+ const { paramSerializeStyle, paramSerializeExplode } = el.dataset;
1115
1128
  queryParamObj = Object.assign(queryParamObj, JSON.parse(el.value.replace(/\s+/g, ' ')));
1116
1129
  if (el.dataset.paramAllowReserved === 'true') {
1117
1130
  queryParamsWithReservedCharsAllowed.push(el.dataset.pname);
@@ -1322,6 +1335,8 @@ export default class ApiRequest extends LitElement {
1322
1335
  if (this.fetchCredentials) {
1323
1336
  fetchOptions.credentials = this.fetchCredentials;
1324
1337
  }
1338
+ const controller = new AbortController();
1339
+ const { signal } = controller;
1325
1340
  fetchOptions.headers = reqHeaders;
1326
1341
  const fetchRequest = new Request(fetchUrl, fetchOptions);
1327
1342
  this.dispatchEvent(new CustomEvent('before-try', {
@@ -1329,6 +1344,7 @@ export default class ApiRequest extends LitElement {
1329
1344
  composed: true,
1330
1345
  detail: {
1331
1346
  request: fetchRequest,
1347
+ controller,
1332
1348
  },
1333
1349
  }));
1334
1350
 
@@ -1340,7 +1356,7 @@ export default class ApiRequest extends LitElement {
1340
1356
  let respText;
1341
1357
  tryBtnEl.disabled = true;
1342
1358
  const startTime = performance.now();
1343
- fetchResponse = await fetch(fetchRequest);
1359
+ fetchResponse = await fetch(fetchRequest, { signal });
1344
1360
  const endTime = performance.now();
1345
1361
  responseClone = fetchResponse.clone(); // create a response clone to allow reading response body again (response.json, response.text etc)
1346
1362
  tryBtnEl.disabled = false;
@@ -1391,7 +1407,7 @@ export default class ApiRequest extends LitElement {
1391
1407
  }
1392
1408
  if (this.responseIsBlob) {
1393
1409
  const contentDisposition = fetchResponse.headers.get('content-disposition');
1394
- this.respContentDisposition = contentDisposition ? contentDisposition.split('filename=')[1].replace(/\\"/g, '') : 'filename';
1410
+ this.respContentDisposition = contentDisposition ? contentDisposition.split('filename=')[1].replace(/"|'/g, '') : 'filename';
1395
1411
  respBlob = await fetchResponse.blob();
1396
1412
  this.responseBlobUrl = URL.createObjectURL(respBlob);
1397
1413
  }
@@ -1412,17 +1428,27 @@ export default class ApiRequest extends LitElement {
1412
1428
  }));
1413
1429
  } catch (err) {
1414
1430
  tryBtnEl.disabled = false;
1415
- this.responseMessage = `${err.message} (CORS or Network Issue)`;
1416
- document.dispatchEvent(new CustomEvent('after-try', {
1417
- bubbles: true,
1418
- composed: true,
1419
- detail: {
1420
- err,
1421
- request: fetchRequest,
1422
- response: responseClone,
1423
- responseStatus: responseClone.ok,
1424
- },
1425
- }));
1431
+ if (err.name === 'AbortError') {
1432
+ this.dispatchEvent(new CustomEvent('request-aborted', {
1433
+ bubbles: true,
1434
+ composed: true,
1435
+ detail: {
1436
+ err,
1437
+ request: fetchRequest,
1438
+ },
1439
+ }));
1440
+ this.responseMessage = 'Request Aborted';
1441
+ } else {
1442
+ this.dispatchEvent(new CustomEvent('after-try', {
1443
+ bubbles: true,
1444
+ composed: true,
1445
+ detail: {
1446
+ err,
1447
+ request: fetchRequest,
1448
+ },
1449
+ }));
1450
+ this.responseMessage = `${err.message} (CORS or Network Issue)`;
1451
+ }
1426
1452
  }
1427
1453
  this.requestUpdate();
1428
1454
  }
@@ -1,6 +1,6 @@
1
- import { LitElement, html, css } from 'lit-element';
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 { schemaInObjectNotation, generateExample } from '~/utils/schema-utils';
5
5
  import FontStyles from '~/styles/font-styles';
6
6
  import FlexStyles from '~/styles/flex-styles';
@@ -34,6 +34,7 @@ export default class ApiResponse extends LitElement {
34
34
  schemaExpandLevel: { type: Number, attribute: 'schema-expand-level' },
35
35
  schemaDescriptionExpanded: { type: String, attribute: 'schema-description-expanded' },
36
36
  allowSchemaDescriptionExpandToggle: { type: String, attribute: 'allow-schema-description-expand-toggle' },
37
+ schemaHideReadOnly: { type: String, attribute: 'schema-hide-read-only' },
37
38
  schemaHideWriteOnly: { type: String, attribute: 'schema-hide-write-only' },
38
39
  };
39
40
  }
@@ -118,8 +119,8 @@ export default class ApiResponse extends LitElement {
118
119
  mimeResp,
119
120
  mimeRespObj.examples,
120
121
  mimeRespObj.example,
121
- true,
122
- false,
122
+ !(this.schemaHideReadOnly && (this.schemaHideReadOnly.includes(this.method) || this.schemaHideReadOnly === 'true')),
123
+ !(this.schemaHideWriteOnly && (this.schemaHideWriteOnly.includes(this.method) || this.schemaHideWriteOnly === 'true')),
123
124
  mimeResp.includes('json') ? 'json' : 'text',
124
125
  );
125
126
  allMimeResp[mimeResp] = {
@@ -154,7 +155,7 @@ export default class ApiResponse extends LitElement {
154
155
  }
155
156
  }}"
156
157
  class='m-btn small ${this.selectedStatus === respStatus ? 'primary' : ''}'
157
- part="btn--resp ${this.selectedStatus === respStatus ? 'btn-fill--resp' : 'btn-outline--resp'} btn-response-status"
158
+ part="btn ${this.selectedStatus === respStatus ? 'btn-response-status btn-selected-response-status' : ' btn-response-status'}"
158
159
  style='margin: 8px 4px 0 0'
159
160
  >
160
161
  ${respStatus}
@@ -179,8 +180,8 @@ export default class ApiResponse extends LitElement {
179
180
  : html`
180
181
  <div class="tab-panel col">
181
182
  <div class="tab-buttons row" @click="${(e) => { if (e.target.tagName.toLowerCase() === 'button') { this.activeSchemaTab = e.target.dataset.tab; } }}" >
182
- <button class="tab-btn ${this.activeSchemaTab !== 'example' ? 'active' : ''}" data-tab = 'schema' >SCHEMA</button>
183
183
  <button class="tab-btn ${this.activeSchemaTab === 'example' ? 'active' : ''}" data-tab = 'example'>EXAMPLE </button>
184
+ <button class="tab-btn ${this.activeSchemaTab !== 'example' ? 'active' : ''}" data-tab = 'schema' >SCHEMA</button>
184
185
  <div style="flex:1"></div>
185
186
  ${Object.keys(this.mimeResponsesForEachStatus[status]).length === 1
186
187
  ? html`<span class='small-font-size gray-text' style='align-self:center; margin-top:8px;'> ${Object.keys(this.mimeResponsesForEachStatus[status])[0]} </span>`
@@ -258,6 +259,7 @@ export default class ApiResponse extends LitElement {
258
259
  render-style = '${this.renderStyle}'
259
260
  .data="${mimeRespDetails.examples[0].exampleValue}"
260
261
  class = 'example-panel ${this.renderStyle === 'read' ? 'border pad-8-16' : 'border-top pad-top-8'}'
262
+ exportparts = "btn:btn, btn-fill:btn-fill, btn-copy:btn-copy"
261
263
  ></json-tree>`
262
264
  : html`
263
265
  ${mimeRespDetails.examples[0].exampleSummary && mimeRespDetails.examples[0].exampleSummary.length > 80 ? html`<div style="padding: 4px 0"> ${mimeRespDetails.examples[0].exampleSummary} </div>` : ''}
@@ -281,6 +283,7 @@ export default class ApiResponse extends LitElement {
281
283
  <json-tree
282
284
  render-style = '${this.renderStyle}'
283
285
  .data = '${v.exampleValue}'
286
+ exportparts = "btn:btn, btn-fill:btn-fill, btn-copy:btn-copy"
284
287
  ></json-tree>`
285
288
  : html`<pre>${v.exampleValue}</pre>`
286
289
  }
@@ -307,7 +310,7 @@ export default class ApiResponse extends LitElement {
307
310
  schema-expand-level = "${this.schemaExpandLevel}"
308
311
  schema-description-expanded = "${this.schemaDescriptionExpanded}"
309
312
  allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}",
310
- schema-hide-read-only = "false"
313
+ schema-hide-read-only = "${this.schemaHideReadOnly}"
311
314
  schema-hide-write-only = "${this.schemaHideWriteOnly}"
312
315
  > </schema-tree> `
313
316
  : html`
@@ -317,7 +320,7 @@ export default class ApiResponse extends LitElement {
317
320
  schema-expand-level = "${this.schemaExpandLevel}"
318
321
  schema-description-expanded = "${this.schemaDescriptionExpanded}"
319
322
  allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}",
320
- schema-hide-read-only = "false"
323
+ schema-hide-read-only = "${this.schemaHideReadOnly}"
321
324
  schema-hide-write-only = "${this.schemaHideWriteOnly}"
322
325
  > </schema-tree>`
323
326
  }`;
@@ -1,4 +1,4 @@
1
- import { LitElement, html } from 'lit-element';
1
+ import { LitElement, html } from 'lit';
2
2
  import DialogBoxStyles from '~/styles/dialog-box-styles';
3
3
 
4
4
  export default class DialogBox extends LitElement {
@@ -1,4 +1,4 @@
1
- import { LitElement, html, css } from 'lit-element';
1
+ import { LitElement, html, css } from 'lit';
2
2
  import { copyToClipboard } from '~/utils/common-utils';
3
3
  import FontStyles from '~/styles/font-styles';
4
4
  import BorderStyles from '~/styles/border-styles';
@@ -35,18 +35,29 @@ export default class JsonTree extends LitElement {
35
35
  text-align: left;
36
36
  }
37
37
 
38
- .open-bracket{
38
+ .open-bracket {
39
39
  display:inline-block;
40
40
  padding: 0 20px 0 0;
41
41
  cursor:pointer;
42
42
  border: 1px solid transparent;
43
43
  border-radius:3px;
44
44
  }
45
- .open-bracket:hover{
45
+ .close-bracket {
46
+ border: 1px solid transparent;
47
+ border-radius:3px;
48
+ display:inline-block;
49
+ }
50
+ .open-bracket:hover {
46
51
  color:var(--primary-color);
47
52
  background-color:var(--hover-color);
48
53
  border: 1px solid var(--border-color);
49
54
  }
55
+ .open-bracket.expanded:hover ~ .inside-bracket {
56
+ border-left: 1px solid var(--fg3);
57
+ }
58
+ .open-bracket.expanded:hover ~ .close-bracket {
59
+ color:var(--primary-color);
60
+ }
50
61
  .inside-bracket{
51
62
  padding-left:12px;
52
63
  border-left:1px dotted var(--border-color);
@@ -78,7 +89,7 @@ export default class JsonTree extends LitElement {
78
89
  return html`
79
90
  <div class = "json-tree" >
80
91
  <div class='toolbar'>
81
- <button class="toolbar-btn" part="btn btn-fill" @click='${(e) => { copyToClipboard(JSON.stringify(this.data, null, 2), e); }}'> Copy </button>
92
+ <button class="toolbar-btn" part="btn btn-fill btn-copy" @click='${(e) => { copyToClipboard(JSON.stringify(this.data, null, 2), e); }}'> Copy </button>
82
93
  </div>
83
94
  ${this.generateTree(this.data, true)}
84
95
  </div>