openapi-explorer 0.9.344 → 0.9.346
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/CHANGELOG.md +1 -0
- package/dist/browser/openapi-explorer.min.js +5 -5
- package/dist/es/openapi-explorer.js +19 -25
- package/dist/es/templates/endpoint-template.js +1 -7
- package/dist/es/templates/navbar-template.js +25 -16
- package/dist/es/utils/common-utils.js +5 -1
- package/dist/lib/openapi-explorer.js +18 -24
- package/dist/lib/templates/endpoint-template.js +1 -7
- package/dist/lib/templates/navbar-template.js +26 -15
- package/dist/lib/utils/common-utils.js +5 -1
- package/package.json +1 -1
|
@@ -22,7 +22,7 @@ import TabStyles from './styles/tab-styles';
|
|
|
22
22
|
import NavStyles from './styles/nav-styles';
|
|
23
23
|
import InfoStyles from './styles/info-styles';
|
|
24
24
|
import advancedSearchStyles from './styles/advanced-search-styles';
|
|
25
|
-
import { advancedSearch, getCurrentElement,
|
|
25
|
+
import { advancedSearch, getCurrentElement, replaceState, sleep } from './utils/common-utils';
|
|
26
26
|
import ProcessSpec from './utils/spec-parser';
|
|
27
27
|
import responsiveViewMainBodyTemplate from './templates/responsiveViewMainBodyTemplate';
|
|
28
28
|
import apiRequestStyles from './styles/api-request-styles';
|
|
@@ -74,10 +74,16 @@ export default class OpenApiExplorer extends LitElement {
|
|
|
74
74
|
layout: {
|
|
75
75
|
type: String
|
|
76
76
|
},
|
|
77
|
-
|
|
77
|
+
collapsed: {
|
|
78
78
|
type: Boolean,
|
|
79
79
|
attribute: 'collapse'
|
|
80
80
|
},
|
|
81
|
+
operationsCollapsed: {
|
|
82
|
+
type: Boolean
|
|
83
|
+
},
|
|
84
|
+
componentsCollapsed: {
|
|
85
|
+
type: Boolean
|
|
86
|
+
},
|
|
81
87
|
defaultSchemaTab: {
|
|
82
88
|
type: String,
|
|
83
89
|
attribute: 'default-schema-tab'
|
|
@@ -251,6 +257,8 @@ export default class OpenApiExplorer extends LitElement {
|
|
|
251
257
|
}
|
|
252
258
|
|
|
253
259
|
this.renderStyle = 'focused';
|
|
260
|
+
this.operationsCollapsed = this.collapsed;
|
|
261
|
+
this.componentsCollapsed = this.collapsed;
|
|
254
262
|
this.explorerLocation = this.explorerLocation || getCurrentElement();
|
|
255
263
|
|
|
256
264
|
if (!this.defaultSchemaTab || !'body, model,'.includes(`${this.defaultSchemaTab},`)) {
|
|
@@ -395,29 +403,16 @@ export default class OpenApiExplorer extends LitElement {
|
|
|
395
403
|
}, 0);
|
|
396
404
|
}
|
|
397
405
|
|
|
406
|
+
if (name === 'collapsed') {
|
|
407
|
+
this.operationsCollapsed = newVal;
|
|
408
|
+
this.componentsCollapsed = newVal;
|
|
409
|
+
}
|
|
410
|
+
|
|
398
411
|
super.attributeChangedCallback(name, oldVal, newVal);
|
|
399
412
|
}
|
|
400
413
|
|
|
401
414
|
onSearchChange(e) {
|
|
402
|
-
this.operationsCollapsed = false;
|
|
403
415
|
this.matchPaths = e.target.value;
|
|
404
|
-
this.resolvedSpec.tags.forEach(tag => tag.paths.filter(v => {
|
|
405
|
-
if (this.matchPaths) {
|
|
406
|
-
// v.expanded = false;
|
|
407
|
-
if (pathIsInSearch(this.matchPaths, v)) {
|
|
408
|
-
tag.expanded = true;
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
}));
|
|
412
|
-
this.resolvedSpec.components.forEach(component => {
|
|
413
|
-
component.subComponents.forEach(subComponent => {
|
|
414
|
-
subComponent.expanded = false;
|
|
415
|
-
|
|
416
|
-
if (!this.matchPaths || componentIsInSearch(this.matchPaths, subComponent)) {
|
|
417
|
-
subComponent.expanded = true;
|
|
418
|
-
}
|
|
419
|
-
});
|
|
420
|
-
});
|
|
421
416
|
this.requestUpdate();
|
|
422
417
|
}
|
|
423
418
|
|
|
@@ -425,11 +420,6 @@ export default class OpenApiExplorer extends LitElement {
|
|
|
425
420
|
const searchEl = this.shadowRoot.getElementById('nav-bar-search');
|
|
426
421
|
searchEl.value = '';
|
|
427
422
|
this.matchPaths = '';
|
|
428
|
-
this.resolvedSpec.components.forEach(component => {
|
|
429
|
-
component.subComponents.forEach(v => {
|
|
430
|
-
v.expanded = true;
|
|
431
|
-
});
|
|
432
|
-
});
|
|
433
423
|
}
|
|
434
424
|
|
|
435
425
|
async onShowSearchModalClicked() {
|
|
@@ -516,6 +506,10 @@ export default class OpenApiExplorer extends LitElement {
|
|
|
516
506
|
this.resolvedSpec.tags.forEach(t => t.expanded = false);
|
|
517
507
|
}
|
|
518
508
|
|
|
509
|
+
if (this.componentsCollapsed) {
|
|
510
|
+
this.resolvedSpec.components.forEach(c => c.expanded = false);
|
|
511
|
+
}
|
|
512
|
+
|
|
519
513
|
this.dispatchEvent(new CustomEvent('spec-loaded', {
|
|
520
514
|
bubbles: true,
|
|
521
515
|
detail: spec
|
|
@@ -83,12 +83,6 @@ export default function endpointTemplate() {
|
|
|
83
83
|
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, 'expand-all')}" style="color:var(--primary-color);cursor:pointer">Expand</span> | <span @click="${e => expandCollapseAll.call(this, e, 'collapse-all')}" 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
|
|
84
84
|
<div class="regular-font regular-font-size m-markdown" style="padding-bottom:12px">
|
|
85
85
|
${unsafeHTML(marked(tag.description || ''))}
|
|
86
|
-
</div>` : ''} ${tag.paths.filter(v => {
|
|
87
|
-
if (this.matchPaths) {
|
|
88
|
-
return pathIsInSearch(this.matchPaths, v);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return true;
|
|
92
|
-
}).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> `)}`;
|
|
86
|
+
</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> `)}`;
|
|
93
87
|
}
|
|
94
88
|
/* eslint-enable indent */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { html } from 'lit-element';
|
|
2
|
-
import { pathIsInSearch } from '../utils/common-utils';
|
|
2
|
+
import { componentIsInSearch, pathIsInSearch } from '../utils/common-utils';
|
|
3
3
|
|
|
4
4
|
function onExpandCollapse(tagId) {
|
|
5
5
|
const tag = this.resolvedSpec.tags.find(t => t.elementId === tagId);
|
|
@@ -20,27 +20,36 @@ function onExpandCollapse(tagId) {
|
|
|
20
20
|
export function expandCollapseAll() {
|
|
21
21
|
const expand = this.operationsCollapsed;
|
|
22
22
|
this.operationsCollapsed = !expand;
|
|
23
|
-
this.resolvedSpec.tags.forEach(
|
|
24
|
-
|
|
23
|
+
this.resolvedSpec.tags.forEach(tag => {
|
|
24
|
+
tag.expanded = expand;
|
|
25
25
|
});
|
|
26
|
+
this.requestUpdate();
|
|
27
|
+
}
|
|
28
|
+
export function expandCollapseAllComponents() {
|
|
29
|
+
const expand = this.componentsCollapsed;
|
|
30
|
+
this.componentsCollapsed = !expand;
|
|
31
|
+
this.resolvedSpec.components.forEach(component => {
|
|
32
|
+
component.expanded = expand;
|
|
33
|
+
});
|
|
34
|
+
this.requestUpdate();
|
|
26
35
|
}
|
|
27
36
|
/* eslint-disable indent */
|
|
28
37
|
|
|
29
38
|
export default function navbarTemplate() {
|
|
30
|
-
|
|
31
|
-
expandCollapseAll.call(this, e);
|
|
32
|
-
}}" style="font-size:16px;transform:rotate(0);cursor:pointer">▸</div>` : html`<div @click="${e => {
|
|
33
|
-
expandCollapseAll.call(this, e);
|
|
34
|
-
}}" style="font-size:16px;transform:rotate(90deg);cursor:pointer">▸</div>`}` : ''} </div> </div> </div> ${this.resolvedSpec.tags.filter(tag => tag.paths.filter(path => pathIsInSearch(this.matchPaths, path)).length).map(tag => html` <slot name="nav-${tag.elementId}"> <div class="nav-bar-tag-and-paths ${tag.expanded ? 'expanded' : 'collapsed'}"> ${tag.name === 'General ⦂' ? html`` : html` <div class="nav-bar-tag" id="link-${tag.elementId}" data-content-id="${tag.elementId}" @click="${() => {
|
|
35
|
-
onExpandCollapse.call(this, tag.elementId);
|
|
36
|
-
}}"> <div style="display:flex;justify-content:space-between;width:100%"> <div>${tag.name}</div> <div class="nav-bar-tag-icon expand-button-arrow">▸</div> <div class="nav-bar-tag-icon collapse-button-arrow">▾</div> </div> </div> `} <div class="nav-bar-paths-under-tag"> ${tag.paths.filter(v => {
|
|
37
|
-
if (this.matchPaths) {
|
|
38
|
-
return pathIsInSearch(this.matchPaths, v);
|
|
39
|
-
}
|
|
39
|
+
var _this$resolvedSpec$co;
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
return html` <nav class="nav-bar ${this.renderStyle}" part="section-navbar"> ${this.allowSearch === 'false' && this.allowAdvancedSearch === 'false' ? '' : html` <div style="display:flex;flex-direction:row;justify-content:center;align-items:center;padding:24px;${this.allowAdvancedSearch === 'false' ? 'border-bottom: 1px solid var(--nav-hover-bg-color)' : ''}"> ${this.allowSearch === 'false' ? '' : html` <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="Filter" @change="${this.onSearchChange}" spellcheck="false"> <div style="margin:6px 5px 0 -24px;font-size:var(--font-size-regular);cursor:pointer">↩</div> </div> ${this.matchPaths ? html` <div @click="${this.onClearSearch}" style="margin-left:5px;cursor:pointer;align-self:center;color:var(--nav-text-color)" class="small-font-size primary-text bold-text"> CLEAR </div>` : ''} `} ${this.allowAdvancedSearch === 'false' || this.matchPaths ? '' : html` <button class="m-btn primary" part="btn btn-fill btn-search" style="margin-left:5px" @click="${this.onShowSearchModalClicked}"> Search </button> `} </div> `} ${html`<nav class="nav-scroll" part="navbar-scroll"> ${this.showInfo === 'false' || !this.resolvedSpec.info ? '' : html`<div class="nav-bar-info" id="link-overview" data-content-id="overview" @click="${e => this.scrollToEventTarget(e, false)}"> ${this.isV1 && this.resolvedSpec.info.title || 'Overview'} </div>`} ${this.allowServerSelection === 'false' ? '' : html`<div class="nav-bar-info" id="link-servers" data-content-id="servers" @click="${e => this.scrollToEventTarget(e, false)}"> API Servers </div>`} ${this.allowAuthentication === 'false' || !this.resolvedSpec.securitySchemes ? '' : html`<div class="nav-bar-info" id="link-auth" data-content-id="auth" @click="${e => this.scrollToEventTarget(e, false)}"> Authentication </div>`} <slot name="nav-section" class="custom-nav-section" data-content-id="section" @click="${e => this.scrollToEventTarget(e, false)}"></slot> <div class="sticky-scroll-element"> <div class="nav-bar-section" part="navbar-operations-header"> <slot name="operations-header"> <div class="nav-bar-section-title">OPERATIONS</div> </slot> <div style="" part="navbar-operations-header-collapse"> ${this.resolvedSpec.tags.length > 1 && this.resolvedSpec.tags.some(tag => tag.paths.some(path => pathIsInSearch(this.matchPaths, path))) ? html` ${this.operationsCollapsed ? html`<div @click="${() => {
|
|
42
|
+
expandCollapseAll.call(this);
|
|
43
|
+
}}" style="font-size:16px;transform:rotate(0);cursor:pointer">▸</div>` : html`<div @click="${() => {
|
|
44
|
+
expandCollapseAll.call(this);
|
|
45
|
+
}}" style="font-size:16px;transform:rotate(90deg);cursor:pointer">▸</div>`}` : ''} </div> </div> </div> ${this.resolvedSpec.tags.filter(tag => 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 ? 'expanded' : 'collapsed'}"> ${tag.name === 'General ⦂' ? html`` : html` <div class="nav-bar-tag" id="link-${tag.elementId}" data-content-id="${tag.elementId}" @click="${() => {
|
|
46
|
+
onExpandCollapse.call(this, tag.elementId);
|
|
47
|
+
}}"> <div style="display:flex;justify-content:space-between;width:100%"> <div>${tag.name}</div> <div class="nav-bar-tag-icon expand-button-arrow">▸</div> <div class="nav-bar-tag-icon collapse-button-arrow">▾</div> </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 === 'true' ? 'small-font' : ''}" data-content-id="${p.elementId}" id="link-${p.elementId}" @click="${e => {
|
|
43
48
|
this.scrollToEventTarget(e, false);
|
|
44
|
-
}}"> <span style="line-break:anywhere;${p.deprecated ? 'filter:opacity(0.5)' : ''}"> ${this.usePathInNavBar === 'true' ? html`<span class="mono-font">${p.method.toUpperCase()} ${p.path}</span>` : p.summary || p.shortSummary} ${p.isWebhook ? '(Webhook)' : ''} </span> </div>`)} </div> </div> </slot> `)} ${this.resolvedSpec.components && !this.hideComponents ? html` <div class="sticky-scroll-element"> <div id="link-components" class="nav-bar-section"> <div class="nav-bar-section-title">COMPONENTS</div> </
|
|
49
|
+
}}"> <span style="line-break:anywhere;${p.deprecated ? 'filter:opacity(0.5)' : ''}"> ${this.usePathInNavBar === 'true' ? html`<span class="mono-font">${p.method.toUpperCase()} ${p.path}</span>` : p.summary || p.shortSummary} ${p.isWebhook ? '(Webhook)' : ''} </span> </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">COMPONENTS</div> </slot> ${this.resolvedSpec.components.some(c => c.subComponents.some(s => componentIsInSearch(this.matchPaths, s))) ? html` <div style="" part="navbar-components-header-collapse"> ${this.componentsCollapsed ? html`<div @click="${() => {
|
|
50
|
+
expandCollapseAllComponents.call(this);
|
|
51
|
+
}}" style="font-size:16px;transform:rotate(0);cursor:pointer">▸</div>` : html`<div @click="${() => {
|
|
52
|
+
expandCollapseAllComponents.call(this);
|
|
53
|
+
}}" style="font-size:16px;transform:rotate(90deg);cursor:pointer">▸</div>`}</div>` : ''} </div> </div> ${this.resolvedSpec.components.filter(c => c.subComponents.some(s => componentIsInSearch(this.matchPaths, s))).map(component => html` <div class="nav-bar-tag-and-paths ${component.expanded ? 'expanded' : 'collapsed'}"> <div class="nav-bar-tag" data-content-id="cmp--${component.name.toLowerCase()}" id="link-cmp--${component.name.toLowerCase()}" @click="${e => this.scrollToEventTarget(e, false)}"> ${component.name} </div> <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>`)}` : ''} </nav>`} </nav> `;
|
|
45
54
|
}
|
|
46
55
|
/* eslint-enable indent */
|
|
@@ -41,9 +41,13 @@ export function getBaseUrlFromUrl(url) {
|
|
|
41
41
|
return `${pathArray[0]}//${pathArray[2]}`;
|
|
42
42
|
}
|
|
43
43
|
export function componentIsInSearch(searchVal, component) {
|
|
44
|
-
return component.name.toLowerCase().includes(searchVal.toLowerCase());
|
|
44
|
+
return !searchVal || component.name.toLowerCase().includes(searchVal.toLowerCase());
|
|
45
45
|
}
|
|
46
46
|
export function pathIsInSearch(searchVal, path) {
|
|
47
|
+
if (!searchVal) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
|
|
47
51
|
const stringToSearch = `${path.method} ${path.path} ${path.summary || path.description || ''} ${path.operationId || ''}`.toLowerCase();
|
|
48
52
|
return stringToSearch.includes(searchVal.toLowerCase());
|
|
49
53
|
}
|
|
@@ -110,10 +110,16 @@ class OpenApiExplorer extends _litElement.LitElement {
|
|
|
110
110
|
layout: {
|
|
111
111
|
type: String
|
|
112
112
|
},
|
|
113
|
-
|
|
113
|
+
collapsed: {
|
|
114
114
|
type: Boolean,
|
|
115
115
|
attribute: 'collapse'
|
|
116
116
|
},
|
|
117
|
+
operationsCollapsed: {
|
|
118
|
+
type: Boolean
|
|
119
|
+
},
|
|
120
|
+
componentsCollapsed: {
|
|
121
|
+
type: Boolean
|
|
122
|
+
},
|
|
117
123
|
defaultSchemaTab: {
|
|
118
124
|
type: String,
|
|
119
125
|
attribute: 'default-schema-tab'
|
|
@@ -287,6 +293,8 @@ class OpenApiExplorer extends _litElement.LitElement {
|
|
|
287
293
|
}
|
|
288
294
|
|
|
289
295
|
this.renderStyle = 'focused';
|
|
296
|
+
this.operationsCollapsed = this.collapsed;
|
|
297
|
+
this.componentsCollapsed = this.collapsed;
|
|
290
298
|
this.explorerLocation = this.explorerLocation || (0, _commonUtils.getCurrentElement)();
|
|
291
299
|
|
|
292
300
|
if (!this.defaultSchemaTab || !'body, model,'.includes(`${this.defaultSchemaTab},`)) {
|
|
@@ -432,29 +440,16 @@ class OpenApiExplorer extends _litElement.LitElement {
|
|
|
432
440
|
}, 0);
|
|
433
441
|
}
|
|
434
442
|
|
|
443
|
+
if (name === 'collapsed') {
|
|
444
|
+
this.operationsCollapsed = newVal;
|
|
445
|
+
this.componentsCollapsed = newVal;
|
|
446
|
+
}
|
|
447
|
+
|
|
435
448
|
super.attributeChangedCallback(name, oldVal, newVal);
|
|
436
449
|
}
|
|
437
450
|
|
|
438
451
|
onSearchChange(e) {
|
|
439
|
-
this.operationsCollapsed = false;
|
|
440
452
|
this.matchPaths = e.target.value;
|
|
441
|
-
this.resolvedSpec.tags.forEach(tag => tag.paths.filter(v => {
|
|
442
|
-
if (this.matchPaths) {
|
|
443
|
-
// v.expanded = false;
|
|
444
|
-
if ((0, _commonUtils.pathIsInSearch)(this.matchPaths, v)) {
|
|
445
|
-
tag.expanded = true;
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
}));
|
|
449
|
-
this.resolvedSpec.components.forEach(component => {
|
|
450
|
-
component.subComponents.forEach(subComponent => {
|
|
451
|
-
subComponent.expanded = false;
|
|
452
|
-
|
|
453
|
-
if (!this.matchPaths || (0, _commonUtils.componentIsInSearch)(this.matchPaths, subComponent)) {
|
|
454
|
-
subComponent.expanded = true;
|
|
455
|
-
}
|
|
456
|
-
});
|
|
457
|
-
});
|
|
458
453
|
this.requestUpdate();
|
|
459
454
|
}
|
|
460
455
|
|
|
@@ -462,11 +457,6 @@ class OpenApiExplorer extends _litElement.LitElement {
|
|
|
462
457
|
const searchEl = this.shadowRoot.getElementById('nav-bar-search');
|
|
463
458
|
searchEl.value = '';
|
|
464
459
|
this.matchPaths = '';
|
|
465
|
-
this.resolvedSpec.components.forEach(component => {
|
|
466
|
-
component.subComponents.forEach(v => {
|
|
467
|
-
v.expanded = true;
|
|
468
|
-
});
|
|
469
|
-
});
|
|
470
460
|
}
|
|
471
461
|
|
|
472
462
|
async onShowSearchModalClicked() {
|
|
@@ -553,6 +543,10 @@ class OpenApiExplorer extends _litElement.LitElement {
|
|
|
553
543
|
this.resolvedSpec.tags.forEach(t => t.expanded = false);
|
|
554
544
|
}
|
|
555
545
|
|
|
546
|
+
if (this.componentsCollapsed) {
|
|
547
|
+
this.resolvedSpec.components.forEach(c => c.expanded = false);
|
|
548
|
+
}
|
|
549
|
+
|
|
556
550
|
this.dispatchEvent(new CustomEvent('spec-loaded', {
|
|
557
551
|
bubbles: true,
|
|
558
552
|
detail: spec
|
|
@@ -100,12 +100,6 @@ function endpointTemplate() {
|
|
|
100
100
|
return (0, _litElement.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, 'expand-all')}" style="color:var(--primary-color);cursor:pointer">Expand</span> | <span @click="${e => expandCollapseAll.call(this, e, 'collapse-all')}" style="color:var(--primary-color);cursor:pointer">Collapse</span> </div> ${(this.resolvedSpec && this.resolvedSpec.tags || []).map(tag => (0, _litElement.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
|
|
101
101
|
<div class="regular-font regular-font-size m-markdown" style="padding-bottom:12px">
|
|
102
102
|
${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(tag.description || ''))}
|
|
103
|
-
</div>` : ''} ${tag.paths.filter(v => {
|
|
104
|
-
if (this.matchPaths) {
|
|
105
|
-
return (0, _commonUtils.pathIsInSearch)(this.matchPaths, v);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return true;
|
|
109
|
-
}).map(path => (0, _litElement.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> `)}`;
|
|
103
|
+
</div>` : ''} ${tag.paths.filter(v => (0, _commonUtils.pathIsInSearch)(this.matchPaths, v)).map(path => (0, _litElement.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> `)}`;
|
|
110
104
|
}
|
|
111
105
|
/* eslint-enable indent */
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.default = navbarTemplate;
|
|
5
5
|
exports.expandCollapseAll = expandCollapseAll;
|
|
6
|
+
exports.expandCollapseAllComponents = expandCollapseAllComponents;
|
|
6
7
|
|
|
7
8
|
var _litElement = require("lit-element");
|
|
8
9
|
|
|
@@ -27,28 +28,38 @@ function onExpandCollapse(tagId) {
|
|
|
27
28
|
function expandCollapseAll() {
|
|
28
29
|
const expand = this.operationsCollapsed;
|
|
29
30
|
this.operationsCollapsed = !expand;
|
|
30
|
-
this.resolvedSpec.tags.forEach(
|
|
31
|
-
|
|
31
|
+
this.resolvedSpec.tags.forEach(tag => {
|
|
32
|
+
tag.expanded = expand;
|
|
32
33
|
});
|
|
34
|
+
this.requestUpdate();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function expandCollapseAllComponents() {
|
|
38
|
+
const expand = this.componentsCollapsed;
|
|
39
|
+
this.componentsCollapsed = !expand;
|
|
40
|
+
this.resolvedSpec.components.forEach(component => {
|
|
41
|
+
component.expanded = expand;
|
|
42
|
+
});
|
|
43
|
+
this.requestUpdate();
|
|
33
44
|
}
|
|
34
45
|
/* eslint-disable indent */
|
|
35
46
|
|
|
36
47
|
|
|
37
48
|
function navbarTemplate() {
|
|
38
|
-
|
|
39
|
-
expandCollapseAll.call(this, e);
|
|
40
|
-
}}" style="font-size:16px;transform:rotate(0);cursor:pointer">▸</div>` : (0, _litElement.html)`<div @click="${e => {
|
|
41
|
-
expandCollapseAll.call(this, e);
|
|
42
|
-
}}" style="font-size:16px;transform:rotate(90deg);cursor:pointer">▸</div>`}` : ''} </div> </div> </div> ${this.resolvedSpec.tags.filter(tag => tag.paths.filter(path => (0, _commonUtils.pathIsInSearch)(this.matchPaths, path)).length).map(tag => (0, _litElement.html)` <slot name="nav-${tag.elementId}"> <div class="nav-bar-tag-and-paths ${tag.expanded ? 'expanded' : 'collapsed'}"> ${tag.name === 'General ⦂' ? (0, _litElement.html)`` : (0, _litElement.html)` <div class="nav-bar-tag" id="link-${tag.elementId}" data-content-id="${tag.elementId}" @click="${() => {
|
|
43
|
-
onExpandCollapse.call(this, tag.elementId);
|
|
44
|
-
}}"> <div style="display:flex;justify-content:space-between;width:100%"> <div>${tag.name}</div> <div class="nav-bar-tag-icon expand-button-arrow">▸</div> <div class="nav-bar-tag-icon collapse-button-arrow">▾</div> </div> </div> `} <div class="nav-bar-paths-under-tag"> ${tag.paths.filter(v => {
|
|
45
|
-
if (this.matchPaths) {
|
|
46
|
-
return (0, _commonUtils.pathIsInSearch)(this.matchPaths, v);
|
|
47
|
-
}
|
|
49
|
+
var _this$resolvedSpec$co;
|
|
48
50
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
return (0, _litElement.html)` <nav class="nav-bar ${this.renderStyle}" part="section-navbar"> ${this.allowSearch === 'false' && this.allowAdvancedSearch === 'false' ? '' : (0, _litElement.html)` <div style="display:flex;flex-direction:row;justify-content:center;align-items:center;padding:24px;${this.allowAdvancedSearch === 'false' ? 'border-bottom: 1px solid var(--nav-hover-bg-color)' : ''}"> ${this.allowSearch === 'false' ? '' : (0, _litElement.html)` <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="Filter" @change="${this.onSearchChange}" spellcheck="false"> <div style="margin:6px 5px 0 -24px;font-size:var(--font-size-regular);cursor:pointer">↩</div> </div> ${this.matchPaths ? (0, _litElement.html)` <div @click="${this.onClearSearch}" style="margin-left:5px;cursor:pointer;align-self:center;color:var(--nav-text-color)" class="small-font-size primary-text bold-text"> CLEAR </div>` : ''} `} ${this.allowAdvancedSearch === 'false' || this.matchPaths ? '' : (0, _litElement.html)` <button class="m-btn primary" part="btn btn-fill btn-search" style="margin-left:5px" @click="${this.onShowSearchModalClicked}"> Search </button> `} </div> `} ${(0, _litElement.html)`<nav class="nav-scroll" part="navbar-scroll"> ${this.showInfo === 'false' || !this.resolvedSpec.info ? '' : (0, _litElement.html)`<div class="nav-bar-info" id="link-overview" data-content-id="overview" @click="${e => this.scrollToEventTarget(e, false)}"> ${this.isV1 && this.resolvedSpec.info.title || 'Overview'} </div>`} ${this.allowServerSelection === 'false' ? '' : (0, _litElement.html)`<div class="nav-bar-info" id="link-servers" data-content-id="servers" @click="${e => this.scrollToEventTarget(e, false)}"> API Servers </div>`} ${this.allowAuthentication === 'false' || !this.resolvedSpec.securitySchemes ? '' : (0, _litElement.html)`<div class="nav-bar-info" id="link-auth" data-content-id="auth" @click="${e => this.scrollToEventTarget(e, false)}"> Authentication </div>`} <slot name="nav-section" class="custom-nav-section" data-content-id="section" @click="${e => this.scrollToEventTarget(e, false)}"></slot> <div class="sticky-scroll-element"> <div class="nav-bar-section" part="navbar-operations-header"> <slot name="operations-header"> <div class="nav-bar-section-title">OPERATIONS</div> </slot> <div style="" part="navbar-operations-header-collapse"> ${this.resolvedSpec.tags.length > 1 && this.resolvedSpec.tags.some(tag => tag.paths.some(path => (0, _commonUtils.pathIsInSearch)(this.matchPaths, path))) ? (0, _litElement.html)` ${this.operationsCollapsed ? (0, _litElement.html)`<div @click="${() => {
|
|
52
|
+
expandCollapseAll.call(this);
|
|
53
|
+
}}" style="font-size:16px;transform:rotate(0);cursor:pointer">▸</div>` : (0, _litElement.html)`<div @click="${() => {
|
|
54
|
+
expandCollapseAll.call(this);
|
|
55
|
+
}}" style="font-size:16px;transform:rotate(90deg);cursor:pointer">▸</div>`}` : ''} </div> </div> </div> ${this.resolvedSpec.tags.filter(tag => tag.paths.some(path => (0, _commonUtils.pathIsInSearch)(this.matchPaths, path))).map(tag => (0, _litElement.html)` <slot name="nav-${tag.elementId}"> <div class="nav-bar-tag-and-paths ${tag.expanded ? 'expanded' : 'collapsed'}"> ${tag.name === 'General ⦂' ? (0, _litElement.html)`` : (0, _litElement.html)` <div class="nav-bar-tag" id="link-${tag.elementId}" data-content-id="${tag.elementId}" @click="${() => {
|
|
56
|
+
onExpandCollapse.call(this, tag.elementId);
|
|
57
|
+
}}"> <div style="display:flex;justify-content:space-between;width:100%"> <div>${tag.name}</div> <div class="nav-bar-tag-icon expand-button-arrow">▸</div> <div class="nav-bar-tag-icon collapse-button-arrow">▾</div> </div> </div> `} <div class="nav-bar-paths-under-tag"> ${tag.paths.filter(v => (0, _commonUtils.pathIsInSearch)(this.matchPaths, v)).map(p => (0, _litElement.html)` <div class="nav-bar-path ${this.usePathInNavBar === 'true' ? 'small-font' : ''}" data-content-id="${p.elementId}" id="link-${p.elementId}" @click="${e => {
|
|
51
58
|
this.scrollToEventTarget(e, false);
|
|
52
|
-
}}"> <span style="line-break:anywhere;${p.deprecated ? 'filter:opacity(0.5)' : ''}"> ${this.usePathInNavBar === 'true' ? (0, _litElement.html)`<span class="mono-font">${p.method.toUpperCase()} ${p.path}</span>` : p.summary || p.shortSummary} ${p.isWebhook ? '(Webhook)' : ''} </span> </div>`)} </div> </div> </slot> `)} ${this.resolvedSpec.components && !this.hideComponents ? (0, _litElement.html)` <div class="sticky-scroll-element"> <div id="link-components" class="nav-bar-section"> <div class="nav-bar-section-title">COMPONENTS</div> </
|
|
59
|
+
}}"> <span style="line-break:anywhere;${p.deprecated ? 'filter:opacity(0.5)' : ''}"> ${this.usePathInNavBar === 'true' ? (0, _litElement.html)`<span class="mono-font">${p.method.toUpperCase()} ${p.path}</span>` : p.summary || p.shortSummary} ${p.isWebhook ? '(Webhook)' : ''} </span> </div>`)} </div> </div> </slot> `)} ${(_this$resolvedSpec$co = this.resolvedSpec.components) !== null && _this$resolvedSpec$co !== void 0 && _this$resolvedSpec$co.length && !this.hideComponents ? (0, _litElement.html)` <div class="sticky-scroll-element"> <div id="link-components" class="nav-bar-section"> <slot name="components-header"> <div class="nav-bar-section-title">COMPONENTS</div> </slot> ${this.resolvedSpec.components.some(c => c.subComponents.some(s => (0, _commonUtils.componentIsInSearch)(this.matchPaths, s))) ? (0, _litElement.html)` <div style="" part="navbar-components-header-collapse"> ${this.componentsCollapsed ? (0, _litElement.html)`<div @click="${() => {
|
|
60
|
+
expandCollapseAllComponents.call(this);
|
|
61
|
+
}}" style="font-size:16px;transform:rotate(0);cursor:pointer">▸</div>` : (0, _litElement.html)`<div @click="${() => {
|
|
62
|
+
expandCollapseAllComponents.call(this);
|
|
63
|
+
}}" style="font-size:16px;transform:rotate(90deg);cursor:pointer">▸</div>`}</div>` : ''} </div> </div> ${this.resolvedSpec.components.filter(c => c.subComponents.some(s => (0, _commonUtils.componentIsInSearch)(this.matchPaths, s))).map(component => (0, _litElement.html)` <div class="nav-bar-tag-and-paths ${component.expanded ? 'expanded' : 'collapsed'}"> <div class="nav-bar-tag" data-content-id="cmp--${component.name.toLowerCase()}" id="link-cmp--${component.name.toLowerCase()}" @click="${e => this.scrollToEventTarget(e, false)}"> ${component.name} </div> <div class="nav-bar-paths-under-tag"> ${component.subComponents.filter(s => (0, _commonUtils.componentIsInSearch)(this.matchPaths, s)).map(p => (0, _litElement.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>`)}` : ''} </nav>`} </nav> `;
|
|
53
64
|
}
|
|
54
65
|
/* eslint-enable indent */
|
|
@@ -62,10 +62,14 @@ function getBaseUrlFromUrl(url) {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
function componentIsInSearch(searchVal, component) {
|
|
65
|
-
return component.name.toLowerCase().includes(searchVal.toLowerCase());
|
|
65
|
+
return !searchVal || component.name.toLowerCase().includes(searchVal.toLowerCase());
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
function pathIsInSearch(searchVal, path) {
|
|
69
|
+
if (!searchVal) {
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
|
|
69
73
|
const stringToSearch = `${path.method} ${path.path} ${path.summary || path.description || ''} ${path.operationId || ''}`.toLowerCase();
|
|
70
74
|
return stringToSearch.includes(searchVal.toLowerCase());
|
|
71
75
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openapi-explorer",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.346",
|
|
4
4
|
"description": "OpenAPI Explorer - API viewer with dynamically generated components, documentation, and interaction console",
|
|
5
5
|
"author": "Rhosys Developers <developers@rhosys.ch>",
|
|
6
6
|
"repository": {
|