rapidoc 9.3.8 → 10.0.1

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 -3914
  3. package/package.json +23 -46
  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 -1010
  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 -21603
  17. package/dist/report.html +0 -39
  18. package/index-hashroute.html +0 -65
  19. package/index.html +0 -1045
  20. package/index_bak.html +0 -251
  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 -1793
  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 -367
  29. package/src/components/schema-tree.js +0 -381
  30. package/src/components/tag-input.js +0 -135
  31. package/src/index.js +0 -7
  32. package/src/json-schema-viewer.js +0 -346
  33. package/src/oauth-receiver.js +0 -56
  34. package/src/rapidoc-mini.js +0 -382
  35. package/src/rapidoc.js +0 -1083
  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 -207
  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 -75
  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 -251
  54. package/src/templates/expanded-endpoint-template.js +0 -199
  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 -110
  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 -612
  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,58 +0,0 @@
1
- import { css } from 'lit';
2
-
3
- export default css`
4
- .m-table {
5
- border-spacing: 0;
6
- border-collapse: separate;
7
- border: 1px solid var(--light-border-color);
8
- border-radius: var(--border-radius);
9
- margin: 0;
10
- max-width: 100%;
11
- direction: ltr;
12
- }
13
- .m-table tr:first-child td,
14
- .m-table tr:first-child th {
15
- border-top: 0 none;
16
- }
17
- .m-table td,
18
- .m-table th {
19
- font-size: var(--font-size-small);
20
- line-height: calc(var(--font-size-small) + 4px);
21
- padding: 4px 5px 4px;
22
- vertical-align: top;
23
- }
24
-
25
- .m-table.padded-12 td,
26
- .m-table.padded-12 th {
27
- padding: 12px;
28
- }
29
-
30
- .m-table td:not([align]),
31
- .m-table th:not([align]) {
32
- text-align: left;
33
- }
34
-
35
- .m-table th {
36
- color: var(--fg2);
37
- font-size: var(--font-size-small);
38
- line-height: calc(var(--font-size-small) + 18px);
39
- font-weight: 600;
40
- letter-spacing: normal;
41
- background-color: var(--bg2);
42
- vertical-align: bottom;
43
- border-bottom: 1px solid var(--light-border-color);
44
- }
45
-
46
- .m-table > tbody > tr > td,
47
- .m-table > tr > td {
48
- border-top: 1px solid var(--light-border-color);
49
- text-overflow: ellipsis;
50
- overflow: hidden;
51
- }
52
- .table-title {
53
- font-size:var(--font-size-small);
54
- font-weight:bold;
55
- vertical-align: middle;
56
- margin: 12px 0 4px 0;
57
- }
58
- `;
@@ -1,72 +0,0 @@
1
- import { html } from 'lit';
2
- import '~/components/dialog-box';
3
-
4
- /* eslint-disable indent */
5
- export default function searchByPropertiesModalTemplate() {
6
- document.addEventListener('close', () => { this.showAdvancedSearchDialog = false; });
7
- document.addEventListener('open', this.onOpenSearchDialog);
8
-
9
- return html`
10
- <dialog-box
11
- heading="Search"
12
- show="${(!!this.showAdvancedSearchDialog)}"
13
- >
14
- <span class="advanced-search-options">
15
- <input
16
- id="input-advanced-search-dialog"
17
- style="width:100%; padding-right:20px;"
18
- type="text"
19
- part="textbox textbox-search-dialog"
20
- placeholder="search text..."
21
- spellcheck="false"
22
- @keyup = "${(e) => this.onAdvancedSearch(e, 400)}"
23
- >
24
- <div style="display:flex; margin:8px 0 24px;">
25
- <div>
26
- <input style="cursor:pointer;" type="checkbox" part="checkbox checkbox-search-dialog" id="search-api-path" checked @change = "${(e) => this.onAdvancedSearch(e, 0)}">
27
- <label for="search-api-path" style="cursor:pointer;"> API Path </label>
28
- </div>
29
- <div style="margin-left: 16px;">
30
- <input style="cursor:pointer;" type="checkbox" part="checkbox checkbox-search-dialog" id="search-api-descr" checked @change = "${(e) => this.onAdvancedSearch(e, 0)}">
31
- <label style="cursor:pointer;" for="search-api-descr"> API Description </label>
32
- </div>
33
- <div style="margin-left: 16px;">
34
- <input style="cursor:pointer;" type="checkbox" part="checkbox checkbox-search-dialog" id="search-api-params" @change = "${(e) => this.onAdvancedSearch(e, 0)}">
35
- <label style="cursor:pointer;" for="search-api-params"> API Parameters </label>
36
- </div>
37
- <div style="margin-left: 16px;">
38
- <input style="cursor:pointer;" type="checkbox" part="checkbox checkbox-search-dialog" id="search-api-request-body" @change = "${(e) => this.onAdvancedSearch(e, 0)}">
39
- <label style="cursor:pointer;" for="search-api-request-body"> Request Body Parameters </label>
40
- </div>
41
- <div style="margin-left: 16px;">
42
- <input style="cursor:pointer;" type="checkbox" part="checkbox checkbox-search-dialog" id="search-api-resp-descr" @change = "${(e) => this.onAdvancedSearch(e, 0)}">
43
- <label style="cursor:pointer;" for="search-api-resp-descr"> Response Description </label>
44
- </div>
45
- </div>
46
- </span>
47
-
48
- ${this.advancedSearchMatches?.map((path) => html`
49
- <div
50
- class="mono-font small-font-size hover-bg"
51
- style='padding: 5px; cursor: pointer; border-bottom: 1px solid var(--light-border-color); ${path.deprecated ? 'filter:opacity(0.5);' : ''}'
52
- data-content-id='${path.elementId}'
53
- tabindex = '0'
54
- @click="${
55
- (e) => {
56
- this.searchVal = ''; // clear quick filter if applied
57
- this.showAdvancedSearchDialog = false; // Hide Search Dialog
58
- this.requestUpdate();
59
- this.scrollToEventTarget(e, true);
60
- }
61
- }"
62
- >
63
- <span style="pointer-events: none" class="upper bold-text method-fg ${path.method}">${path.method}</span>
64
- <span style="pointer-events: none">${path.path}</span>
65
- <span style="pointer-events: none" class="regular-font gray-text">${path.summary}</span>
66
- </div>
67
- `)
68
- }
69
- </dialog-box>
70
- `;
71
- }
72
- /* eslint-enable indent */
@@ -1,75 +0,0 @@
1
- import { html } from 'lit';
2
-
3
- /* eslint-disable indent */
4
- export default function callbackTemplate(callbacks) {
5
- return html`
6
- <div class="req-res-title" style="margin-top:12px">CALLBACKS</div>
7
- ${Object.entries(callbacks).map((kv) => html`
8
- <div class="tiny-title" style="padding: 12px; border:1px solid var(--light-border-color)">
9
- ${kv[0]}
10
- ${Object.entries(kv[1]).map((pathObj) => html`
11
- <div class="mono-font small-font-size" style="display:flex; margin-left:16px;">
12
- <div style="width:100%">
13
- ${Object.entries(pathObj[1]).map((method) => html`
14
- <div>
15
- <div style="margin-top:12px;">
16
- <div class="method method-fg ${method[0]}" style="width:70px; border:none; margin:0; padding:0; line-height:20px; vertical-align: baseline;text-align:left">
17
- <span style="font-size:20px;"> &#x2944; </span>
18
- ${method[0]}
19
- </div>
20
- <span style="line-height:20px; vertical-align: baseline;">${pathObj[0]} </span>
21
- </div>
22
- <div class='expanded-req-resp-container'>
23
- <api-request
24
- class = "${this.renderStyle}-mode callback"
25
- style = "width:100%;"
26
- callback = "true"
27
- method = "${method[0] || ''}",
28
- path = "${pathObj[0] || ''}"
29
- .parameters = "${method[1]?.parameters || ''}"
30
- .request_body = "${method[1]?.requestBody || ''}"
31
- fill-request-fields-with-example = "${this.fillRequestFieldsWithExample}"
32
- allow-try = "false"
33
- render-style="${this.renderStyle}"
34
- schema-style = "${this.schemaStyle}"
35
- active-schema-tab = "${this.defaultSchemaTab}"
36
- schema-expand-level = "${this.schemaExpandLevel}"
37
- schema-description-expanded = "${this.schemaDescriptionExpanded}"
38
- allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}"
39
- schema-hide-read-only = "false"
40
- schema-hide-write-only = "${this.schemaHideWriteOnly === 'never' ? 'false' : 'true'}"
41
- fetch-credentials = "${this.fetchCredentials}"
42
- exportparts = "wrap-request-btn:wrap-request-btn, btn:btn, btn-fill:btn-fill, btn-outline:btn-outline, btn-try:btn-try, btn-clear:btn-clear, btn-clear-resp:btn-clear-resp,
43
- tab-panel:tab-panel, tab-btn:tab-btn, tab-btn-row:tab-btn-row, tab-coontent:tab-content,
44
- file-input:file-input, textbox:textbox, textbox-param:textbox-param, textarea:textarea, textarea-param:textarea-param,
45
- anchor:anchor, anchor-param-example:anchor-param-example, schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
46
- > </api-request>
47
-
48
- <api-response
49
- style = "width:100%;"
50
- class = "${this.renderStyle}-mode"
51
- callback = "true"
52
- .responses="${method[1]?.responses}"
53
- render-style="${this.renderStyle}"
54
- schema-style="${this.schemaStyle}"
55
- active-schema-tab = "${this.defaultSchemaTab}"
56
- schema-expand-level = "${this.schemaExpandLevel}"
57
- schema-description-expanded = "${this.schemaDescriptionExpanded}"
58
- allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}"
59
- schema-hide-read-only = "${this.schemaHideReadOnly === 'never' ? 'false' : 'true'}"
60
- schema-hide-write-only = "false"
61
- exportparts = "btn:btn, btn-response-status:btn-response-status, btn-selected-response-status:btn-selected-response-status, btn-fill:btn-fill, btn-copy:btn-copy,
62
- tab-panel:tab-panel, tab-btn:tab-btn, tab-btn-row:tab-btn-row, tab-coontent:tab-content,
63
- schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
64
- > </api-response>
65
- </div>
66
- </div>
67
- `)}
68
- </div>
69
- </div>
70
- `)}
71
- </div>
72
- `)}
73
- `;
74
- }
75
- /* eslint-enable indent */
@@ -1,34 +0,0 @@
1
- import { html } from 'lit';
2
- import { unsafeHTML } from 'lit/directives/unsafe-html.js'; // eslint-disable-line import/extensions
3
- import Prism from 'prismjs';
4
- import { copyToClipboard } from '~/utils/common-utils';
5
-
6
- /* eslint-disable indent */
7
- export default function codeSamplesTemplate(xCodeSamples) {
8
- return html`
9
- <section class="table-title" style="margin-top:24px;">CODE SAMPLES</div>
10
- <div part="tab-panel" class="tab-panel col"
11
- @click="${
12
- (e) => {
13
- if (!e.target.classList.contains('tab-btn')) { return; }
14
- const clickedTab = e.target.dataset.tab;
15
-
16
- const tabButtons = [...e.currentTarget.querySelectorAll('.tab-btn')];
17
- const tabContents = [...e.currentTarget.querySelectorAll('.tab-content')];
18
- tabButtons.forEach((tabBtnEl) => tabBtnEl.classList[tabBtnEl.dataset.tab === clickedTab ? 'add' : 'remove']('active'));
19
- tabContents.forEach((tabBodyEl) => { tabBodyEl.style.display = (tabBodyEl.dataset.tab === clickedTab ? 'block' : 'none'); });
20
- }
21
- }">
22
- <div part="tab-btn-row" class="tab-buttons row" style="width:100; overflow">
23
- ${xCodeSamples.map((v, i) => html`<button part="tab-btn" class="tab-btn ${i === 0 ? 'active' : ''}" data-tab = '${v.lang}${i}'> ${v.label || v.lang} </button>`)}
24
- </div>
25
- ${xCodeSamples.map((v, i) => html`
26
- <div class="tab-content m-markdown" style= "display:${i === 0 ? 'block' : 'none'}" data-tab = '${v.lang}${i}'>
27
- <button class="toolbar-btn" style = "position:absolute; top:12px; right:8px" @click='${(e) => { copyToClipboard(v.source, e); }}'> Copy </button>
28
- <pre><code class="language">${Prism.languages[v.lang?.toLowerCase()] ? unsafeHTML(Prism.highlight(v.source, Prism.languages[v.lang?.toLowerCase()], v.lang?.toLowerCase())) : v.source}</code></pre>
29
- </div>`)
30
- }
31
- </div>
32
- </section>`;
33
- }
34
- /* eslint-enable indent */
@@ -1,76 +0,0 @@
1
- import { html } from 'lit';
2
- import { unsafeHTML } from 'lit/directives/unsafe-html.js'; // eslint-disable-line import/extensions
3
- import { marked } from 'marked';
4
- import { schemaInObjectNotation } from '~/utils/schema-utils';
5
- import '~/components/json-tree';
6
- import '~/components/schema-tree';
7
- import '~/components/schema-table';
8
-
9
- function schemaBodyTemplate(sComponent) {
10
- return html`
11
- <div class='divider'></div>
12
- <div class='expanded-endpoint-body observe-me ${sComponent.name}' id='cmp--${sComponent.id}' >
13
- <div style="font-weight:bold"> ${sComponent.name} <span style="color:var(--light-fg); font-size:var(--font-size-small); font-weight:400;"> Schema </span></div>
14
- ${this.schemaStyle === 'table'
15
- ? html`
16
- <schema-table
17
- .data = '${schemaInObjectNotation(sComponent.component, {})}'
18
- schema-expand-level = "${this.schemaExpandLevel}"
19
- schema-description-expanded = "${this.schemaDescriptionExpanded}"
20
- allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}"
21
- schema-hide-read-only = "false"
22
- schema-hide-write-only = "${this.schemaHideWriteOnly}"
23
- exportparts = "schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
24
- > </schema-table>`
25
- : html`
26
- <schema-tree
27
- .data = '${schemaInObjectNotation(sComponent.component, {})}'
28
- schema-expand-level = "${this.schemaExpandLevel}"
29
- schema-description-expanded = "${this.schemaDescriptionExpanded}"
30
- allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}"
31
- schema-hide-read-only = "false"
32
- schema-hide-write-only = "${this.schemaHideWriteOnly}"
33
- exportparts = "schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
34
- > </schema-tree>`
35
- }
36
- </div>`;
37
- }
38
-
39
- function componentBodyTemplate(sComponent, componentType) {
40
- if (sComponent.id.indexOf('schemas-') !== -1) {
41
- return schemaBodyTemplate.call(this, sComponent);
42
- }
43
- return html`
44
- <div class='divider'></div>
45
- <div class='expanded-endpoint-body observe-me ${sComponent.name}' id='cmp--${sComponent.id}' >
46
- ${html`
47
- <div style="font-weight:bold"> ${sComponent.name} <span style="color:var(--light-fg); font-size:var(--font-size-small); font-weight:400"> ${componentType} </span> </div>
48
- ${sComponent.component
49
- ? html`
50
- <div class='mono-font regular-font-size' style='padding: 8px 0; color:var(--fg2)'>
51
- <json-tree class="border tree" render-style='${this.renderStyle}' .data="${sComponent.component}"> </json-tree>
52
- </div>`
53
- : ''}
54
- `}
55
- </div>
56
- `;
57
- }
58
-
59
- export default function componentsTemplate() {
60
- if (!this.resolvedSpec) { return ''; }
61
- return html`
62
- ${this.resolvedSpec.components.map((component) => html`
63
- <div id="cmp--${component.name.toLowerCase()}" class='regular-font section-gap--read-mode observe-me' style="border-top:1px solid var(--primary-color);">
64
- <div class="title tag">${component.name}</div>
65
- <div class="regular-font-size">
66
- ${unsafeHTML(`<div class='m-markdown regular-font'>${marked(component.description ? component.description : '')}</div>`)}
67
- </div>
68
- </div>
69
- <div class='regular-font section-gap--read-mode'>
70
- ${component.subComponents.filter((c) => c.expanded !== false).map((sComponent) => componentBodyTemplate.call(this, sComponent, component.name))}
71
- </div>
72
- `)
73
- }
74
- `;
75
- }
76
- /* eslint-enable indent */
@@ -1,251 +0,0 @@
1
- import { html } from 'lit';
2
- import { unsafeHTML } from 'lit/directives/unsafe-html.js'; // eslint-disable-line import/extensions
3
- import { marked } from 'marked';
4
- import '~/components/api-request';
5
- import '~/components/api-response';
6
- import codeSamplesTemplate from '~/templates/code-samples-template';
7
- import callbackTemplate from '~/templates/callback-template';
8
- import { pathSecurityTemplate } from '~/templates/security-scheme-template';
9
- import { getMatchedPaths, rapidocApiKey } from '~/utils/common-utils';
10
-
11
- function toggleExpand(path) {
12
- if (path.expanded) {
13
- path.expanded = false; // collapse
14
- if (this.updateRoute === 'true') {
15
- this.replaceHistoryState('');
16
- }
17
- } else {
18
- path.expanded = true; // Expand
19
- if (this.updateRoute === 'true') {
20
- const newHash = `${this.routePrefix || '#'}${path.elementId}`;
21
- if (window.location.hash !== newHash) {
22
- this.replaceHistoryState(path.elementId);
23
- }
24
- }
25
- }
26
- this.requestUpdate();
27
- }
28
-
29
- export function expandCollapseAll(operationsRootEl, action = 'expand-all') {
30
- const elList = [...operationsRootEl.querySelectorAll('.section-tag')];
31
- if (action === 'expand-all') {
32
- elList.map((el) => {
33
- el.classList.replace('collapsed', 'expanded');
34
- });
35
- } else {
36
- elList.map((el) => {
37
- el.classList.replace('expanded', 'collapsed');
38
- });
39
- }
40
- }
41
-
42
- function onExpandCollapseAll(e, action = 'expand-all') {
43
- expandCollapseAll.call(this, e.target.closest('.operations-root'), action);
44
- }
45
-
46
- /* eslint-disable indent */
47
- function endpointHeadTemplate(path, pathsExpanded = false) {
48
- return html`
49
- <summary @click="${(e) => { toggleExpand.call(this, path, e); }}" part="section-endpoint-head-${path.expanded ? 'expanded' : 'collapsed'}" class='endpoint-head ${path.method} ${path.deprecated ? 'deprecated' : ''} ${pathsExpanded || path.expanded ? 'expanded' : 'collapsed'}'>
50
- <div part="section-endpoint-head-method" class="method ${path.method} ${path.deprecated ? 'deprecated' : ''}"> ${path.method} </div>
51
- <div part="section-endpoint-head-path" class="path ${path.deprecated ? 'deprecated' : ''}">
52
- ${path.path}
53
- ${path.isWebhook ? html`<span style="font-family: var(--font-regular); font-size: var(--); font-size: var(--font-size-small); color:var(--primary-color); margin-left: 16px"> Webhook</span>` : ''}
54
- </div>
55
- ${path.deprecated
56
- ? html`
57
- <span style="font-size:var(--font-size-small); text-transform:uppercase; font-weight:bold; color:var(--red); margin:2px 0 0 5px;">
58
- deprecated
59
- </span>`
60
- : ''
61
- }
62
- ${this.showSummaryWhenCollapsed
63
- ? html`
64
- <div class="only-large-screen" style="min-width:60px; flex:1"></div>
65
- <div part="section-endpoint-head-description" class="descr">${path.summary || path.shortSummary} </div>`
66
- : ''
67
- }
68
- </summary>
69
- `;
70
- }
71
-
72
- function endpointBodyTemplate(path) {
73
- const acceptContentTypes = new Set();
74
- for (const respStatus in path.responses) {
75
- for (const acceptContentType in (path.responses[respStatus]?.content)) {
76
- acceptContentTypes.add(acceptContentType.trim());
77
- }
78
- }
79
- const accept = [...acceptContentTypes].join(', ');
80
- // Filter API Keys that are non-empty and are applicable to the the path
81
- const nonEmptyApiKeys = this.resolvedSpec.securitySchemes.filter((v) => (v.finalKeyValue && path.security?.some((ps) => (v.securitySchemeId in ps)))) || [];
82
-
83
- // If a RapiDoc API Key is specified on the element and its value is not hyphen(-) then include it for all paths
84
- const rapiDocApiKey = this.resolvedSpec.securitySchemes.find((v) => (v.securitySchemeId === rapidocApiKey && v.value !== '-'));
85
- if (rapiDocApiKey) {
86
- nonEmptyApiKeys.push(rapiDocApiKey);
87
- }
88
-
89
- const codeSampleTabPanel = path.xCodeSamples ? codeSamplesTemplate(path.xCodeSamples) : '';
90
- return html`
91
- <div part="section-endpoint-body-${path.expanded ? 'expanded' : 'collapsed'}" class='endpoint-body ${path.method} ${path.deprecated ? 'deprecated' : ''}'>
92
- <div class="summary">
93
- ${path.summary
94
- ? html`<div class="title" part="section-endpoint-body-title">${path.summary}</div>`
95
- : path.shortSummary !== path.description
96
- ? html`<div class="title" part="section-endpoint-body-title">${path.shortSummary}</div>`
97
- : ''
98
- }
99
- ${path.xBadges && path.xBadges?.length > 0
100
- ? html`
101
- <div style="display:flex; flex-wrap:wrap;font-size: var(--font-size-small);">
102
- ${path.xBadges.map((v) => (
103
- v.color === 'none'
104
- ? ''
105
- : html`<span part="endpoint-badge" style="margin:1px; margin-right:5px; padding:1px 8px; font-weight:bold; border-radius:12px; background-color: var(--light-${v.color}, var(--input-bg)); color:var(--${v.color}); border:1px solid var(--${v.color})">${v.label}</span>`
106
- ))
107
- }
108
- </div>
109
- `
110
- : ''
111
- }
112
-
113
- ${path.description ? html`<div part="section-endpoint-body-description" class="m-markdown"> ${unsafeHTML(marked(path.description))}</div>` : ''}
114
- ${path.externalDocs?.url || path.externalDocs?.description
115
- ? html`<div style="background-color:var(--bg3); padding:2px 8px 8px 8px; margin:8px 0; border-radius:var(--border-radius)">
116
- <div class="m-markdown"> ${unsafeHTML(marked(path.externalDocs?.description || ''))} </div>
117
- ${path.externalDocs?.url
118
- ? html`<a style="font-family:var(--font-mono); font-size:var(--font-size-small)" href="${path.externalDocs?.url}" target="_blank">
119
- ${path.externalDocs?.url} <div style="transform: rotate(270deg) scale(1.5); display: inline-block; margin-left:5px">⇲</div>
120
- </a>`
121
- : ''
122
- }
123
- </div>`
124
- : ''
125
- }
126
- <slot name="${path.elementId}"></slot>
127
- ${pathSecurityTemplate.call(this, path.security)}
128
- ${codeSampleTabPanel}
129
- </div>
130
- <div class='req-resp-container'>
131
- <div style="display:flex; flex-direction:column" class="view-mode-request ${this.layout}-layout">
132
- <api-request
133
- class = "${this.renderStyle}-mode ${this.layout}-layout"
134
- style = "width:100%;"
135
- webhook = "${path.isWebhook}"
136
- method = "${path.method}"
137
- path = "${path.path}"
138
- .security = "${path.security}"
139
- .parameters = "${path.parameters}"
140
- .request_body = "${path.requestBody}"
141
- .api_keys = "${nonEmptyApiKeys}"
142
- .servers = "${path.servers}"
143
- server-url = "${path.servers && path.servers.length > 0 ? path.servers[0].url : this.selectedServer?.computedUrl}"
144
- active-schema-tab = "${this.defaultSchemaTab}"
145
- fill-request-fields-with-example = "${this.fillRequestFieldsWithExample}"
146
- allow-try = "${this.allowTry}"
147
- show-curl-before-try = "${this.showCurlBeforeTry}"
148
- accept = "${accept}"
149
- render-style="${this.renderStyle}"
150
- schema-style = "${this.schemaStyle}"
151
- schema-expand-level = "${this.schemaExpandLevel}"
152
- schema-description-expanded = "${this.schemaDescriptionExpanded}"
153
- allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}"
154
- schema-hide-read-only = "${this.schemaHideReadOnly === 'never' ? 'false' : path.isWebhook ? 'false' : 'true'}"
155
- schema-hide-write-only = "${this.schemaHideWriteOnly === 'never' ? 'false' : path.isWebhook ? 'true' : 'false'}"
156
- fetch-credentials = "${this.fetchCredentials}"
157
- exportparts = "wrap-request-btn:wrap-request-btn, btn:btn, btn-fill:btn-fill, btn-outline:btn-outline, btn-try:btn-try, btn-clear:btn-clear, btn-clear-resp:btn-clear-resp,
158
- tab-panel:tab-panel, tab-btn:tab-btn, tab-btn-row:tab-btn-row, tab-coontent:tab-content,
159
- file-input:file-input, textbox:textbox, textbox-param:textbox-param, textarea:textarea, textarea-param:textarea-param,
160
- anchor:anchor, anchor-param-example:anchor-param-example, schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
161
- > </api-request>
162
-
163
- ${path.callbacks ? callbackTemplate.call(this, path.callbacks) : ''}
164
- </div>
165
-
166
- <api-response
167
- class = "${this.renderStyle}-mode"
168
- style = "width:100%;"
169
- webhook = "${path.isWebhook}"
170
- .responses="${path.responses}"
171
- active-schema-tab = "${this.defaultSchemaTab}"
172
- render-style="${this.renderStyle}"
173
- schema-style="${this.schemaStyle}"
174
- schema-expand-level = "${this.schemaExpandLevel}"
175
- schema-description-expanded = "${this.schemaDescriptionExpanded}"
176
- allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}"
177
- schema-hide-read-only = "${this.schemaHideReadOnly === 'never' ? 'false' : path.isWebhook ? 'true' : 'false'}"
178
- schema-hide-write-only = "${this.schemaHideWriteOnly === 'never' ? 'false' : path.isWebhook ? 'false' : 'true'}"
179
- selected-status = "${Object.keys(path.responses || {})[0] || ''}"
180
- exportparts = "btn:btn, btn-fill:btn-fill, btn-outline:btn-outline, btn-try:btn-try, file-input:file-input,
181
- textbox:textbox, textbox-param:textbox-param, textarea:textarea, textarea-param:textarea-param, anchor:anchor, anchor-param-example:anchor-param-example, btn-clear-resp:btn-clear-resp,
182
- tab-panel:tab-panel, tab-btn:tab-btn, tab-btn-row:tab-btn-row, tab-coontent:tab-content,
183
- schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
184
- > </api-response>
185
- </div>
186
- </div>`;
187
- }
188
-
189
- export default function endpointTemplate(isMini = false, pathsExpanded = false) {
190
- if (!this.resolvedSpec) { return ''; }
191
- return html`
192
- ${isMini
193
- ? ''
194
- : html`
195
- <div style="display:flex; justify-content:flex-end;">
196
- <span @click="${(e) => onExpandCollapseAll(e, 'expand-all')}" style="color:var(--primary-color); cursor:pointer;">
197
- Expand all
198
- </span>
199
- &nbsp;|&nbsp;
200
- <span @click="${(e) => onExpandCollapseAll(e, 'collapse-all')}" style="color:var(--primary-color); cursor:pointer;" >
201
- Collapse all
202
- </span>
203
- &nbsp; sections
204
- </div>`
205
- }
206
- ${this.resolvedSpec.tags.map((tag) => html`
207
- ${isMini
208
- ? html`
209
- <div class='section-tag-body'>
210
- ${tag.paths.filter((path) => {
211
- if (this.searchVal) {
212
- return getMatchedPaths(this.searchVal, path, tag.name);
213
- }
214
- return true;
215
- }).map((path) => html`
216
- <section id='${path.elementId}' class='m-endpoint regular-font ${path.method} ${pathsExpanded || path.expanded ? 'expanded' : 'collapsed'}'>
217
- ${endpointHeadTemplate.call(this, path, pathsExpanded)}
218
- ${pathsExpanded || path.expanded ? endpointBodyTemplate.call(this, path) : ''}
219
- </section>`)
220
- }
221
- </div>
222
- `
223
- : html`
224
- <div class='regular-font section-gap section-tag ${tag.expanded ? 'expanded' : 'collapsed'}'>
225
- <div class='section-tag-header' @click="${() => { tag.expanded = !tag.expanded; this.requestUpdate(); }}">
226
- <div id='${tag.elementId}' class="sub-title tag" style="color:var(--primary-color)">${tag.displayName || tag.name}</div>
227
- </div>
228
- <div class='section-tag-body'>
229
- <slot name="${tag.elementId}"></slot>
230
- <div class="regular-font regular-font-size m-markdown" style="padding-bottom:12px">
231
- ${unsafeHTML(marked(tag.description || ''))}
232
- </div>
233
- ${tag.paths.filter((v) => {
234
- if (this.searchVal) {
235
- return getMatchedPaths(this.searchVal, v, tag.name);
236
- }
237
- return true;
238
- }).map((path) => html`
239
- <section part="section-endpoint" id='${path.elementId}' class='m-endpoint regular-font ${path.method} ${pathsExpanded || path.expanded ? 'expanded' : 'collapsed'}'>
240
- ${endpointHeadTemplate.call(this, path, pathsExpanded)}
241
- ${pathsExpanded || path.expanded ? endpointBodyTemplate.call(this, path) : ''}
242
- </section>`)
243
- }
244
- </div>
245
- </div>
246
- `
247
- }
248
- `)
249
- }`;
250
- }
251
- /* eslint-enable indent */