openapi-explorer 2.1.654 → 2.1.658
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.
- package/dist/browser/openapi-explorer.min.js +2 -2
- package/dist/es/components/api-request.js +58 -140
- package/dist/es/components/api-response.js +9 -34
- package/dist/es/components/json-tree.js +4 -18
- package/dist/es/components/request-form-table.js +13 -36
- package/dist/es/components/schema-table.js +28 -42
- package/dist/es/components/schema-tree.js +31 -61
- package/dist/es/components/syntax-highlighter.js +7 -26
- package/dist/es/components/tag-input.js +2 -14
- package/dist/es/openapi-explorer-oauth-handler.js +0 -2
- package/dist/es/openapi-explorer.js +62 -174
- package/dist/es/react.js +4 -4
- package/dist/es/styles/input-styles.js +1 -1
- package/dist/es/styles/schema-styles.js +1 -1
- package/dist/es/templates/advance-search-template.js +1 -5
- package/dist/es/templates/callback-template.js +2 -2
- package/dist/es/templates/code-samples-template.js +1 -3
- package/dist/es/templates/components-template.js +41 -4
- package/dist/es/templates/endpoint-template.js +6 -17
- package/dist/es/templates/expanded-endpoint-template.js +4 -7
- package/dist/es/templates/focused-endpoint-template.js +0 -10
- package/dist/es/templates/mainBodyTemplate.js +3 -2
- package/dist/es/templates/navbar-template.js +9 -12
- package/dist/es/templates/overview-template.js +2 -2
- package/dist/es/templates/security-scheme-template.js +12 -73
- package/dist/es/templates/server-template.js +1 -8
- package/dist/es/utils/color-utils.js +2 -21
- package/dist/es/utils/common-utils.js +3 -20
- package/dist/es/utils/schema-utils.js +35 -132
- package/dist/es/utils/spec-parser.js +35 -120
- package/dist/es/utils/theme.js +3 -6
- package/dist/es/utils/xml/xml.js +1 -40
- package/dist/lib/components/api-request.js +58 -157
- package/dist/lib/components/api-response.js +9 -54
- package/dist/lib/components/json-tree.js +4 -27
- package/dist/lib/components/request-form-table.js +14 -42
- package/dist/lib/components/schema-table.js +28 -52
- package/dist/lib/components/schema-tree.js +31 -72
- package/dist/lib/components/syntax-highlighter.js +6 -49
- package/dist/lib/components/tag-input.js +2 -18
- package/dist/lib/languages/en.js +2 -3
- package/dist/lib/languages/fr.js +2 -3
- package/dist/lib/languages/index.js +0 -6
- package/dist/lib/openapi-explorer-oauth-handler.js +0 -6
- package/dist/lib/openapi-explorer.js +61 -197
- package/dist/lib/react.js +4 -5
- package/dist/lib/styles/advanced-search-styles.js +1 -5
- package/dist/lib/styles/api-request-styles.js +1 -5
- package/dist/lib/styles/border-styles.js +1 -5
- package/dist/lib/styles/endpoint-styles.js +1 -5
- package/dist/lib/styles/flex-styles.js +1 -5
- package/dist/lib/styles/font-styles.js +1 -5
- package/dist/lib/styles/info-styles.js +1 -5
- package/dist/lib/styles/input-styles.js +1 -5
- package/dist/lib/styles/key-frame-styles.js +1 -5
- package/dist/lib/styles/nav-styles.js +1 -5
- package/dist/lib/styles/prism-styles.js +1 -5
- package/dist/lib/styles/schema-styles.js +1 -5
- package/dist/lib/styles/tab-styles.js +1 -5
- package/dist/lib/styles/table-styles.js +1 -5
- package/dist/lib/styles/tag-input-styles.js +1 -5
- package/dist/lib/templates/advance-search-template.js +0 -6
- package/dist/lib/templates/callback-template.js +1 -3
- package/dist/lib/templates/code-samples-template.js +0 -4
- package/dist/lib/templates/components-template.js +43 -9
- package/dist/lib/templates/endpoint-template.js +6 -29
- package/dist/lib/templates/expanded-endpoint-template.js +3 -17
- package/dist/lib/templates/focused-endpoint-template.js +0 -19
- package/dist/lib/templates/mainBodyTemplate.js +2 -13
- package/dist/lib/templates/navbar-template.js +9 -20
- package/dist/lib/templates/overview-template.js +1 -6
- package/dist/lib/templates/security-scheme-template.js +12 -79
- package/dist/lib/templates/server-template.js +1 -12
- package/dist/lib/utils/color-utils.js +4 -25
- package/dist/lib/utils/common-utils.js +3 -33
- package/dist/lib/utils/schema-utils.js +33 -141
- package/dist/lib/utils/spec-parser.js +35 -128
- package/dist/lib/utils/theme.js +3 -16
- package/dist/lib/utils/xml/xml.js +1 -42
- package/package.json +2 -2
package/dist/es/react.js
CHANGED
@@ -11,19 +11,19 @@ export function reactEventListener({
|
|
11
11
|
}, eventName, functionCallback) {
|
12
12
|
const targetElement = window;
|
13
13
|
useEffect(() => {
|
14
|
-
targetElement.addEventListener(eventName, functionCallback);
|
14
|
+
targetElement.addEventListener(eventName, functionCallback);
|
15
|
+
// This is an effect that requires cleanup when the component using this
|
15
16
|
// custom hook unmounts:
|
16
17
|
// https://reactjs.org/docs/hooks-effect.html#effects-with-cleanup
|
17
|
-
|
18
18
|
return () => {
|
19
19
|
// Check if the event functionCallback we were given was a debounced or throttled
|
20
20
|
// event functionCallback, if it is, cancel any future events
|
21
21
|
// https://github.com/niksy/throttle-debounce#cancelling
|
22
22
|
if (functionCallback !== null && functionCallback !== void 0 && functionCallback.cancel) {
|
23
23
|
functionCallback.cancel();
|
24
|
-
}
|
25
|
-
|
24
|
+
}
|
26
25
|
|
26
|
+
// Remove the event functionCallbacks
|
27
27
|
if (targetElement !== null && targetElement !== void 0 && targetElement.removeEventListener) {
|
28
28
|
targetElement.removeEventListener(eventName, functionCallback);
|
29
29
|
}
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import { css } from 'lit';
|
2
|
-
/* eslint-disable max-len */
|
3
2
|
|
3
|
+
/* eslint-disable max-len */
|
4
4
|
export default css`.m-btn{border-radius:var(--border-radius);font-weight:600;display:inline-block;padding:6px 16px;font-size:var(--font-size-small);outline:0;line-height:1;text-align:center;white-space:nowrap;border:2px solid var(--primary-color);background-color:transparent;transition:background-color .2s;user-select:none;cursor:pointer;box-shadow:0 1px 3px rgba(0,0,0,.12),0 1px 2px rgba(0,0,0,.24)}.m-btn.primary{background-color:var(--primary-color);color:var(--primary-btn-text-color)}.m-btn.outline-primary{color:var(--primary-color);background-color:var(--bg);border:1px solid var(--bg)}.m-btn.outline-primary:hover{border:1px solid var(--bg)}.m-btn.thin-border{border-width:1px}.m-btn.large{padding:8px 14px}.m-btn.small{padding:5px 12px}.m-btn.tiny{padding:5px 6px}.m-btn.circle{border-radius:50%}.m-btn:hover{background-color:var(--primary-color);color:var(--primary-btn-text-color)}.m-btn.nav{border:2px solid var(--secondary-color)}.m-btn.nav:hover{background-color:var(--secondary-color)}.m-btn:disabled{background-color:var(--bg3);color:var(--fg3);border-color:var(--fg3);cursor:progress;opacity:.4}button,input,select,textarea{color:var(--fg);outline:0;background-color:var(--input-bg);border:1px solid var(--border-color);border-radius:var(--border-radius)}button{font-family:var(--font-regular)}input[type=file],input[type=password],input[type=text],select,textarea{font-family:var(--font-regular);font-weight:400;font-size:var(--font-size-small);transition:border .2s;padding:6px 5px}select{font-family:var(--font-regular);padding-right:30px;background-image:url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2212%22%20height%3D%2212%22%3E%3Cpath%20d%3D%22M10.3%203.3L6%207.6%201.7%203.3A1%201%200%2000.3%204.7l5%205a1%201%200%20001.4%200l5-5a1%201%200%2010-1.4-1.4z%22%20fill%3D%22%23777777%22%2F%3E%3C%2Fsvg%3E");background-position:calc(100% - 5px) center;background-repeat:no-repeat;background-size:10px;-webkit-appearance:none;-moz-appearance:none;appearance:none;cursor:pointer}select:hover{border-color:var(--primary-color)}input[type=password]::placeholder,input[type=text]::placeholder,textarea::placeholder{color:var(--placeholder-color);opacity:1}input[type=password]:active,input[type=password]:focus,input[type=text]:active,input[type=text]:focus,select:focus,textarea:active,textarea:focus{border:1px solid var(--primary-color)}input[type=file]{font-family:var(--font-regular);padding:2px;cursor:pointer;border:1px solid var(--primary-color);min-height:calc(var(--font-size-small) + 18px)}input[type=file]::-webkit-file-upload-button{font-family:var(--font-regular);font-size:var(--font-size-small);outline:0;cursor:pointer;padding:3px 8px;border:1px solid var(--primary-color);background-color:var(--primary-color);color:var(--primary-btn-text-color);border-radius:var(--border-radius);-webkit-appearance:none}pre,textarea{scrollbar-width:thin;scrollbar-color:var(--border-color) var(--input-bg)}pre::-webkit-scrollbar,textarea::-webkit-scrollbar{width:8px;height:8px}pre::-webkit-scrollbar-track,textarea::-webkit-scrollbar-track{background:var(--input-bg)}pre::-webkit-scrollbar-thumb,textarea::-webkit-scrollbar-thumb{border-radius:2px;background-color:var(--border-color)}.link{font-size:var(--font-size-small);text-decoration:underline;color:var(--blue);font-family:var(--font-mono);margin-bottom:2px}input[type=checkbox]:focus{outline:0}input[type=checkbox]{appearance:none;display:inline-block;background-color:var(--light-bg);border-radius:9px;cursor:pointer;height:18px;position:relative;transition:border .15s,padding .25s;min-width:36px;width:36px;vertical-align:top}input[type=checkbox]:after{position:absolute;background-color:var(--bg);border-radius:8px;content:'';top:0;left:0;right:16px;display:block;height:16px;transition:left .25s .1s,right .15s .175s}input[type=checkbox]:checked{box-shadow:inset 0 0 0 13px var(--primary-color);border-color:var(--primary-color)}input[type=checkbox]:checked:after{border:1px solid var(--primary-color);left:16px;right:1px;transition:border .25s,left .15s .25s,right .25s .175s}.oauth-client-input{display:flex;align-items:center;flex-grow:1;width:300px;max-width:300px;margin-top:1rem}input.oauth-client-secret{flex-grow:1;max-width:300px}`;
|
@@ -1,2 +1,2 @@
|
|
1
1
|
import { css } from 'lit';
|
2
|
-
export default css`*,:after,:before{box-sizing:border-box}.no-select{-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none}.tr{display:flex;flex:none;width:100%;box-sizing:content-box;border-bottom:1px dotted transparent}.td{display:block;flex:0 0 auto}.key{font-family:var(--font-mono);white-space:normal;word-break:break-all}.key-descr{font-family:var(--font-regular);flex-shrink:1;text-overflow:ellipsis;overflow:hidden;display:none;max-height:auto}.toolbar{display:none}.xxx-of-key{font-size:calc(var(--font-size-small) - 2px);font-weight:700;background-color:var(--primary-color);color:var(--primary-btn-text-color);border-radius:2px;line-height:calc(var(--font-size-small) + 6px);padding:0 5px;display:inline-block}.xxx-of-descr{font-family:var(--font-regular);font-size:calc(var(--font-size-small) - 1px);margin-left:2px}.bina,.binary,.byte,.date,.date-time,.datetime,.emai,.email,.host,.hostname,.ipv4,.pass,.password,.stri,.string,.uri,.url,.uuid{color:var(--green)}.blue,.deci,.decimal,.doub,.double,.floa,.float,.int3,.int32,.int6,.int64,.inte,.integer,.numb,.number{color:var(--blue)}.null{color:var(--red)}.bool,.boolean{color:var(--orange)}.cons,.const,.enum{color:var(--purple)}.tree .toolbar{display:flex;justify-content:space-between}.toolbar{width:100%}.toolbar-item{cursor:pointer;padding:5px 0 5px 1rem;margin:0 1rem!important;color:var(--secondary-color);flex-shrink:0}.tree .toolbar .toolbar-item{display:none}.schema-root-type{cursor:auto;color:var(--fg2);font-weight:700;text-transform:uppercase}.schema-root-type.xxx-of{display:none}.toolbar-item:first-of-type{margin:0 2px 0 0}@media only screen and (min-width:576px){.key-descr{display:block}.tree .toolbar .toolbar-item{display:block}.toolbar{display:flex}}`;
|
2
|
+
export default css`*,:after,:before{box-sizing:border-box}.no-select{-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none}.tr{display:flex;flex:none;width:100%;box-sizing:content-box;border-bottom:1px dotted transparent}.td{display:block;flex:0 0 auto}.key{font-family:var(--font-mono);white-space:normal;word-break:break-all}.key-descr{font-family:var(--font-regular);flex-shrink:1;text-overflow:ellipsis;overflow:hidden;display:none;max-height:auto}.toolbar{display:none}.xxx-of-key{font-size:calc(var(--font-size-small) - 2px);font-weight:700;background-color:var(--primary-color);color:var(--primary-btn-text-color);border-radius:2px;line-height:calc(var(--font-size-small) + 6px);padding:0 5px;display:inline-block}.xxx-of-descr{font-family:var(--font-regular);font-size:calc(var(--font-size-small) - 1px);margin-left:2px}.bina,.binary,.byte,.date,.date-time,.datetime,.emai,.email,.host,.hostname,.ipv4,.pass,.password,.stri,.string,.uri,.url,.uuid{color:var(--green)}.blue,.deci,.decimal,.doub,.double,.floa,.float,.int3,.int32,.int6,.int64,.inte,.integer,.numb,.number{color:var(--blue)}.null{color:var(--red)}.bool,.boolean{color:var(--orange)}.cons,.const,.enum{color:var(--purple)}.tree .toolbar{display:flex;justify-content:space-between}.toolbar{width:100%}.toolbar-item{cursor:pointer;padding:5px 0 5px 1rem;margin:0 1rem!important;color:var(--secondary-color);flex-shrink:0}.tree .toolbar .toolbar-item{display:none}.schema-root-type{cursor:auto;color:var(--fg2);font-weight:700;text-transform:uppercase}.schema-root-type.xxx-of{display:none}.toolbar-item:first-of-type{margin:0 2px 0 0}@media only screen and (min-width:576px){.key-descr{display:block}.tree .toolbar .toolbar-item{display:block}.toolbar{display:flex}}.expanded-endpoint-component>h2:hover,.schema-link:hover{cursor:pointer;text-decoration:underline}`;
|
@@ -1,13 +1,12 @@
|
|
1
1
|
import { html } from 'lit';
|
2
|
-
/* eslint-disable indent */
|
3
2
|
|
3
|
+
/* eslint-disable indent */
|
4
4
|
export default function searchByPropertiesModalTemplate() {
|
5
5
|
const keyDownEventListenerAdvancedSearch = e => {
|
6
6
|
if ((e.detail && e.detail.code || e.code) === 'Escape') {
|
7
7
|
this.showAdvancedSearchDialog = false;
|
8
8
|
}
|
9
9
|
};
|
10
|
-
|
11
10
|
const closeAdvancedSearchDialog = () => {
|
12
11
|
// Trigger the event to force it to be removed from the DOM
|
13
12
|
document.dispatchEvent(new CustomEvent('keydown', {
|
@@ -19,7 +18,6 @@ export default function searchByPropertiesModalTemplate() {
|
|
19
18
|
once: true
|
20
19
|
});
|
21
20
|
};
|
22
|
-
|
23
21
|
document.addEventListener('keydown', keyDownEventListenerAdvancedSearch, {
|
24
22
|
once: true
|
25
23
|
});
|
@@ -27,9 +25,7 @@ export default function searchByPropertiesModalTemplate() {
|
|
27
25
|
closeAdvancedSearchDialog();
|
28
26
|
}}" part="btn btn-outline">×</button> </header> <div id="advanced-search-modal" class="dialog-box-content"> <span class="advanced-search-options"> <div class="advanced-search-dialog-input"> <input id="advanced-search-dialog-input" type="text" part="textbox textbox-search-dialog" placeholder="search text..." spellcheck="false" @keyup="${e => this.onAdvancedSearch(e)}"> </div> <div class="advanced-search-locations"> <div> <input style="cursor:pointer" type="checkbox" part="checkbox checkbox-search-dialog" id="search-api-path" checked="checked" @change="${e => this.onAdvancedSearch(e)}"> <label style="cursor:pointer" for="search-api-path"> API Path </label> </div> <div> <input style="cursor:pointer" type="checkbox" part="checkbox checkbox-search-dialog" id="search-api-descr" checked="checked" @change="${e => this.onAdvancedSearch(e)}"> <label style="cursor:pointer" for="search-api-descr"> API Description </label> </div> <div> <input style="cursor:pointer" type="checkbox" part="checkbox checkbox-search-dialog" id="search-api-params" @change="${e => this.onAdvancedSearch(e)}"> <label style="cursor:pointer" for="search-api-params"> Request Parameters </label> </div> <div> <input style="cursor:pointer" type="checkbox" part="checkbox checkbox-search-dialog" id="search-api-request-body" @change="${e => this.onAdvancedSearch(e)}"> <label style="cursor:pointer" for="search-api-request-body"> Request Body </label> </div> <div> <input style="cursor:pointer" type="checkbox" part="checkbox checkbox-search-dialog" id="search-api-resp-descr" @change="${e => this.onAdvancedSearch(e)}"> <label style="cursor:pointer" for="search-api-resp-descr"> Response Description </label> </div> </div> </span> <div class="advanced-search-results"> ${this.advancedSearchMatches && this.advancedSearchMatches.map(path => html` <div class="mono-font small-font-size hover-bg" tabindex="0" style="padding:5px;cursor:pointer;border-bottom:1px solid var(--light-border-color);${path.deprecated ? 'filter:opacity(0.5);' : ''}" data-content-id="${path.elementId}" @click="${e => {
|
29
27
|
this.matchPaths = ''; // clear quick filter if applied
|
30
|
-
|
31
28
|
closeAdvancedSearchDialog(); // Hide Search Dialog
|
32
|
-
|
33
29
|
this.requestUpdate();
|
34
30
|
this.scrollToEventTarget(e, true);
|
35
31
|
}}"> <span class="upper bold-text method-fg ${path.method}">${path.method}</span> <span>${path.path}</span> - <span class="regular-font gray-text">${path.summary}</span> </div> `)} </div> </div> </div> </div>` : ''}`;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { html } from 'lit';
|
2
|
-
/* eslint-disable indent */
|
3
2
|
|
3
|
+
/* eslint-disable indent */
|
4
4
|
export default function callbackTemplate(callbacks) {
|
5
|
-
return html` <div class="api-request col regular-font request-panel ${this.renderStyle}-mode"> ${Object.entries(callbacks).map(kv => html` <div class="${this.renderStyle}-request"> <div class="req-res-title">CALLBACKS</div> <div class="table-title">${kv[0]}</div> ${Object.entries(kv[1]).map(pathObj => html` <div class="mono-font small-font-size" style="display:flex"> <div style="width:100%"> ${Object.entries(pathObj[1]).map(method => html` <div> <div style="margin-top:12px"> <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"> <span style="font-size:20px"> ⥄ </span> ${method[0]} </div> <span style="line-height:20px;vertical-align:baseline">${pathObj[0]} </span> </div> <div class="expanded-req-resp-container"> <api-request class="request-panel" callback="true" method="${method[0] || ''}" , path="${pathObj[0] || ''}" .parameters="${method[1] && method[1].parameters || ''}" .request_body="${method[1] && method[1].requestBody || ''}" fill-defaults="${!this.hideDefaults}" display-nulls="${!!this.includeNulls}" enable-console="false" render-style="${this.renderStyle}" schema-style="${this.displaySchemaAsTable ? 'table' : 'tree'}" active-schema-tab="${this.defaultSchemaTab}" schema-expand-level="${this.schemaExpandLevel}" schema-hide-read-only="${this.schemaHideReadOnly}" fetch-credentials="${this.fetchCredentials}" exportparts="btn btn-fill btn-outline btn-try"> </api-request> <api-response callback="true" .responses="${method[1] && method[1].responses}" display-nulls="${!!this.includeNulls}" render-style="${this.renderStyle}" schema-style="${this.displaySchemaAsTable ? 'table' : 'tree'}" active-schema-tab="${this.defaultSchemaTab}" schema-expand-level="${this.schemaExpandLevel}" exportparts="btn--resp btn-fill--resp btn-outline--resp"> </api-response> </div> </div> `)} </div> </div> `)} </div> `)} </div> `;
|
5
|
+
return html` <div class="api-request col regular-font request-panel ${this.renderStyle}-mode"> ${Object.entries(callbacks).map(kv => html` <div class="${this.renderStyle}-request"> <div class="req-res-title">CALLBACKS</div> <div class="table-title">${kv[0]}</div> ${Object.entries(kv[1]).map(pathObj => html` <div class="mono-font small-font-size" style="display:flex"> <div style="width:100%"> ${Object.entries(pathObj[1]).map(method => html` <div> <div style="margin-top:12px"> <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"> <span style="font-size:20px"> ⥄ </span> ${method[0]} </div> <span style="line-height:20px;vertical-align:baseline">${pathObj[0]} </span> </div> <div class="expanded-req-resp-container"> <api-request class="request-panel" callback="true" method="${method[0] || ''}" , path="${pathObj[0] || ''}" .parameters="${method[1] && method[1].parameters || ''}" .request_body="${method[1] && method[1].requestBody || ''}" fill-defaults="${!this.hideDefaults}" display-nulls="${!!this.includeNulls}" enable-console="false" render-style="${this.renderStyle}" schema-style="${this.displaySchemaAsTable ? 'table' : 'tree'}" active-schema-tab="${this.defaultSchemaTab}" schema-expand-level="${this.schemaExpandLevel}" schema-hide-read-only="${this.schemaHideReadOnly}" fetch-credentials="${this.fetchCredentials}" @scrollToSchemaComponentByName="${v => this.scrollToSchemaComponentByName(v)}" exportparts="btn btn-fill btn-outline btn-try"> </api-request> <api-response callback="true" .responses="${method[1] && method[1].responses}" display-nulls="${!!this.includeNulls}" render-style="${this.renderStyle}" schema-style="${this.displaySchemaAsTable ? 'table' : 'tree'}" active-schema-tab="${this.defaultSchemaTab}" schema-expand-level="${this.schemaExpandLevel}" @scrollToSchemaComponentByName="${v => this.scrollToSchemaComponentByName(v)}" exportparts="btn--resp btn-fill--resp btn-outline--resp"> </api-response> </div> </div> `)} </div> </div> `)} </div> `)} </div> `;
|
6
6
|
}
|
7
7
|
/* eslint-enable indent */
|
@@ -1,12 +1,11 @@
|
|
1
1
|
import { html } from 'lit';
|
2
|
-
/* eslint-disable indent */
|
3
2
|
|
3
|
+
/* eslint-disable indent */
|
4
4
|
export default function codeSamplesTemplate(xCodeSamples) {
|
5
5
|
return html` <section class="table-title top-gap"> CODE SAMPLES <div class="tab-panel col" @click="${e => {
|
6
6
|
if (!e.target.classList.contains('tab-btn')) {
|
7
7
|
return;
|
8
8
|
}
|
9
|
-
|
10
9
|
const clickedTab = e.target.dataset.tab;
|
11
10
|
const tabButtons = [...e.currentTarget.querySelectorAll('.tab-btn')];
|
12
11
|
const tabContents = [...e.currentTarget.querySelectorAll('.tab-content')];
|
@@ -18,7 +17,6 @@ export default function codeSamplesTemplate(xCodeSamples) {
|
|
18
17
|
// We skip the first line because it could be there is no padding there, but padding on the next lines which needs to be removed
|
19
18
|
const paddingToRemove = Math.min(...v.source.split('\n').slice(1).map(l => {
|
20
19
|
var _l$match;
|
21
|
-
|
22
20
|
return (_l$match = l.match(/^(\s*).*$/m)) === null || _l$match === void 0 ? void 0 : _l$match[1].length;
|
23
21
|
}).filter(l => typeof l !== 'undefined'));
|
24
22
|
const sanitizedSource = v.source.split('\n').map(s => s.substring(0, paddingToRemove).match(/^\s+$/) ? s.substring(paddingToRemove) : s);
|
@@ -4,15 +4,52 @@ import { html } from 'lit';
|
|
4
4
|
import { unsafeHTML } from 'lit/directives/unsafe-html.js';
|
5
5
|
import { marked } from 'marked';
|
6
6
|
import '../components/schema-tree.js';
|
7
|
-
|
7
|
+
import { getI18nText } from '../languages/index.js';
|
8
8
|
function componentBodyTemplate(sComponent) {
|
9
9
|
const formdataPartSchema = schemaInObjectNotation(sComponent.component, {
|
10
10
|
includeNulls: this.includeNulls
|
11
11
|
});
|
12
|
-
return html` <div class="expanded-endpoint-component observe-me ${sComponent.name}" id="cmp--${sComponent.id}" @click="${() => this.scrollTo(`cmp--${sComponent.id}`)}"
|
12
|
+
return html` <div class="expanded-endpoint-component observe-me ${sComponent.name}" id="cmp--${sComponent.id}"> <h2 @click="${() => this.scrollTo(`cmp--${sComponent.id}`)}">${sComponent.name}</h2> <div class="mono-font regular-font-size" style="padding:8px 0;color:var(--fg2)"> ${this.displaySchemaAsTable ? html`<schema-table .data="${formdataPartSchema}" @scrollToSchemaComponentByName="${v => this.scrollToSchemaComponentByName(v)}" schema-expand-level="${this.schemaExpandLevel}" schema-hide-read-only="false" schema-hide-write-only="false"> </schema-table>` : html`<schema-tree .data="${formdataPartSchema}" schema-expand-level="${this.schemaExpandLevel}" schema-hide-read-only="false" schema-hide-write-only="false"> </schema-tree>`} </div> </div> `;
|
13
|
+
}
|
14
|
+
export function getComponentInfo(componentKeyId) {
|
15
|
+
const infoDictionary = {
|
16
|
+
schemas: {
|
17
|
+
name: getI18nText('menu.schemas'),
|
18
|
+
description: ''
|
19
|
+
},
|
20
|
+
responses: {
|
21
|
+
name: 'Responses',
|
22
|
+
description: 'Describes responses from an API Operation, including design-time, static links to operations based on the response.'
|
23
|
+
},
|
24
|
+
parameters: {
|
25
|
+
name: 'Parameters',
|
26
|
+
description: 'Describes operation parameters. A unique parameter is defined by a combination of a name and location.'
|
27
|
+
},
|
28
|
+
examples: {
|
29
|
+
name: 'Examples',
|
30
|
+
description: 'List of Examples for operations, can be requests, responses and objects examples.'
|
31
|
+
},
|
32
|
+
headers: {
|
33
|
+
name: 'Headers',
|
34
|
+
description: 'Headers follows the structure of the Parameters but they are explicitly in "header"'
|
35
|
+
},
|
36
|
+
links: {
|
37
|
+
name: 'Links',
|
38
|
+
description: 'Links represent a possible design-time link for a response. The presence of a link does not guarantee the caller\'s ability to successfully invoke it, rather it provides a known relationship and traversal mechanism between responses and other operations.'
|
39
|
+
},
|
40
|
+
callbacks: {
|
41
|
+
name: 'Callbacks',
|
42
|
+
description: 'A map of possible out-of band callbacks related to the parent operation. Each value in the map is a Path Item Object that describes a set of requests that may be initiated by the API provider and the expected responses. The key value used to identify the path item object is an expression, evaluated at runtime, that identifies a URL to use for the callback operation.'
|
43
|
+
}
|
44
|
+
};
|
45
|
+
return infoDictionary[componentKeyId] || {
|
46
|
+
name: componentKeyId
|
47
|
+
};
|
13
48
|
}
|
14
|
-
|
15
49
|
export default function componentsTemplate() {
|
16
|
-
return html` ${this.resolvedSpec.components.map(component =>
|
50
|
+
return html` ${this.resolvedSpec.components.map(component => {
|
51
|
+
const componentInfo = getComponentInfo(component.componentKeyId);
|
52
|
+
return html` <div id="cmp--${componentInfo.name.toLowerCase()}" class="regular-font section-gap--focused-mode observe-me" style="padding-bottom:0"> <div class="title tag">${componentInfo.name}</div> <div class="regular-font-size"> ${unsafeHTML(`<div class='m-markdown regular-font'>${marked(componentInfo.description ? componentInfo.description : '')}</div>`)} </div> </div> <div class="regular-font section-gap--focused-mode" style="padding-top:0"> ${component.subComponents.filter(c => c.expanded).map(sComponent => componentBodyTemplate.call(this, sComponent))} </div> `;
|
53
|
+
})}; } `;
|
17
54
|
}
|
18
55
|
/* eslint-enable indent */
|
@@ -7,31 +7,27 @@ import codeSamplesTemplate from './code-samples-template.js';
|
|
7
7
|
import callbackTemplate from './callback-template.js';
|
8
8
|
import { pathSecurityTemplate } from './security-scheme-template.js';
|
9
9
|
import { getCurrentElement, pathIsInSearch, replaceState } from '../utils/common-utils.js';
|
10
|
-
|
11
10
|
function toggleExpand(path) {
|
12
11
|
if (path.expanded) {
|
13
12
|
path.expanded = false;
|
14
13
|
replaceState(null);
|
15
14
|
} else {
|
16
15
|
path.expanded = true;
|
17
|
-
this.emitOperationChangedEvent(path.elementId);
|
16
|
+
this.emitOperationChangedEvent(path.elementId);
|
18
17
|
|
18
|
+
// Toggle all the other ones off
|
19
19
|
this.resolvedSpec.tags.forEach(t => t.paths.filter(p => p.elementId !== path.elementId).forEach(p => p.expanded = false));
|
20
|
-
|
21
20
|
if (path.elementId !== getCurrentElement()) {
|
22
21
|
replaceState(path.elementId);
|
23
22
|
}
|
24
23
|
}
|
25
|
-
|
26
24
|
this.requestUpdate();
|
27
25
|
}
|
28
|
-
|
29
26
|
function toggleTag(tagElement, tagId) {
|
30
27
|
const tag = this.resolvedSpec.tags.find(t => t.elementId === tagId);
|
31
28
|
tag.expanded = !tag.expanded;
|
32
29
|
this.requestUpdate();
|
33
30
|
}
|
34
|
-
|
35
31
|
export function expandCollapseAll(currentElement, expand) {
|
36
32
|
this.resolvedSpec.tags.forEach(t => t.expanded = expand);
|
37
33
|
this.requestUpdate();
|
@@ -40,38 +36,31 @@ export function expandCollapseComponent(component) {
|
|
40
36
|
component.expanded = !component.expanded;
|
41
37
|
this.requestUpdate();
|
42
38
|
}
|
43
|
-
/* eslint-disable indent */
|
44
39
|
|
40
|
+
/* eslint-disable indent */
|
45
41
|
function endpointHeadTemplate(path) {
|
46
42
|
return html` <summary @click="${e => {
|
47
43
|
toggleExpand.call(this, path, e);
|
48
44
|
}}" class="endpoint-head ${path.method} ${path.expanded ? 'expanded' : 'collapsed'}"> <div class="method ${path.method}"><span style="line-height:1">${path.method}</span></div> <div style="${path.deprecated ? 'text-decoration: line-through;' : ''}"> ${this.usePathInNavBar ? html`<div class="path">${path.path.split('/').filter(t => t.trim()).map(t => html`<span>/${t}</span>`)}</div>` : html`<div class="">${path.summary || path.shortSummary}</div>`} ${path.isWebhook ? html`<span style="color:var(--primary-color)"> (Webhook) </span>` : ''} </div> </summary> `;
|
49
45
|
}
|
50
|
-
|
51
46
|
function endpointBodyTemplate(path) {
|
52
47
|
var _path$servers, _path$servers$, _this$selectedServer;
|
53
|
-
|
54
48
|
const acceptContentTypes = new Set();
|
55
|
-
|
56
49
|
for (const respStatus in path.responses) {
|
57
50
|
for (const acceptContentType in (_path$responses$respS = path.responses[respStatus]) === null || _path$responses$respS === void 0 ? void 0 : _path$responses$respS.content) {
|
58
51
|
var _path$responses$respS;
|
59
|
-
|
60
52
|
acceptContentTypes.add(acceptContentType.trim());
|
61
53
|
}
|
62
54
|
}
|
63
|
-
|
64
|
-
|
65
|
-
|
55
|
+
const accept = [...acceptContentTypes].join(', ');
|
56
|
+
// Filter API Keys that are non-empty and are applicable to the the path
|
66
57
|
const nonEmptyApiKeys = this.resolvedSpec.securitySchemes.filter(v => {
|
67
58
|
var _path$security;
|
68
|
-
|
69
59
|
return v.finalKeyValue && ((_path$security = path.security) === null || _path$security === void 0 ? void 0 : _path$security.some(ps => ps[v.apiKeyId]));
|
70
60
|
}) || [];
|
71
61
|
const codeSampleTabPanel = path.xCodeSamples ? codeSamplesTemplate(path.xCodeSamples) : '';
|
72
|
-
return html` <div class="endpoint-body ${path.method}"> <div class="summary"> ${this.usePathInNavBar ? path.summary ? html`<div class="title">${path.summary}<div></div></div>` : path.shortSummary !== path.description ? html`<div class="title">${path.shortSummary}</div>` : '' : html` <div class="title mono-font regular-font-size" part="section-operation-url" style="display:flex;flex-wrap:wrap;color:var(--fg3)"> ${path.isWebhook ? html`<span style="color:var(--primary-color)"> WEBHOOK </span>` : ''} <span part="label-operation-method" class="regular-font upper method-fg bold-text ${path.method}">${path.method} </span> <span style="display:flex;flex-wrap:wrap" part="label-operation-path">${path.path.split('/').filter(t => t.trim()).map(t => html`<span>/${t}</span>`)}</span> </div>`} ${path.description ? html`<div class="m-markdown"> ${unsafeHTML(marked(path.description))}</div>` : ''} <slot name="${path.elementId}"></slot> <slot name="path-details" data-method="${path.method}" data-path="${path.path}"></slot> ${pathSecurityTemplate.call(this, path.security)} ${codeSampleTabPanel} </div> <div class="req-resp-container"> <div style="display:flex;flex-direction:column" class="request"> <api-request class="request-panel" style="width:100%" method="${path.method}" , path="${path.path}" element-id="${path.elementId}" .parameters="${path.parameters}" .request_body="${path.requestBody}" .api_keys="${nonEmptyApiKeys}" .servers="${path.servers}" server-url="${((_path$servers = path.servers) === null || _path$servers === void 0 ? void 0 : (_path$servers$ = _path$servers[0]) === null || _path$servers$ === void 0 ? void 0 : _path$servers$.url) || ((_this$selectedServer = this.selectedServer) === null || _this$selectedServer === void 0 ? void 0 : _this$selectedServer.computedUrl)}" active-schema-tab="${this.defaultSchemaTab}" fill-defaults="${!this.hideDefaults}" display-nulls="${!!this.includeNulls}" enable-console="${!this.hideExecution}" accept="${accept}" render-style="${this.renderStyle}" schema-style="${this.displaySchemaAsTable ? 'table' : 'tree'}" schema-expand-level="${this.schemaExpandLevel}" schema-hide-read-only="${this.schemaHideReadOnly}" fetch-credentials="${this.fetchCredentials}" exportparts="btn btn-fill btn-outline btn-try"> </api-request> </div> ${path.callbacks ? callbackTemplate.call(this, path.callbacks) : ''} <api-response class="request response" .responses="${path.responses}" display-nulls="${!!this.includeNulls}" active-schema-tab="${this.defaultSchemaTab}" render-style="${this.renderStyle}" schema-style="${this.displaySchemaAsTable ? 'table' : 'tree'}" schema-expand-level="${this.schemaExpandLevel}" schema-hide-write-only="${this.schemaHideWriteOnly}" selected-status="${Object.keys(path.responses || {})[0] || ''}" exportparts="btn--resp btn-fill--resp btn-outline--resp"> </api-response> </div> </div>`;
|
62
|
+
return html` <div class="endpoint-body ${path.method}"> <div class="summary"> ${this.usePathInNavBar ? path.summary ? html`<div class="title">${path.summary}<div></div></div>` : path.shortSummary !== path.description ? html`<div class="title">${path.shortSummary}</div>` : '' : html` <div class="title mono-font regular-font-size" part="section-operation-url" style="display:flex;flex-wrap:wrap;color:var(--fg3)"> ${path.isWebhook ? html`<span style="color:var(--primary-color)"> WEBHOOK </span>` : ''} <span part="label-operation-method" class="regular-font upper method-fg bold-text ${path.method}">${path.method} </span> <span style="display:flex;flex-wrap:wrap" part="label-operation-path">${path.path.split('/').filter(t => t.trim()).map(t => html`<span>/${t}</span>`)}</span> </div>`} ${path.description ? html`<div class="m-markdown"> ${unsafeHTML(marked(path.description))}</div>` : ''} <slot name="${path.elementId}"></slot> <slot name="path-details" data-method="${path.method}" data-path="${path.path}"></slot> ${pathSecurityTemplate.call(this, path.security)} ${codeSampleTabPanel} </div> <div class="req-resp-container"> <div style="display:flex;flex-direction:column" class="request"> <api-request class="request-panel" style="width:100%" method="${path.method}" , path="${path.path}" element-id="${path.elementId}" .parameters="${path.parameters}" .request_body="${path.requestBody}" .api_keys="${nonEmptyApiKeys}" .servers="${path.servers}" server-url="${((_path$servers = path.servers) === null || _path$servers === void 0 ? void 0 : (_path$servers$ = _path$servers[0]) === null || _path$servers$ === void 0 ? void 0 : _path$servers$.url) || ((_this$selectedServer = this.selectedServer) === null || _this$selectedServer === void 0 ? void 0 : _this$selectedServer.computedUrl)}" active-schema-tab="${this.defaultSchemaTab}" fill-defaults="${!this.hideDefaults}" display-nulls="${!!this.includeNulls}" enable-console="${!this.hideExecution}" accept="${accept}" render-style="${this.renderStyle}" schema-style="${this.displaySchemaAsTable ? 'table' : 'tree'}" schema-expand-level="${this.schemaExpandLevel}" schema-hide-read-only="${this.schemaHideReadOnly}" fetch-credentials="${this.fetchCredentials}" @scrollToSchemaComponentByName="${v => this.scrollToSchemaComponentByName(v)}" exportparts="btn btn-fill btn-outline btn-try"> </api-request> </div> ${path.callbacks ? callbackTemplate.call(this, path.callbacks) : ''} <api-response class="request response" .responses="${path.responses}" display-nulls="${!!this.includeNulls}" active-schema-tab="${this.defaultSchemaTab}" render-style="${this.renderStyle}" schema-style="${this.displaySchemaAsTable ? 'table' : 'tree'}" schema-expand-level="${this.schemaExpandLevel}" schema-hide-write-only="${this.schemaHideWriteOnly}" selected-status="${Object.keys(path.responses || {})[0] || ''}" @scrollToSchemaComponentByName="${v => this.scrollToSchemaComponentByName(v)}" exportparts="btn--resp btn-fill--resp btn-outline--resp"> </api-response> </div> </div>`;
|
73
63
|
}
|
74
|
-
|
75
64
|
export default function endpointTemplate() {
|
76
65
|
return html` <div style="display:flex;justify-content:flex-end;padding-right:1rem;font-size:14px;margin-top:16px"> <span @click="${e => expandCollapseAll.call(this, e, true)}" style="color:var(--primary-color);cursor:pointer">Expand</span> | <span @click="${e => expandCollapseAll.call(this, e, false)}" style="color:var(--primary-color);cursor:pointer">Collapse</span> </div> ${(this.resolvedSpec && this.resolvedSpec.tags || []).map(tag => html` <div class="regular-font method-section-gap section-tag ${tag.expanded ? 'expanded' : 'collapsed'}"> <div class="section-tag-header" @click="${e => toggleTag.call(this, e, tag.elementId)}"> <div id="${tag.elementId}" class="sub-title tag" style="color:var(--primary-color)">${tag.name}</div> </div> <div class="section-tag-body"> <slot name="${tag.elementId}"></slot> ${tag.description ? html` <div class="regular-font regular-font-size m-markdown description" style="padding-bottom:12px"> ${unsafeHTML(marked(tag.description || ''))} </div>` : ''} ${tag.paths.filter(v => pathIsInSearch(this.matchPaths, v)).map(path => html` <section id="${path.elementId}" class="m-endpoint regular-font ${path.method} ${path.expanded ? 'expanded' : 'collapsed'}"> ${endpointHeadTemplate.call(this, path)} ${path.expanded ? endpointBodyTemplate.call(this, path) : ''} </section>`)} </div> </div> `)}`;
|
77
66
|
}
|
@@ -6,26 +6,23 @@ import codeSamplesTemplate from './code-samples-template.js';
|
|
6
6
|
import callbackTemplate from './callback-template.js';
|
7
7
|
import '../components/api-request.js';
|
8
8
|
import '../components/api-response.js';
|
9
|
-
/* eslint-disable indent */
|
10
9
|
|
10
|
+
/* eslint-disable indent */
|
11
11
|
export function expandedEndpointBodyTemplate(path, tagName = '') {
|
12
12
|
var _path$servers, _path$servers$, _this$selectedServer;
|
13
|
-
|
14
13
|
const acceptContentTypes = new Set();
|
15
|
-
|
16
14
|
for (const respStatus in path.responses) {
|
17
15
|
for (const acceptContentType in (_path$responses$respS = path.responses[respStatus]) === null || _path$responses$respS === void 0 ? void 0 : _path$responses$respS.content) {
|
18
16
|
var _path$responses$respS;
|
19
|
-
|
20
17
|
acceptContentTypes.add(acceptContentType.trim());
|
21
18
|
}
|
22
19
|
}
|
20
|
+
const accept = [...acceptContentTypes].join(', ');
|
23
21
|
|
24
|
-
|
25
|
-
|
22
|
+
// Filter API Keys that are non-empty and are applicable to the the path
|
26
23
|
const nonEmptyApiKeys = this.resolvedSpec.securitySchemes.filter(v => v.finalKeyValue && path.security && path.security.some(ps => ps[v.apiKeyId])) || [];
|
27
24
|
const codeSampleTabPanel = path.xCodeSamples ? codeSamplesTemplate.call(this, path.xCodeSamples) : '';
|
28
|
-
return html` ${this.renderStyle === 'read' ? html`<div class="divider" part="operation-divider"></div>` : ''} <div class="expanded-endpoint-body observe-me ${path.method}" part="section-operation ${path.elementId}" id="${path.elementId}"> ${this.renderStyle === 'focused' && tagName && tagName !== 'General ⦂' ? html`<h3 class="upper" style="font-weight:700"> ${tagName} </h3>` : ''} ${path.deprecated ? html`<div class="bold-text red-text"> DEPRECATED </div>` : ''} <div style="display:flex;justify-content:space-between"> <div style="flex-grow:1"> <h2>${path.shortSummary || `${path.method.toUpperCase()} ${path.path}`}</h2> <div class='mono-font part="section-operation-url" regular-font-size' style="padding:8px 0;color:var(--fg3)"> ${path.isWebhook ? html`<span style="color:var(--primary-color)"> WEBHOOK </span>` : ''} <span part="label-operation-method" class="regular-font upper method-fg bold-text ${path.method}">${path.method}</span> <span part="label-operation-path">${path.path}</span> </div> </div> ${path.externalDocs ? html`<div class="m-markdown" style="margin-top:2rem;margin-bottom:.5rem;max-width:300px"> ${unsafeHTML(marked(path.externalDocs.description || ''))} <a href="${path.externalDocs.url}">Navigate to documentation ↗</a> </div>` : ''} </div> <div class="m-markdown" style="margin-right:2rem"> ${unsafeHTML(marked(path.description || ''))}</div> <slot name="${path.elementId}"></slot> <slot name="path-details" data-method="${path.method}" data-path="${path.path}"></slot> ${pathSecurityTemplate.call(this, path.security)} ${codeSampleTabPanel} <div class="expanded-req-resp-container"> <api-request class="request-panel" method="${path.method}" path="${path.path}" element-id="${path.elementId}" .parameters="${path.parameters}" .request_body="${path.requestBody}" .api_keys="${nonEmptyApiKeys}" .servers="${path.servers}" server-url="${((_path$servers = path.servers) === null || _path$servers === void 0 ? void 0 : (_path$servers$ = _path$servers[0]) === null || _path$servers$ === void 0 ? void 0 : _path$servers$.url) || ((_this$selectedServer = this.selectedServer) === null || _this$selectedServer === void 0 ? void 0 : _this$selectedServer.computedUrl)}" fill-defaults="${!this.hideDefaults}" display-nulls="${!!this.includeNulls}" enable-console="${!this.hideExecution}" accept="${accept}" render-style="${this.renderStyle}" schema-style="${this.displaySchemaAsTable ? 'table' : 'tree'}" active-schema-tab="${this.defaultSchemaTab}" schema-expand-level="${this.schemaExpandLevel}" schema-hide-read-only="${this.schemaHideReadOnly}" fetch-credentials="${this.fetchCredentials}" exportparts="btn btn-fill btn-outline btn-try"> </api-request> ${path.callbacks ? callbackTemplate.call(this, path.callbacks) : ''} <api-response class="response-panel" .responses="${path.responses}" display-nulls="${!!this.includeNulls}" render-style="${this.renderStyle}" schema-style="${this.displaySchemaAsTable ? 'table' : 'tree'}" active-schema-tab="${this.defaultSchemaTab}" schema-expand-level="${this.schemaExpandLevel}" schema-hide-write-only="${this.schemaHideWriteOnly}" selected-status="${Object.keys(path.responses || {})[0] || ''}" exportparts="btn--resp btn-fill--resp btn-outline--resp"> </api-response> </div> </div>`;
|
25
|
+
return html` ${this.renderStyle === 'read' ? html`<div class="divider" part="operation-divider"></div>` : ''} <div class="expanded-endpoint-body observe-me ${path.method}" part="section-operation ${path.elementId}" id="${path.elementId}"> ${this.renderStyle === 'focused' && tagName && tagName !== 'General ⦂' ? html`<h3 class="upper" style="font-weight:700"> ${tagName} </h3>` : ''} ${path.deprecated ? html`<div class="bold-text red-text"> DEPRECATED </div>` : ''} <div style="display:flex;justify-content:space-between"> <div style="flex-grow:1"> <h2>${path.shortSummary || `${path.method.toUpperCase()} ${path.path}`}</h2> <div class='mono-font part="section-operation-url" regular-font-size' style="padding:8px 0;color:var(--fg3)"> ${path.isWebhook ? html`<span style="color:var(--primary-color)"> WEBHOOK </span>` : ''} <span part="label-operation-method" class="regular-font upper method-fg bold-text ${path.method}">${path.method}</span> <span part="label-operation-path">${path.path}</span> </div> </div> ${path.externalDocs ? html`<div class="m-markdown" style="margin-top:2rem;margin-bottom:.5rem;max-width:300px"> ${unsafeHTML(marked(path.externalDocs.description || ''))} <a href="${path.externalDocs.url}">Navigate to documentation ↗</a> </div>` : ''} </div> <div class="m-markdown" style="margin-right:2rem"> ${unsafeHTML(marked(path.description || ''))}</div> <slot name="${path.elementId}"></slot> <slot name="path-details" data-method="${path.method}" data-path="${path.path}"></slot> ${pathSecurityTemplate.call(this, path.security)} ${codeSampleTabPanel} <div class="expanded-req-resp-container"> <api-request class="request-panel" method="${path.method}" path="${path.path}" element-id="${path.elementId}" .parameters="${path.parameters}" .request_body="${path.requestBody}" .api_keys="${nonEmptyApiKeys}" .servers="${path.servers}" server-url="${((_path$servers = path.servers) === null || _path$servers === void 0 ? void 0 : (_path$servers$ = _path$servers[0]) === null || _path$servers$ === void 0 ? void 0 : _path$servers$.url) || ((_this$selectedServer = this.selectedServer) === null || _this$selectedServer === void 0 ? void 0 : _this$selectedServer.computedUrl)}" fill-defaults="${!this.hideDefaults}" display-nulls="${!!this.includeNulls}" enable-console="${!this.hideExecution}" accept="${accept}" render-style="${this.renderStyle}" schema-style="${this.displaySchemaAsTable ? 'table' : 'tree'}" active-schema-tab="${this.defaultSchemaTab}" schema-expand-level="${this.schemaExpandLevel}" schema-hide-read-only="${this.schemaHideReadOnly}" fetch-credentials="${this.fetchCredentials}" @scrollToSchemaComponentByName="${v => this.scrollToSchemaComponentByName(v)}" exportparts="btn btn-fill btn-outline btn-try"> </api-request> ${path.callbacks ? callbackTemplate.call(this, path.callbacks) : ''} <api-response class="response-panel" .responses="${path.responses}" display-nulls="${!!this.includeNulls}" render-style="${this.renderStyle}" schema-style="${this.displaySchemaAsTable ? 'table' : 'tree'}" active-schema-tab="${this.defaultSchemaTab}" schema-expand-level="${this.schemaExpandLevel}" schema-hide-write-only="${this.schemaHideWriteOnly}" selected-status="${Object.keys(path.responses || {})[0] || ''}" @scrollToSchemaComponentByName="${v => this.scrollToSchemaComponentByName(v)}" exportparts="btn--resp btn-fill--resp btn-outline--resp"> </api-response> </div> </div>`;
|
29
26
|
}
|
30
27
|
export function expandedTagTemplate(tagId, subsectionFullId) {
|
31
28
|
const tag = (this.resolvedSpec.tags || []).find(t => t.elementId === tagId);
|
@@ -6,33 +6,27 @@ import componentsTemplate from './components-template.js';
|
|
6
6
|
import overviewTemplate from './overview-template.js';
|
7
7
|
import serverTemplate from './server-template.js';
|
8
8
|
import securitySchemeTemplate from './security-scheme-template.js';
|
9
|
-
|
10
9
|
function wrapFocusedTemplate(templateToWrap) {
|
11
10
|
return html` <div class="regular-font section-gap--focused-mode" part="section-operations-in-tag"> ${templateToWrap} </div>`;
|
12
11
|
}
|
13
|
-
|
14
12
|
function defaultContentTemplate() {
|
15
13
|
// In focused mode default content is overview or first path
|
16
14
|
if (!this.hideInfo) {
|
17
15
|
return overviewTemplate.call(this);
|
18
16
|
}
|
19
|
-
|
20
17
|
const selectedTagObj = this.resolvedSpec.tags[0];
|
21
18
|
const selectedPathObj = selectedTagObj === null || selectedTagObj === void 0 ? void 0 : selectedTagObj.paths[0];
|
22
19
|
return selectedPathObj ? wrapFocusedTemplate(expandedEndpointBodyTemplate.call(this, selectedPathObj, selectedTagObj.name)) : wrapFocusedTemplate('');
|
23
20
|
}
|
24
|
-
|
25
21
|
export default function focusedEndpointTemplate() {
|
26
22
|
if (!this.explorerLocation || !this.resolvedSpec) {
|
27
23
|
return undefined;
|
28
24
|
}
|
29
|
-
|
30
25
|
const focusElId = this.explorerLocation;
|
31
26
|
let selectedPathObj = null;
|
32
27
|
let selectedTagObj = null;
|
33
28
|
let focusedTemplate;
|
34
29
|
let i = 0;
|
35
|
-
|
36
30
|
if (focusElId.startsWith('overview') && !this.hideInfo) {
|
37
31
|
focusedTemplate = overviewTemplate.call(this);
|
38
32
|
} else if (focusElId === 'auth' && !this.hideAuthentication) {
|
@@ -46,7 +40,6 @@ export default function focusedEndpointTemplate() {
|
|
46
40
|
} else if (focusElId.startsWith('tag--')) {
|
47
41
|
const idToFocus = focusElId.indexOf('--', 4) > 0 ? focusElId.substring(0, focusElId.indexOf('--', 5)) : focusElId;
|
48
42
|
selectedTagObj = this.resolvedSpec.tags.find(v => v.elementId === idToFocus);
|
49
|
-
|
50
43
|
if (selectedTagObj) {
|
51
44
|
focusedTemplate = expandedTagTemplate.call(this, idToFocus, focusElId);
|
52
45
|
} else {
|
@@ -56,12 +49,10 @@ export default function focusedEndpointTemplate() {
|
|
56
49
|
for (i = 0; i < this.resolvedSpec.tags.length; i += 1) {
|
57
50
|
selectedTagObj = this.resolvedSpec.tags[i];
|
58
51
|
selectedPathObj = this.resolvedSpec.tags[i].paths.find(v => `${v.elementId}` === focusElId);
|
59
|
-
|
60
52
|
if (selectedPathObj) {
|
61
53
|
break;
|
62
54
|
}
|
63
55
|
}
|
64
|
-
|
65
56
|
if (selectedPathObj) {
|
66
57
|
focusedTemplate = wrapFocusedTemplate.call(this, expandedEndpointBodyTemplate.call(this, selectedPathObj, selectedTagObj.name));
|
67
58
|
} else {
|
@@ -69,7 +60,6 @@ export default function focusedEndpointTemplate() {
|
|
69
60
|
focusedTemplate = defaultContentTemplate.call(this);
|
70
61
|
}
|
71
62
|
}
|
72
|
-
|
73
63
|
return focusedTemplate;
|
74
64
|
}
|
75
65
|
/* eslint-enable indent */
|
@@ -1,5 +1,6 @@
|
|
1
|
-
import { html } from 'lit';
|
1
|
+
import { html } from 'lit';
|
2
2
|
|
3
|
+
// Templates
|
3
4
|
import focusedEndpointTemplate from './focused-endpoint-template.js';
|
4
5
|
import overviewTemplate from './overview-template.js';
|
5
6
|
import endpointTemplate from './endpoint-template.js';
|
@@ -22,8 +23,8 @@ export default function mainBodyTemplate() {
|
|
22
23
|
navHoverBgColor: ColorUtils.isValidHexColor(this.navHoverBgColor) ? this.navHoverBgColor : '',
|
23
24
|
navHoverTextColor: ColorUtils.isValidHexColor(this.navHoverTextColor) ? this.navHoverTextColor : ''
|
24
25
|
};
|
25
|
-
/* eslint-disable indent */
|
26
26
|
|
27
|
+
/* eslint-disable indent */
|
27
28
|
return html` ${SetTheme.call(this, newTheme)} ${this.hideSearch ? '' : advancedSearchTemplate.call(this)} <div id="the-main-body" class="body"> ${this.renderStyle === 'focused' && this.resolvedSpec ? navbarTemplate.call(this) : ''} ${this.loading === true ? html`<slot name="loader"><div class="loader"></div></slot>` : html` <main class="main-content regular-font" part="section-main-content"> <slot></slot> <div id="operations-root" class="main-content-inner"> ${this.loadFailed === true ? html`<div style="text-align:center;margin:16px">Unable to load the Spec${this.specUrl ? ': ' : ''}<strong>${this.specUrl}</strong></div>` : html` <div class="operations-root" @click="${e => {
|
28
29
|
this.handleHref(e);
|
29
30
|
}}"> ${this.renderStyle === 'focused' ? html`${focusedEndpointTemplate.call(this)}` : html` ${!this.hideInfo ? overviewTemplate.call(this) : ''} ${!this.hideServerSelection ? serverTemplate.call(this) : ''} ${!this.hideAuthentication ? securitySchemeTemplate.call(this) : ''} <section id="section" class="observe-me ${this.renderStyle === 'focused' ? 'section-gap--focused-mode' : 'section-gap'}"> <slot name="custom-section"></slot> </section> ${endpointTemplate.call(this)}`} </div> `}</div></main>`} </div> <slot name="footer"></slot> `;
|
@@ -3,23 +3,18 @@ import { marked } from 'marked';
|
|
3
3
|
import { componentIsInSearch, pathIsInSearch } from '../utils/common-utils.js';
|
4
4
|
import { getI18nText } from '../languages/index.js';
|
5
5
|
import { expandCollapseComponent } from './endpoint-template.js';
|
6
|
-
|
6
|
+
import { getComponentInfo } from './components-template.js';
|
7
7
|
function onExpandCollapse(tagId) {
|
8
8
|
const tag = this.resolvedSpec.tags.find(t => t.elementId === tagId);
|
9
|
-
|
10
9
|
if (!tag) {
|
11
10
|
return;
|
12
11
|
}
|
13
|
-
|
14
12
|
tag.expanded = !tag.expanded;
|
15
|
-
|
16
13
|
if (tag.expanded && this.operationsCollapsed) {
|
17
14
|
this.resolvedSpec.tags.filter(t => t.elementId !== tagId).forEach(t => t.expanded = false);
|
18
15
|
}
|
19
|
-
|
20
16
|
this.requestUpdate();
|
21
17
|
}
|
22
|
-
|
23
18
|
export function expandCollapseAll() {
|
24
19
|
const expand = this.operationsCollapsed;
|
25
20
|
this.operationsCollapsed = !expand;
|
@@ -36,20 +31,22 @@ export function expandCollapseAllComponents() {
|
|
36
31
|
});
|
37
32
|
this.requestUpdate();
|
38
33
|
}
|
39
|
-
/* eslint-disable indent */
|
40
34
|
|
35
|
+
/* eslint-disable indent */
|
41
36
|
export default function navbarTemplate() {
|
42
37
|
var _this$resolvedSpec$co;
|
43
|
-
|
44
38
|
return html` <nav class="nav-bar ${this.renderStyle}" part="section-navbar"> <slot name="nav-header"></slot> ${this.hideSearch ? '' : html` <div style="display:flex;flex-direction:row;justify-content:center;align-items:center;padding:24px"> <div style="display:flex;flex:1;line-height:22px"> <input id="nav-bar-search" part="textbox textbox-nav-filter" style="width:100%;padding-right:20px;color:var(--nav-hover-text-color);border-color:var(--secondary-color);background-color:var(--nav-hover-bg-color)" type="text" placeholder="${getI18nText('menu.filter')}" @input="${this.onSearchChange}" spellcheck="false"> </div> <button class="m-btn outline-primary" part="btn btn-fill btn-search" style="margin-left:5px" @click="${this.onShowSearchModalClicked}"> ${getI18nText('menu.search')} </button> </div> `} ${html`<nav class="nav-scroll" part="navbar-scroll"> ${this.hideInfo || !this.resolvedSpec.info ? '' : html`<div class="nav-bar-info" id="link-overview" data-content-id="overview" @click="${e => this.scrollToEventTarget(e, false)}"> ${this.resolvedSpec.info.title || getI18nText('menu.overview')} </div>`} ${this.hideServerSelection ? '' : html`<div class="nav-bar-info" id="link-servers" data-content-id="servers" @click="${e => this.scrollToEventTarget(e, false)}"> ${getI18nText('menu.api-servers')} </div>`} ${this.hideAuthentication || !this.resolvedSpec.securitySchemes ? '' : html`<div class="nav-bar-info" id="link-auth" data-content-id="auth" @click="${e => this.scrollToEventTarget(e, false)}"> ${getI18nText('menu.authentication')} </div>`} <slot name="nav-section" class="custom-nav-section" data-content-id="section" @click="${e => this.scrollToCustomNavSectionTarget(e, false)}"></slot> <div class="sticky-scroll-element ${this.operationsCollapsed ? 'collapsed' : ''}" @click="${() => {
|
45
39
|
expandCollapseAll.call(this);
|
46
40
|
}}"> <div class="nav-bar-section" part="navbar-operations-header"> <slot name="operations-header"> <div class="nav-bar-section-title">${getI18nText('menu.operations')}</div> </slot> <div style="" part="navbar-operations-header-collapse"> ${this.resolvedSpec.tags.length > 1 && this.resolvedSpec.tags.some(tag => !tag.paths.length && !this.matchPaths || tag.paths.some(path => pathIsInSearch(this.matchPaths, path))) ? html` <div class="toggle">▾</div>` : ''} </div> </div> </div> ${this.resolvedSpec.tags.filter(tag => !tag.paths.length && !this.matchPaths || tag.paths.some(path => pathIsInSearch(this.matchPaths, path))).map(tag => html` <slot name="nav-${tag.elementId}"> <div class="nav-bar-tag-and-paths ${tag.expanded ? '' : 'collapsed'}"> ${tag.name === 'General ⦂' ? html`` : html` <div class="nav-bar-tag" id="link-${tag.elementId}" data-content-id="${tag.elementId}" @click="${() => {
|
47
41
|
onExpandCollapse.call(this, tag.elementId);
|
48
42
|
}}"> <div style="display:flex;justify-content:space-between;width:100%"> <div style="margin-right:.5rem">${tag.name}</div> <div class="toggle">▾</div> </div> </div> `} <div class="nav-bar-section-wrapper"> <div> ${tag.headers.map(header => html` <div class="nav-bar-h${header.depth}" id="link-${tag.elementId}--${new marked.Slugger().slug(header.text)}" data-content-id="${tag.elementId}--${new marked.Slugger().slug(header.text)}" @click="${e => this.scrollToEventTarget(e, false)}"> ${header.text} </div>`)} </div> <div class="nav-bar-paths-under-tag"> ${tag.paths.filter(v => pathIsInSearch(this.matchPaths, v)).map(p => html` <div class="nav-bar-path ${this.usePathInNavBar ? 'small-font' : ''}" data-content-id="${p.elementId}" id="link-${p.elementId}" @click="${e => {
|
49
43
|
this.scrollToEventTarget(e, false);
|
50
|
-
}}"> <span style="${p.deprecated ? 'filter:opacity(0.5)' : ''}"> ${this.usePathInNavBar ? html`<div class="mono-font" style="display:flex;align-items:center"> <div class="method ${p.method}"><span style="line-height:1">${p.method}</span></div> <div style="display:flex;flex-wrap:wrap">${p.path.split('/').filter(t => t.trim()).map(t => html`<span>/${t}</span>`)}</div> </div>` : p.summary || p.shortSummary} ${p.isWebhook ? '(Webhook)' : ''} </span> </div>`)} </div> </div> </div> </slot> `)} ${(_this$resolvedSpec$co = this.resolvedSpec.components) !== null && _this$resolvedSpec$co !== void 0 && _this$resolvedSpec$co.length && !this.hideComponents ? html` <div class="sticky-scroll-element"> <div id="link-components" class="nav-bar-section"> <slot name="components-header"> <div class="nav-bar-section-title">${getI18nText('menu.components')}</div> </slot> </div> </div> ${this.resolvedSpec.components.filter(c => c.subComponents.some(s => componentIsInSearch(this.matchPaths, s))).map(component =>
|
51
|
-
|
52
|
-
|
53
|
-
|
44
|
+
}}"> <span style="${p.deprecated ? 'filter:opacity(0.5)' : ''}"> ${this.usePathInNavBar ? html`<div class="mono-font" style="display:flex;align-items:center"> <div class="method ${p.method}"><span style="line-height:1">${p.method}</span></div> <div style="display:flex;flex-wrap:wrap">${p.path.split('/').filter(t => t.trim()).map(t => html`<span>/${t}</span>`)}</div> </div>` : p.summary || p.shortSummary} ${p.isWebhook ? '(Webhook)' : ''} </span> </div>`)} </div> </div> </div> </slot> `)} ${(_this$resolvedSpec$co = this.resolvedSpec.components) !== null && _this$resolvedSpec$co !== void 0 && _this$resolvedSpec$co.length && !this.hideComponents ? html` <div class="sticky-scroll-element"> <div id="link-components" class="nav-bar-section"> <slot name="components-header"> <div class="nav-bar-section-title">${getI18nText('menu.components')}</div> </slot> </div> </div> ${this.resolvedSpec.components.filter(c => c.subComponents.some(s => componentIsInSearch(this.matchPaths, s))).map(component => {
|
45
|
+
const componentInfo = getComponentInfo(component.componentKeyId);
|
46
|
+
return html` <div class="nav-bar-tag-and-paths ${component.expanded ? '' : 'collapsed'}"> <div class="nav-bar-tag" data-content-id="cmp--${componentInfo.name.toLowerCase()}" id="link-cmp--${componentInfo.name.toLowerCase()}" @click="${e => {
|
47
|
+
expandCollapseComponent.call(this, component);
|
48
|
+
this.scrollToEventTarget(e, false);
|
49
|
+
}}"> <div> ${componentInfo.name} </div> <div style="" part="navbar-components-header-collapse"> <div class="toggle">▾</div> </div> </div> <div class="nav-bar-section-wrapper"> <div class="nav-bar-paths-under-tag"> ${component.subComponents.filter(s => componentIsInSearch(this.matchPaths, s)).map(p => html` <div class="nav-bar-path" data-content-id="cmp--${p.id}" id="link-cmp--${p.id}" @click="${e => this.scrollToEventTarget(e, false)}"> <span> ${p.name} </span> </div>`)} </div> </div> </div>`;
|
50
|
+
})}` : ''} </nav>`} </nav> `;
|
54
51
|
}
|
55
52
|
/* eslint-enable indent */
|
@@ -2,9 +2,9 @@ import { html } from 'lit';
|
|
2
2
|
import { unsafeHTML } from 'lit/directives/unsafe-html.js';
|
3
3
|
import { marked } from 'marked';
|
4
4
|
import { getI18nText } from '../languages/index.js';
|
5
|
-
/* eslint-disable indent */
|
6
5
|
|
6
|
+
/* eslint-disable indent */
|
7
7
|
export default function overviewTemplate() {
|
8
|
-
return html` <section id="overview" part="section-overview" class="observe-me ${this.renderStyle === 'focused' ? 'section-gap--focused-mode' : 'section-gap'}"> ${this.resolvedSpec && this.resolvedSpec.info ? html` <slot name="overview"> <div id="api-title" part="label-overview-title" style="font-size:32px" class="section-padding"> ${this.resolvedSpec.info.title} ${!this.resolvedSpec.info.version ? '' : html` <span style="font-size:var(--font-size-small);font-weight:700"> ${this.resolvedSpec.info.version} </span>`} </div> <div id="api-info" style="font-size:calc(var(--font-size-regular) - 1px);margin-top:8px" class="section-padding"> ${this.resolvedSpec.info.contact && this.resolvedSpec.info.contact.email ? html`<span>${this.resolvedSpec.info.contact.name || getI18nText('overview.email')}: <a href="mailto:${this.resolvedSpec.info.contact.email}" part="anchor anchor-overview">${this.resolvedSpec.info.contact.email}</a> </span>` : ''} ${this.resolvedSpec.info.contact && this.resolvedSpec.info.contact.url ? html`<span>URL: <a href="${this.resolvedSpec.info.contact.url}" part="anchor anchor-overview">${this.resolvedSpec.info.contact.url}</a></span>` : ''} ${this.resolvedSpec.info.license ? html`<span>License: ${this.resolvedSpec.info.license.url ? html`<a href="${this.resolvedSpec.info.license.url}" part="anchor anchor-overview">${this.resolvedSpec.info.license.name}</a>` : this.resolvedSpec.info.license.name} </span>` : ''} ${this.resolvedSpec.info.termsOfService ? html`<span><a href="${this.resolvedSpec.info.termsOfService}" part="anchor anchor-overview">${getI18nText('overview.terms-of-service')}</a></span>` : ''} </div> </slot> <slot name="overview-api-description"> ${this.resolvedSpec.info.description ? html`${unsafeHTML(`<div class="m-markdown regular-font section-padding">${marked(this.resolvedSpec.info.description)}</div>`)}` : ''} </slot> ` : ''} </section> `;
|
8
|
+
return html` <section id="overview" part="section-overview" class="observe-me ${this.renderStyle === 'focused' ? 'section-gap--focused-mode' : 'section-gap'}"> ${this.resolvedSpec && this.resolvedSpec.info ? html` <slot name="overview-header"></slot> <slot name="overview"> <div id="api-title" part="label-overview-title" style="font-size:32px" class="section-padding"> ${this.resolvedSpec.info.title} ${!this.resolvedSpec.info.version ? '' : html` <span style="font-size:var(--font-size-small);font-weight:700"> ${this.resolvedSpec.info.version} </span>`} </div> <div id="api-info" style="font-size:calc(var(--font-size-regular) - 1px);margin-top:8px" class="section-padding"> ${this.resolvedSpec.info.contact && this.resolvedSpec.info.contact.email ? html`<span>${this.resolvedSpec.info.contact.name || getI18nText('overview.email')}: <a href="mailto:${this.resolvedSpec.info.contact.email}" part="anchor anchor-overview">${this.resolvedSpec.info.contact.email}</a> </span>` : ''} ${this.resolvedSpec.info.contact && this.resolvedSpec.info.contact.url ? html`<span>URL: <a href="${this.resolvedSpec.info.contact.url}" part="anchor anchor-overview">${this.resolvedSpec.info.contact.url}</a></span>` : ''} ${this.resolvedSpec.info.license ? html`<span>License: ${this.resolvedSpec.info.license.url ? html`<a href="${this.resolvedSpec.info.license.url}" part="anchor anchor-overview">${this.resolvedSpec.info.license.name}</a>` : this.resolvedSpec.info.license.name} </span>` : ''} ${this.resolvedSpec.info.termsOfService ? html`<span><a href="${this.resolvedSpec.info.termsOfService}" part="anchor anchor-overview">${getI18nText('overview.terms-of-service')}</a></span>` : ''} </div> </slot> <slot name="overview-body"></slot> <slot name="overview-api-description"> ${this.resolvedSpec.info.description ? html`${unsafeHTML(`<div class="m-markdown regular-font section-padding">${marked(this.resolvedSpec.info.description)}</div>`)}` : ''} </slot> <slot name="overview-footer"></slot> ` : ''} </section> `;
|
9
9
|
}
|
10
10
|
/* eslint-enable indent */
|