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,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,73 +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
- file-input:file-input, textbox:textbox, textbox-param:textbox-param, textarea:textarea, textarea-param:textarea-param,
44
- anchor:anchor, anchor-param-example:anchor-param-example, schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
45
- > </api-request>
46
-
47
- <api-response
48
- style = "width:100%;"
49
- class = "${this.renderStyle}-mode"
50
- callback = "true"
51
- .responses="${method[1]?.responses}"
52
- render-style="${this.renderStyle}"
53
- schema-style="${this.schemaStyle}"
54
- active-schema-tab = "${this.defaultSchemaTab}"
55
- schema-expand-level = "${this.schemaExpandLevel}"
56
- schema-description-expanded = "${this.schemaDescriptionExpanded}"
57
- allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}"
58
- schema-hide-read-only = "${this.schemaHideReadOnly === 'never' ? 'false' : 'true'}"
59
- schema-hide-write-only = "false"
60
- 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,
61
- schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
62
- > </api-response>
63
- </div>
64
- </div>
65
- `)}
66
- </div>
67
- </div>
68
- `)}
69
- </div>
70
- `)}
71
- `;
72
- }
73
- /* 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 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 class="tab-buttons row" style="width:100; overflow">
23
- ${xCodeSamples.map((v, i) => html`<button 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,249 +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
- file-input:file-input, textbox:textbox, textbox-param:textbox-param, textarea:textarea, textarea-param:textarea-param,
159
- anchor:anchor, anchor-param-example:anchor-param-example, schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
160
- > </api-request>
161
-
162
- ${path.callbacks ? callbackTemplate.call(this, path.callbacks) : ''}
163
- </div>
164
-
165
- <api-response
166
- class = "${this.renderStyle}-mode"
167
- style = "width:100%;"
168
- webhook = "${path.isWebhook}"
169
- .responses="${path.responses}"
170
- active-schema-tab = "${this.defaultSchemaTab}"
171
- render-style="${this.renderStyle}"
172
- schema-style="${this.schemaStyle}"
173
- schema-expand-level = "${this.schemaExpandLevel}"
174
- schema-description-expanded = "${this.schemaDescriptionExpanded}"
175
- allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}"
176
- schema-hide-read-only = "${this.schemaHideReadOnly === 'never' ? 'false' : path.isWebhook ? 'true' : 'false'}"
177
- schema-hide-write-only = "${this.schemaHideWriteOnly === 'never' ? 'false' : path.isWebhook ? 'false' : 'true'}"
178
- selected-status = "${Object.keys(path.responses || {})[0] || ''}"
179
- exportparts = "btn:btn, btn-fill:btn-fill, btn-outline:btn-outline, btn-try:btn-try, file-input:file-input,
180
- 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,
181
- schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
182
- > </api-response>
183
- </div>
184
- </div>`;
185
- }
186
-
187
- export default function endpointTemplate(isMini = false, pathsExpanded = false) {
188
- if (!this.resolvedSpec) { return ''; }
189
- return html`
190
- ${isMini
191
- ? ''
192
- : html`
193
- <div style="display:flex; justify-content:flex-end;">
194
- <span @click="${(e) => onExpandCollapseAll(e, 'expand-all')}" style="color:var(--primary-color); cursor:pointer;">
195
- Expand all
196
- </span>
197
- &nbsp;|&nbsp;
198
- <span @click="${(e) => onExpandCollapseAll(e, 'collapse-all')}" style="color:var(--primary-color); cursor:pointer;" >
199
- Collapse all
200
- </span>
201
- &nbsp; sections
202
- </div>`
203
- }
204
- ${this.resolvedSpec.tags.map((tag) => html`
205
- ${isMini
206
- ? html`
207
- <div class='section-tag-body'>
208
- ${tag.paths.filter((path) => {
209
- if (this.searchVal) {
210
- return getMatchedPaths(this.searchVal, path, tag.name);
211
- }
212
- return true;
213
- }).map((path) => html`
214
- <section id='${path.elementId}' class='m-endpoint regular-font ${path.method} ${pathsExpanded || path.expanded ? 'expanded' : 'collapsed'}'>
215
- ${endpointHeadTemplate.call(this, path, pathsExpanded)}
216
- ${pathsExpanded || path.expanded ? endpointBodyTemplate.call(this, path) : ''}
217
- </section>`)
218
- }
219
- </div>
220
- `
221
- : html`
222
- <div class='regular-font section-gap section-tag ${tag.expanded ? 'expanded' : 'collapsed'}'>
223
- <div class='section-tag-header' @click="${() => { tag.expanded = !tag.expanded; this.requestUpdate(); }}">
224
- <div id='${tag.elementId}' class="sub-title tag" style="color:var(--primary-color)">${tag.displayName || tag.name}</div>
225
- </div>
226
- <div class='section-tag-body'>
227
- <slot name="${tag.elementId}"></slot>
228
- <div class="regular-font regular-font-size m-markdown" style="padding-bottom:12px">
229
- ${unsafeHTML(marked(tag.description || ''))}
230
- </div>
231
- ${tag.paths.filter((v) => {
232
- if (this.searchVal) {
233
- return getMatchedPaths(this.searchVal, v, tag.name);
234
- }
235
- return true;
236
- }).map((path) => html`
237
- <section part="section-endpoint" id='${path.elementId}' class='m-endpoint regular-font ${path.method} ${pathsExpanded || path.expanded ? 'expanded' : 'collapsed'}'>
238
- ${endpointHeadTemplate.call(this, path, pathsExpanded)}
239
- ${pathsExpanded || path.expanded ? endpointBodyTemplate.call(this, path) : ''}
240
- </section>`)
241
- }
242
- </div>
243
- </div>
244
- `
245
- }
246
- `)
247
- }`;
248
- }
249
- /* eslint-enable indent */