openapi-explorer 2.1.656 → 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 +1 -1
- 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 +0 -5
- 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
@@ -2,54 +2,31 @@
|
|
2
2
|
|
3
3
|
exports.__esModule = true;
|
4
4
|
exports.default = void 0;
|
5
|
-
|
6
5
|
var _lit = require("lit");
|
7
|
-
|
8
6
|
var _fontStyles = _interopRequireDefault(require("./styles/font-styles.js"));
|
9
|
-
|
10
7
|
var _inputStyles = _interopRequireDefault(require("./styles/input-styles.js"));
|
11
|
-
|
12
8
|
var _schemaStyles = _interopRequireDefault(require("./styles/schema-styles.js"));
|
13
|
-
|
14
9
|
var _flexStyles = _interopRequireDefault(require("./styles/flex-styles.js"));
|
15
|
-
|
16
10
|
var _tableStyles = _interopRequireDefault(require("./styles/table-styles.js"));
|
17
|
-
|
18
11
|
var _keyFrameStyles = _interopRequireDefault(require("./styles/key-frame-styles.js"));
|
19
|
-
|
20
12
|
var _endpointStyles = _interopRequireDefault(require("./styles/endpoint-styles.js"));
|
21
|
-
|
22
13
|
var _prismStyles = _interopRequireDefault(require("./styles/prism-styles.js"));
|
23
|
-
|
24
14
|
var _tagInputStyles = _interopRequireDefault(require("./styles/tag-input-styles.js"));
|
25
|
-
|
26
15
|
var _tabStyles = _interopRequireDefault(require("./styles/tab-styles.js"));
|
27
|
-
|
28
16
|
var _navStyles = _interopRequireDefault(require("./styles/nav-styles.js"));
|
29
|
-
|
30
17
|
var _infoStyles = _interopRequireDefault(require("./styles/info-styles.js"));
|
31
|
-
|
32
18
|
var _advancedSearchStyles = _interopRequireDefault(require("./styles/advanced-search-styles.js"));
|
33
|
-
|
34
19
|
var _commonUtils = require("./utils/common-utils.js");
|
35
|
-
|
36
20
|
var _index = require("./languages/index.js");
|
37
|
-
|
38
21
|
var _specParser = _interopRequireDefault(require("./utils/spec-parser.js"));
|
39
|
-
|
40
22
|
var _mainBodyTemplate = _interopRequireDefault(require("./templates/mainBodyTemplate.js"));
|
41
|
-
|
42
23
|
var _apiRequestStyles = _interopRequireDefault(require("./styles/api-request-styles.js"));
|
43
|
-
|
44
24
|
var _securitySchemeTemplate = require("./templates/security-scheme-template.js");
|
45
|
-
|
46
25
|
require("./components/syntax-highlighter.js");
|
47
|
-
|
48
26
|
require("./openapi-explorer-oauth-handler.js");
|
49
|
-
|
50
27
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
51
|
-
|
52
28
|
// Styles
|
29
|
+
|
53
30
|
class OpenApiExplorer extends _lit.LitElement {
|
54
31
|
constructor() {
|
55
32
|
super();
|
@@ -61,7 +38,6 @@ class OpenApiExplorer extends _lit.LitElement {
|
|
61
38
|
threshold: 0
|
62
39
|
};
|
63
40
|
this.isIntersectionObserverActive = true;
|
64
|
-
|
65
41
|
if (typeof IntersectionObserver !== 'undefined') {
|
66
42
|
this.intersectionObserver = new IntersectionObserver(entries => {
|
67
43
|
this.onIntersect(entries);
|
@@ -69,13 +45,10 @@ class OpenApiExplorer extends _lit.LitElement {
|
|
69
45
|
} else {
|
70
46
|
this.intersectionObserver = {
|
71
47
|
disconnect() {},
|
72
|
-
|
73
48
|
observe() {}
|
74
|
-
|
75
49
|
};
|
76
50
|
}
|
77
51
|
}
|
78
|
-
|
79
52
|
static get properties() {
|
80
53
|
return {
|
81
54
|
// Heading
|
@@ -99,11 +72,9 @@ class OpenApiExplorer extends _lit.LitElement {
|
|
99
72
|
collapsed: {
|
100
73
|
type: Boolean,
|
101
74
|
attribute: 'collapse',
|
102
|
-
|
103
75
|
converter(value) {
|
104
76
|
return value !== 'false' && value !== false;
|
105
77
|
}
|
106
|
-
|
107
78
|
},
|
108
79
|
operationsCollapsed: {
|
109
80
|
type: Boolean
|
@@ -122,21 +93,17 @@ class OpenApiExplorer extends _lit.LitElement {
|
|
122
93
|
hideDefaults: {
|
123
94
|
type: Boolean,
|
124
95
|
attribute: 'hide-defaults',
|
125
|
-
|
126
96
|
converter(value) {
|
127
97
|
return value !== 'false' && value !== false;
|
128
98
|
}
|
129
|
-
|
130
99
|
},
|
131
100
|
// Schema Styles
|
132
101
|
displaySchemaAsTable: {
|
133
102
|
type: Boolean,
|
134
103
|
attribute: 'table',
|
135
|
-
|
136
104
|
converter(value) {
|
137
105
|
return value !== 'false' && value !== false;
|
138
106
|
}
|
139
|
-
|
140
107
|
},
|
141
108
|
schemaExpandLevel: {
|
142
109
|
type: Number,
|
@@ -151,65 +118,51 @@ class OpenApiExplorer extends _lit.LitElement {
|
|
151
118
|
hideInfo: {
|
152
119
|
type: Boolean,
|
153
120
|
attribute: 'hide-info',
|
154
|
-
|
155
121
|
converter(value) {
|
156
122
|
return value !== 'false' && value !== false;
|
157
123
|
}
|
158
|
-
|
159
124
|
},
|
160
125
|
hideAuthentication: {
|
161
126
|
type: Boolean,
|
162
127
|
attribute: 'hide-authentication',
|
163
|
-
|
164
128
|
converter(value) {
|
165
129
|
return value !== 'false' && value !== false;
|
166
130
|
}
|
167
|
-
|
168
131
|
},
|
169
132
|
hideExecution: {
|
170
133
|
type: Boolean,
|
171
134
|
attribute: 'hide-console',
|
172
|
-
|
173
135
|
converter(value) {
|
174
136
|
return value !== 'false' && value !== false;
|
175
137
|
}
|
176
|
-
|
177
138
|
},
|
178
139
|
includeNulls: {
|
179
140
|
type: Boolean,
|
180
141
|
attribute: 'display-nulls',
|
181
|
-
|
182
142
|
converter(value) {
|
183
143
|
return value !== 'false' && value !== false;
|
184
144
|
}
|
185
|
-
|
186
145
|
},
|
187
146
|
hideSearch: {
|
188
147
|
type: Boolean,
|
189
148
|
attribute: 'hide-search',
|
190
|
-
|
191
149
|
converter(value) {
|
192
150
|
return value !== 'false' && value !== false;
|
193
151
|
}
|
194
|
-
|
195
152
|
},
|
196
153
|
hideServerSelection: {
|
197
154
|
type: Boolean,
|
198
155
|
attribute: 'hide-server-selection',
|
199
|
-
|
200
156
|
converter(value) {
|
201
157
|
return value !== 'false' && value !== false;
|
202
158
|
}
|
203
|
-
|
204
159
|
},
|
205
160
|
hideComponents: {
|
206
161
|
type: Boolean,
|
207
162
|
attribute: 'hide-components',
|
208
|
-
|
209
163
|
converter(value) {
|
210
164
|
return value !== 'false' && value !== false;
|
211
165
|
}
|
212
|
-
|
213
166
|
},
|
214
167
|
// Main Colors and Font
|
215
168
|
primaryColor: {
|
@@ -260,11 +213,9 @@ class OpenApiExplorer extends _lit.LitElement {
|
|
260
213
|
usePathInNavBar: {
|
261
214
|
type: Boolean,
|
262
215
|
attribute: 'use-path-in-nav-bar',
|
263
|
-
|
264
216
|
converter(value) {
|
265
217
|
return value !== 'false' && value !== false;
|
266
218
|
}
|
267
|
-
|
268
219
|
},
|
269
220
|
// Fetch Options
|
270
221
|
fetchCredentials: {
|
@@ -289,96 +240,78 @@ class OpenApiExplorer extends _lit.LitElement {
|
|
289
240
|
}
|
290
241
|
};
|
291
242
|
}
|
292
|
-
|
293
243
|
static finalizeStyles() {
|
294
|
-
return [_fontStyles.default, _schemaStyles.default, _inputStyles.default, _flexStyles.default, _tableStyles.default, _keyFrameStyles.default, _endpointStyles.default, _prismStyles.default, _tabStyles.default, _navStyles.default, _infoStyles.default, _tagInputStyles.default, _advancedSearchStyles.default, _apiRequestStyles.default, (0, _lit.css)`:not(:defined){display:none}:host{display:flex;flex-direction:column;width:100%;height:100%;margin:0;padding:0;overflow:hidden;letter-spacing:normal;color:var(--fg);background-color:var(--bg);font-family:var(--font-regular)}.body{display:flex;height:100%;width:100%;overflow:hidden}a{text-decoration:none}.main-content{margin:0;padding:0;display:block;flex:1;height:100%;overflow-y:overlay;overflow-x:hidden;scrollbar-width:thin;scrollbar-color:var(--border-color) transparent}.main-content::-webkit-scrollbar{width:8px;height:8px}.main-content::-webkit-scrollbar-track{background:0 0}.main-content::-webkit-scrollbar-thumb{background-color:var(--border-color)}.section-gap.section-tag{border-bottom:1px solid var(--border-color)}.method-section-gap{margin:0;padding:0 8px 0 4px;border-bottom:1px solid var(--border-color)}.section-gap{padding:24px 0 0}.section-tag-header{position:relative;cursor:n-resize;padding:12px 0}.collapsed .section-tag-header:hover{cursor:s-resize}.section-tag-header:hover{background-image:linear-gradient(to right,rgba(0,0,0,0),var(--border-color),rgba(0,0,0,0))}.collapsed .section-tag-header:hover::after{color:var(--primary-color)}.collapsed .section-tag-body{display:none}.logo{height:36px;width:36px;margin-left:5px}.only-large-screen,.only-large-screen-flex{display:none}.header-title{font-size:calc(var(--font-size-regular) + 8px);padding:0 8px}.tag.title{text-transform:uppercase}.header{background-color:var(--header-bg);color:var(--header-fg);width:100%}input.header-input{background:var(--header-color-darker);color:var(--header-fg);border:1px solid var(--header-color-border);flex:1;padding-right:24px;border-radius:3px}input.header-input::placeholder{opacity:.4}input:disabled{cursor:not-allowed}.loader{margin:16px auto 16px auto;border:4px solid var(--bg3);border-radius:50%;border-top:4px solid var(--primary-color);width:36px;height:36px;animation:spin 2s linear infinite}.expanded-endpoint-body,.expanded-endpoint-component{position:relative;padding:6px 0}.
|
295
|
-
}
|
296
|
-
|
244
|
+
return [_fontStyles.default, _schemaStyles.default, _inputStyles.default, _flexStyles.default, _tableStyles.default, _keyFrameStyles.default, _endpointStyles.default, _prismStyles.default, _tabStyles.default, _navStyles.default, _infoStyles.default, _tagInputStyles.default, _advancedSearchStyles.default, _apiRequestStyles.default, (0, _lit.css)`:not(:defined){display:none}:host{display:flex;flex-direction:column;width:100%;height:100%;margin:0;padding:0;overflow:hidden;letter-spacing:normal;color:var(--fg);background-color:var(--bg);font-family:var(--font-regular)}.body{display:flex;height:100%;width:100%;overflow:hidden}a{text-decoration:none}.main-content{margin:0;padding:0;display:block;flex:1;height:100%;overflow-y:overlay;overflow-x:hidden;scrollbar-width:thin;scrollbar-color:var(--border-color) transparent}.main-content::-webkit-scrollbar{width:8px;height:8px}.main-content::-webkit-scrollbar-track{background:0 0}.main-content::-webkit-scrollbar-thumb{background-color:var(--border-color)}.section-gap.section-tag{border-bottom:1px solid var(--border-color)}.method-section-gap{margin:0;padding:0 8px 0 4px;border-bottom:1px solid var(--border-color)}.section-gap{padding:24px 0 0}.section-tag-header{position:relative;cursor:n-resize;padding:12px 0}.collapsed .section-tag-header:hover{cursor:s-resize}.section-tag-header:hover{background-image:linear-gradient(to right,rgba(0,0,0,0),var(--border-color),rgba(0,0,0,0))}.collapsed .section-tag-header:hover::after{color:var(--primary-color)}.collapsed .section-tag-body{display:none}.logo{height:36px;width:36px;margin-left:5px}.only-large-screen,.only-large-screen-flex{display:none}.header-title{font-size:calc(var(--font-size-regular) + 8px);padding:0 8px}.tag.title{text-transform:uppercase}.header{background-color:var(--header-bg);color:var(--header-fg);width:100%}input.header-input{background:var(--header-color-darker);color:var(--header-fg);border:1px solid var(--header-color-border);flex:1;padding-right:24px;border-radius:3px}input.header-input::placeholder{opacity:.4}input:disabled{cursor:not-allowed}.loader{margin:16px auto 16px auto;border:4px solid var(--bg3);border-radius:50%;border-top:4px solid var(--primary-color);width:36px;height:36px;animation:spin 2s linear infinite}.expanded-endpoint-body,.expanded-endpoint-component{position:relative;padding:6px 0}.divider{border-top:2px solid var(--border-color);margin:24px 0;width:100%}.security-tooltip{border:1px solid var(--border-color);border-left-width:4px;margin-left:2px}.security-tooltip a{color:var(--fg2);text-decoration:none}.tooltip-text{color:var(--fg2);background-color:var(--bg2);visibility:hidden;overflow-wrap:break-word}.tooltip:hover{color:var(--primary-color);border-color:var(--primary-color)}.tooltip-replace:hover{visibility:hidden}.tooltip:hover a:hover{color:var(--primary-color)}.tooltip:hover .tooltip-text{visibility:visible;cursor:text;opacity:1}@media only screen and (max-width:767.98px){.section-padding{margin:1rem}.sub-title.tag{margin-left:1rem}.section-tag-body .description{margin-left:1rem;margin-right:1rem}}@media only screen and (min-width:768px){.nav-bar{width:260px;display:flex}.only-large-screen{display:block}.only-large-screen-flex{display:flex}.section-gap{padding:24px 24px}.section-gap--read-mode{padding:24px 8px}.section-gap--focused-mode{padding:1.5rem}.endpoint-body{position:relative;padding:36px 0 48px 0}}@media only screen and (min-width:1024px){.nav-bar{width:330px;display:flex}.section-gap--read-mode{padding:24px 24px 12px}.main-content-inner{padding:24px}}`];
|
245
|
+
}
|
297
246
|
|
247
|
+
// Startup
|
298
248
|
connectedCallback() {
|
299
249
|
super.connectedCallback();
|
300
250
|
this.handleResize = this.handleResize.bind(this);
|
301
251
|
window.addEventListener('resize', this.handleResize);
|
302
252
|
this.loading = true;
|
303
253
|
const parent = this.parentElement;
|
304
|
-
|
305
254
|
if (parent) {
|
306
255
|
if (parent.offsetWidth === 0 && parent.style.width === '') {
|
307
256
|
parent.style.width = '100vw';
|
308
257
|
}
|
309
|
-
|
310
258
|
if (parent.offsetHeight === 0 && parent.style.height === '') {
|
311
259
|
parent.style.height = '100vh';
|
312
260
|
}
|
313
|
-
|
314
261
|
if (parent.tagName === 'BODY') {
|
315
262
|
if (!parent.style.marginTop) {
|
316
263
|
parent.style.marginTop = '0';
|
317
264
|
}
|
318
|
-
|
319
265
|
if (!parent.style.marginRight) {
|
320
266
|
parent.style.marginRight = '0';
|
321
267
|
}
|
322
|
-
|
323
268
|
if (!parent.style.marginBottom) {
|
324
269
|
parent.style.marginBottom = '0';
|
325
270
|
}
|
326
|
-
|
327
271
|
if (!parent.style.marginLeft) {
|
328
272
|
parent.style.marginLeft = '0';
|
329
273
|
}
|
330
274
|
}
|
331
275
|
}
|
332
|
-
|
333
276
|
this.renderStyle = 'focused';
|
334
277
|
this.operationsCollapsed = this.collapsed;
|
335
278
|
this.componentsCollapsed = this.collapsed;
|
336
279
|
this.explorerLocation = this.explorerLocation || (0, _commonUtils.getCurrentElement)();
|
337
|
-
|
338
280
|
if (!this.defaultSchemaTab || !'body, model, form,'.includes(`${this.defaultSchemaTab},`)) {
|
339
281
|
this.defaultSchemaTab = 'model';
|
340
282
|
}
|
341
|
-
|
342
283
|
if (!this.schemaExpandLevel || this.schemaExpandLevel < 1) {
|
343
284
|
this.schemaExpandLevel = 99999;
|
344
285
|
}
|
345
|
-
|
346
286
|
this.schemaHideReadOnly = ['post', 'put', 'patch', 'query'].join(',');
|
347
287
|
this.schemaHideWriteOnly = true;
|
348
|
-
|
349
288
|
if (!this.responseAreaHeight) {
|
350
289
|
this.responseAreaHeight = '300px';
|
351
290
|
}
|
352
|
-
|
353
291
|
if (!this.navItemSpacing || !'compact, relaxed, default,'.includes(`${this.navItemSpacing},`)) {
|
354
292
|
this.navItemSpacing = 'default';
|
355
293
|
}
|
356
|
-
|
357
294
|
if (!this.fetchCredentials || !'omit, same-origin, include,'.includes(`${this.fetchCredentials},`)) {
|
358
295
|
this.fetchCredentials = '';
|
359
296
|
}
|
360
|
-
|
361
297
|
if (!this.showAdvancedSearchDialog) {
|
362
298
|
this.showAdvancedSearchDialog = false;
|
363
299
|
}
|
364
|
-
|
365
300
|
window.addEventListener('hashchange', () => {
|
366
301
|
this.scrollTo((0, _commonUtils.getCurrentElement)());
|
367
302
|
}, true);
|
368
303
|
this.handleResize();
|
369
|
-
}
|
370
|
-
|
304
|
+
}
|
371
305
|
|
306
|
+
// Cleanup
|
372
307
|
disconnectedCallback() {
|
373
308
|
this.intersectionObserver.disconnect();
|
374
309
|
window.removeEventListener('resize', this.handleResize);
|
375
310
|
super.disconnectedCallback();
|
376
311
|
}
|
377
|
-
|
378
312
|
render() {
|
379
313
|
return _mainBodyTemplate.default.call(this);
|
380
314
|
}
|
381
|
-
|
382
315
|
observeExpandedContent() {
|
383
316
|
// Main Container
|
384
317
|
const observeOverviewEls = this.shadowRoot.querySelectorAll('.observe-me');
|
@@ -386,39 +319,33 @@ class OpenApiExplorer extends _lit.LitElement {
|
|
386
319
|
this.intersectionObserver.observe(targetEl);
|
387
320
|
});
|
388
321
|
}
|
389
|
-
|
390
322
|
handleResize() {
|
391
323
|
const mediaQueryResult = window.matchMedia('(min-width: 768px)');
|
392
324
|
const newDisplay = mediaQueryResult.matches ? 'focused' : 'view';
|
393
|
-
|
394
325
|
if (this.renderStyle !== newDisplay) {
|
395
326
|
this.renderStyle = newDisplay;
|
396
327
|
this.requestUpdate();
|
397
328
|
}
|
398
329
|
}
|
399
|
-
|
400
330
|
attributeChangedCallback(name, oldVal, newVal) {
|
401
331
|
if (name === 'spec-url') {
|
402
332
|
if (oldVal !== newVal) {
|
403
333
|
window.setTimeout(async () => {
|
404
|
-
await this.loadSpec(newVal);
|
405
|
-
|
334
|
+
await this.loadSpec(newVal);
|
335
|
+
// If the initial location is set, then attempt to scroll there
|
406
336
|
if (this.explorerLocation) {
|
407
337
|
this.scrollTo(this.explorerLocation);
|
408
338
|
}
|
409
339
|
}, 0);
|
410
340
|
}
|
411
341
|
}
|
412
|
-
|
413
342
|
if (name === 'server-url' && newVal) {
|
414
343
|
var _this$resolvedSpec;
|
415
|
-
|
416
344
|
this.selectedServer = ((_this$resolvedSpec = this.resolvedSpec) === null || _this$resolvedSpec === void 0 ? void 0 : _this$resolvedSpec.servers.find(s => s.url === newVal || !newVal)) || {
|
417
345
|
url: newVal,
|
418
346
|
computedUrl: newVal
|
419
347
|
};
|
420
348
|
}
|
421
|
-
|
422
349
|
if (name === 'render-style') {
|
423
350
|
if (newVal === 'read') {
|
424
351
|
window.setTimeout(() => {
|
@@ -428,24 +355,19 @@ class OpenApiExplorer extends _lit.LitElement {
|
|
428
355
|
this.intersectionObserver.disconnect();
|
429
356
|
}
|
430
357
|
}
|
431
|
-
|
432
358
|
if (name === 'explorer-location') {
|
433
359
|
window.setTimeout(() => {
|
434
360
|
this.scrollTo(newVal);
|
435
361
|
}, 0);
|
436
362
|
}
|
437
|
-
|
438
363
|
if (name === 'collapsed') {
|
439
364
|
this.operationsCollapsed = newVal;
|
440
365
|
this.componentsCollapsed = newVal;
|
441
366
|
}
|
442
|
-
|
443
367
|
super.attributeChangedCallback(name, oldVal, newVal);
|
444
368
|
}
|
445
|
-
|
446
369
|
onSearchChange(e) {
|
447
370
|
var _this$matchPaths;
|
448
|
-
|
449
371
|
this.matchPaths = e.target.value;
|
450
372
|
const expand = !!((_this$matchPaths = this.matchPaths) !== null && _this$matchPaths !== void 0 && _this$matchPaths.trim());
|
451
373
|
this.operationsCollapsed = !expand;
|
@@ -458,55 +380,43 @@ class OpenApiExplorer extends _lit.LitElement {
|
|
458
380
|
});
|
459
381
|
this.requestUpdate();
|
460
382
|
}
|
461
|
-
|
462
383
|
onClearSearch() {
|
463
384
|
const searchEl = this.shadowRoot.getElementById('nav-bar-search');
|
464
385
|
searchEl.value = '';
|
465
386
|
this.matchPaths = '';
|
466
387
|
}
|
467
|
-
|
468
388
|
async onShowSearchModalClicked() {
|
469
|
-
this.showAdvancedSearchDialog = true;
|
470
|
-
|
389
|
+
this.showAdvancedSearchDialog = true;
|
390
|
+
// wait for the dialog to render
|
471
391
|
await (0, _commonUtils.sleep)(10);
|
472
392
|
const inputEl = this.shadowRoot.getElementById('advanced-search-dialog-input');
|
473
|
-
|
474
393
|
if (inputEl) {
|
475
394
|
inputEl.focus();
|
476
395
|
}
|
477
|
-
}
|
478
|
-
|
396
|
+
}
|
479
397
|
|
398
|
+
// Public Method
|
480
399
|
async loadSpec(specUrlOrObject) {
|
481
400
|
if (!specUrlOrObject) {
|
482
401
|
return;
|
483
402
|
}
|
484
|
-
|
485
403
|
this.matchPaths = '';
|
486
|
-
|
487
404
|
try {
|
488
405
|
var _spec$info;
|
489
|
-
|
490
406
|
this.resolvedSpec = null;
|
491
407
|
this.loading = true;
|
492
408
|
this.loadFailed = false;
|
493
409
|
const spec = await (0, _specParser.default)(specUrlOrObject, this.serverUrl);
|
494
410
|
this.loading = false;
|
495
|
-
|
496
411
|
if (spec === undefined || spec === null) {
|
497
412
|
console.error('Unable to resolve the API spec. '); // eslint-disable-line no-console
|
498
|
-
|
499
413
|
return;
|
500
414
|
}
|
501
|
-
|
502
415
|
(0, _index.initI18n)((_spec$info = spec.info) === null || _spec$info === void 0 ? void 0 : _spec$info['x-locale']);
|
503
|
-
|
504
416
|
if (!this.serverUrl) {
|
505
417
|
var _spec$servers$, _spec$servers$2;
|
506
|
-
|
507
418
|
this.serverUrl = ((_spec$servers$ = spec.servers[0]) === null || _spec$servers$ === void 0 ? void 0 : _spec$servers$.computedUrl) || ((_spec$servers$2 = spec.servers[0]) === null || _spec$servers$2 === void 0 ? void 0 : _spec$servers$2.url);
|
508
419
|
}
|
509
|
-
|
510
420
|
this.selectedServer = spec.servers.find(s => s.url === this.serverUrl || !this.serverUrl) || spec.servers[0];
|
511
421
|
this.afterSpecParsedAndValidated(spec);
|
512
422
|
} catch (err) {
|
@@ -515,16 +425,15 @@ class OpenApiExplorer extends _lit.LitElement {
|
|
515
425
|
this.resolvedSpec = null;
|
516
426
|
console.error('OpenAPI Explorer: Unable to resolve the API spec..', err); // eslint-disable-line no-console
|
517
427
|
}
|
518
|
-
|
519
428
|
try {
|
520
429
|
await _securitySchemeTemplate.checkForAuthToken.call(this);
|
521
430
|
} catch (error) {
|
522
431
|
// eslint-disable-next-line no-console
|
523
432
|
console.error('Failed to check for authentication token', error);
|
524
433
|
}
|
525
|
-
}
|
526
|
-
|
434
|
+
}
|
527
435
|
|
436
|
+
// Public Method
|
528
437
|
async setAuthenticationConfiguration(apiKeyId, {
|
529
438
|
token,
|
530
439
|
clientId,
|
@@ -532,13 +441,10 @@ class OpenApiExplorer extends _lit.LitElement {
|
|
532
441
|
redirectUri
|
533
442
|
}) {
|
534
443
|
const securityObj = this.resolvedSpec && this.resolvedSpec.securitySchemes.find(v => v.apiKeyId === apiKeyId);
|
535
|
-
|
536
444
|
if (!securityObj) {
|
537
445
|
throw Error('SecuritySchemeNotFound');
|
538
446
|
}
|
539
|
-
|
540
447
|
let authorizationToken = token && token.replace(/^(Bearer|Basic)\s+/i, '').trim();
|
541
|
-
|
542
448
|
if (authorizationToken && securityObj.type && securityObj.type === 'http' && securityObj.scheme && securityObj.scheme.toLowerCase() === 'basic') {
|
543
449
|
authorizationToken = `Basic ${btoa(authorizationToken)}`;
|
544
450
|
} else if (authorizationToken && securityObj.scheme && securityObj.scheme.toLowerCase() === 'bearer') {
|
@@ -546,7 +452,6 @@ class OpenApiExplorer extends _lit.LitElement {
|
|
546
452
|
} else {
|
547
453
|
authorizationToken = null;
|
548
454
|
}
|
549
|
-
|
550
455
|
securityObj.clientId = clientId && clientId.trim();
|
551
456
|
securityObj.clientSecret = clientSecret && clientSecret.trim();
|
552
457
|
securityObj.redirectUri = new URL(redirectUri && redirectUri.trim() || '', window.location.href).toString();
|
@@ -554,56 +459,47 @@ class OpenApiExplorer extends _lit.LitElement {
|
|
554
459
|
await _securitySchemeTemplate.checkForAuthToken.call(this);
|
555
460
|
this.requestUpdate();
|
556
461
|
}
|
557
|
-
|
558
462
|
afterSpecParsedAndValidated(spec) {
|
559
463
|
this.resolvedSpec = spec;
|
560
|
-
|
561
464
|
if (this.operationsCollapsed) {
|
562
465
|
this.resolvedSpec.tags.forEach(t => t.expanded = false);
|
563
466
|
}
|
564
|
-
|
565
467
|
if (this.componentsCollapsed) {
|
566
468
|
this.resolvedSpec.components.forEach(c => c.expanded = false);
|
567
469
|
}
|
568
|
-
|
569
470
|
this.dispatchEvent(new CustomEvent('spec-loaded', {
|
570
471
|
bubbles: true,
|
571
472
|
detail: spec
|
572
473
|
}));
|
573
|
-
this.requestUpdate();
|
474
|
+
this.requestUpdate();
|
574
475
|
|
476
|
+
// Initiate IntersectionObserver and put it at the end of event loop, to allow loading all the child elements (must for larger specs)
|
575
477
|
this.intersectionObserver.disconnect();
|
576
|
-
|
577
478
|
if (this.renderStyle === 'focused') {
|
578
479
|
const defaultElementId = !this.hideInfo ? 'overview' : this.resolvedSpec.tags && this.resolvedSpec.tags[0] && this.resolvedSpec.tags[0].paths[0];
|
579
480
|
this.scrollTo(this.explorerLocation || defaultElementId);
|
580
481
|
}
|
581
|
-
|
582
482
|
if (this.renderStyle === 'view' && this.explorerLocation) {
|
583
483
|
this.expandAndGotoOperation(this.explorerLocation);
|
584
484
|
}
|
585
485
|
}
|
586
|
-
|
587
486
|
expandAndGotoOperation(elementId) {
|
588
487
|
var _tag$paths;
|
589
|
-
|
590
488
|
// Expand full operation and tag
|
591
489
|
let isExpandingNeeded = false;
|
592
490
|
const tag = this.resolvedSpec.tags.find(t => t.paths && t.paths.find(p => p.elementId === elementId));
|
593
491
|
const path = tag === null || tag === void 0 ? void 0 : (_tag$paths = tag.paths) === null || _tag$paths === void 0 ? void 0 : _tag$paths.find(p => p.elementId === elementId);
|
594
|
-
|
595
492
|
if (path && (!path.expanded || !tag.expanded)) {
|
596
493
|
isExpandingNeeded = true;
|
597
494
|
path.expanded = true;
|
598
495
|
tag.expanded = true;
|
599
496
|
this.requestUpdate();
|
600
|
-
}
|
601
|
-
|
497
|
+
}
|
602
498
|
|
499
|
+
// requestUpdate() and delay required, else we cant find element because it won't exist immediately
|
603
500
|
const tmpElementId = elementId.indexOf('#') === -1 ? elementId : elementId.substring(1);
|
604
501
|
window.setTimeout(() => {
|
605
502
|
const gotoEl = this.shadowRoot.getElementById(tmpElementId);
|
606
|
-
|
607
503
|
if (gotoEl) {
|
608
504
|
gotoEl.scrollIntoView({
|
609
505
|
behavior: 'auto',
|
@@ -613,41 +509,34 @@ class OpenApiExplorer extends _lit.LitElement {
|
|
613
509
|
}
|
614
510
|
}, isExpandingNeeded ? 150 : 0);
|
615
511
|
}
|
616
|
-
|
617
512
|
isValidTopId(id) {
|
618
513
|
return id.startsWith('overview') || id === 'servers' || id === 'auth';
|
619
514
|
}
|
620
|
-
|
621
515
|
isValidPathId(id) {
|
622
516
|
if (id === 'overview' && !this.hideInfo) {
|
623
517
|
return true;
|
624
518
|
}
|
625
|
-
|
626
519
|
if (id === 'servers' && !this.hideServerSelection) {
|
627
520
|
return true;
|
628
521
|
}
|
629
|
-
|
630
522
|
if (id === 'auth' && !this.hideAuthentication) {
|
631
523
|
return true;
|
632
524
|
}
|
633
|
-
|
634
525
|
if (id.startsWith('tag--')) {
|
635
526
|
return this.resolvedSpec.tags && this.resolvedSpec.tags.find(tag => tag.elementId === id);
|
636
527
|
}
|
637
|
-
|
638
528
|
return this.resolvedSpec.tags && this.resolvedSpec.tags.find(tag => tag.paths.find(path => path.elementId === id));
|
639
529
|
}
|
640
|
-
|
641
530
|
onIntersect(entries) {
|
642
531
|
if (this.isIntersectionObserverActive === false) {
|
643
532
|
return;
|
644
533
|
}
|
645
|
-
|
646
534
|
entries.forEach(entry => {
|
647
535
|
if (entry.isIntersecting && entry.intersectionRatio > 0) {
|
648
536
|
const oldNavEl = this.shadowRoot.querySelector('.nav-bar-tag.active, .nav-bar-path.active, .nav-bar-info.active, .nav-bar-h1.active, .nav-bar-h2.active');
|
649
|
-
const newNavEl = this.shadowRoot.getElementById(`link-${entry.target.id}`);
|
537
|
+
const newNavEl = this.shadowRoot.getElementById(`link-${entry.target.id}`);
|
650
538
|
|
539
|
+
// Add active class in the new element
|
651
540
|
if (newNavEl) {
|
652
541
|
(0, _commonUtils.replaceState)(entry.target.id);
|
653
542
|
newNavEl.scrollIntoView({
|
@@ -655,24 +544,21 @@ class OpenApiExplorer extends _lit.LitElement {
|
|
655
544
|
block: 'center'
|
656
545
|
});
|
657
546
|
newNavEl.classList.add('active');
|
658
|
-
}
|
659
|
-
|
660
|
-
|
547
|
+
}
|
548
|
+
// Remove active class from previous element
|
661
549
|
if (oldNavEl) {
|
662
550
|
oldNavEl.classList.remove('active');
|
663
551
|
}
|
664
552
|
}
|
665
553
|
});
|
666
|
-
}
|
667
|
-
|
554
|
+
}
|
668
555
|
|
556
|
+
// Called by anchor tags created using markdown
|
669
557
|
handleHref(e) {
|
670
558
|
if (e.target.tagName.toLowerCase() === 'a') {
|
671
559
|
const anchor = e.target.getAttribute('href');
|
672
|
-
|
673
560
|
if (anchor && anchor.startsWith('#')) {
|
674
561
|
const gotoEl = this.shadowRoot.getElementById(anchor.replace('#', ''));
|
675
|
-
|
676
562
|
if (gotoEl) {
|
677
563
|
gotoEl.scrollIntoView({
|
678
564
|
behavior: 'auto',
|
@@ -682,6 +568,7 @@ class OpenApiExplorer extends _lit.LitElement {
|
|
682
568
|
}
|
683
569
|
}
|
684
570
|
}
|
571
|
+
|
685
572
|
/**
|
686
573
|
* Called by
|
687
574
|
* - onClick of Navigation Bar
|
@@ -693,106 +580,96 @@ class OpenApiExplorer extends _lit.LitElement {
|
|
693
580
|
* 3. Activate IntersectionObserver (after little delay)
|
694
581
|
*
|
695
582
|
*/
|
696
|
-
|
697
|
-
|
698
583
|
scrollToEventTarget(event, scrollNavItemToView = true) {
|
699
584
|
const navEl = event.currentTarget;
|
700
|
-
|
701
585
|
if (!navEl.dataset.contentId) {
|
702
586
|
return;
|
703
587
|
}
|
704
|
-
|
705
588
|
this.isIntersectionObserverActive = false;
|
706
589
|
this.scrollTo(navEl.dataset.contentId, scrollNavItemToView);
|
707
590
|
setTimeout(() => {
|
708
591
|
this.isIntersectionObserverActive = true;
|
709
592
|
}, 300);
|
710
593
|
}
|
711
|
-
|
712
594
|
scrollToCustomNavSectionTarget(event, scrollNavItemToView = true) {
|
713
595
|
const navEl = event.currentTarget;
|
714
|
-
|
715
596
|
if (!navEl.dataset.contentId) {
|
716
597
|
return;
|
717
598
|
}
|
718
|
-
|
719
599
|
const navSectionSlot = this.shadowRoot.querySelector('slot.custom-nav-section');
|
720
|
-
const assignedNodes = navSectionSlot === null || navSectionSlot === void 0 ? void 0 : navSectionSlot.assignedNodes();
|
600
|
+
const assignedNodes = navSectionSlot === null || navSectionSlot === void 0 ? void 0 : navSectionSlot.assignedNodes();
|
721
601
|
|
602
|
+
// clicked child node could be multiple levels deep in a custom nav
|
722
603
|
const hasChildNode = node => {
|
723
604
|
return node === event.target || node.children && [...node.children].some(c => hasChildNode(c));
|
724
605
|
};
|
725
|
-
|
726
606
|
let repeatedElementIndex = assignedNodes && [].findIndex.call(assignedNodes, slot => hasChildNode(slot));
|
727
|
-
|
728
607
|
if (repeatedElementIndex === -1 && navEl.dataset.contentId.match(/^section--\d+/)) {
|
729
608
|
repeatedElementIndex = Number(navEl.dataset.contentId.split('--')[1]) - 1;
|
730
609
|
}
|
731
|
-
|
732
610
|
this.isIntersectionObserverActive = false;
|
733
611
|
this.scrollTo(navEl.dataset.contentId, scrollNavItemToView, repeatedElementIndex);
|
734
612
|
setTimeout(() => {
|
735
613
|
this.isIntersectionObserverActive = true;
|
736
614
|
}, 300);
|
737
|
-
}
|
738
|
-
|
615
|
+
}
|
616
|
+
async scrollToSchemaComponentByName(schemaComponentNameEvent) {
|
617
|
+
var _this$resolvedSpec2, _this$resolvedSpec2$c, _this$resolvedSpec2$c2, _this$resolvedSpec2$c3;
|
618
|
+
const schemaComponentName = schemaComponentNameEvent.detail;
|
619
|
+
const schemaComponent = (_this$resolvedSpec2 = this.resolvedSpec) === null || _this$resolvedSpec2 === void 0 ? void 0 : (_this$resolvedSpec2$c = _this$resolvedSpec2.components) === null || _this$resolvedSpec2$c === void 0 ? void 0 : (_this$resolvedSpec2$c2 = _this$resolvedSpec2$c.find(c => c.componentKeyId === 'schemas')) === null || _this$resolvedSpec2$c2 === void 0 ? void 0 : (_this$resolvedSpec2$c3 = _this$resolvedSpec2$c2.subComponents) === null || _this$resolvedSpec2$c3 === void 0 ? void 0 : _this$resolvedSpec2$c3.find(s => s.name === schemaComponentName);
|
620
|
+
if (schemaComponent) {
|
621
|
+
await this.scrollTo(`cmp--${schemaComponent.id}`, true);
|
622
|
+
}
|
623
|
+
}
|
739
624
|
|
625
|
+
// Public Method (scrolls to a given path and highlights the left-nav selection)
|
740
626
|
async scrollTo(elementId, scrollNavItemToView = true, repeatedElementIndex) {
|
741
627
|
try {
|
742
628
|
await this.scrollToOrThrowException(elementId, scrollNavItemToView, repeatedElementIndex);
|
743
629
|
} catch (error) {
|
744
630
|
// There's an issue for lit elements for some browsers which are causing this issue we'll log here and still throw
|
745
631
|
console.error('Failed to scroll to target', elementId, scrollNavItemToView, repeatedElementIndex, error); // eslint-disable-line no-console
|
746
|
-
|
747
632
|
throw error;
|
748
633
|
}
|
749
634
|
}
|
750
|
-
|
751
635
|
async scrollToOrThrowException(elementId, scrollNavItemToView = true, forcedRepeatedElementIndex) {
|
752
636
|
if (!this.resolvedSpec) {
|
753
637
|
return;
|
754
638
|
}
|
755
|
-
|
756
639
|
this.emitOperationChangedEvent(elementId);
|
757
|
-
|
758
640
|
if (this.renderStyle === 'view') {
|
759
641
|
this.expandAndGotoOperation(elementId);
|
760
642
|
return;
|
761
|
-
}
|
762
|
-
|
643
|
+
}
|
763
644
|
|
645
|
+
// explorerLocation will get validated in the focused-endpoint-template
|
764
646
|
this.explorerLocation = elementId;
|
765
647
|
const tag = this.resolvedSpec.tags.find(t => t.paths.some(p => p.elementId === elementId));
|
766
|
-
|
767
648
|
if (tag) {
|
768
649
|
tag.expanded = true;
|
769
|
-
}
|
770
|
-
|
771
|
-
|
772
|
-
await (0, _commonUtils.sleep)(0); // In the case of section scrolling, these are hard swaps, so just load "section". In the case of `tags` the headers have the element html Id in the last `--id`, so split that off and check for it
|
650
|
+
}
|
651
|
+
// Convert to Async and to the background, so that we can be sure that the operation has been expanded and put into view before trying to directly scroll to it (or it won't be found in the next line and even if it is, it might not be able to be scrolled into view)
|
652
|
+
await (0, _commonUtils.sleep)(0);
|
773
653
|
|
654
|
+
// In the case of section scrolling, these are hard swaps, so just load "section". In the case of `tags` the headers have the element html Id in the last `--id`, so split that off and check for it
|
774
655
|
const contentEl = this.shadowRoot.getElementById(elementId !== null && elementId !== void 0 && elementId.startsWith('section') ? 'section' : elementId) || this.shadowRoot.getElementById(elementId.split('--').slice(-1)[0]);
|
775
|
-
|
776
656
|
if (!contentEl) {
|
777
657
|
return;
|
778
|
-
}
|
779
|
-
|
658
|
+
}
|
780
659
|
|
660
|
+
// For focused APIs, always scroll to the top of the component
|
781
661
|
let newNavEl;
|
782
662
|
let waitForComponentToExpand = false;
|
783
663
|
const elementIndex = forcedRepeatedElementIndex || forcedRepeatedElementIndex === 0 ? forcedRepeatedElementIndex : Number(elementId.split('--')[1]) - 1;
|
784
|
-
|
785
664
|
if (elementId.match(/^section/)) {
|
786
665
|
const customSections = this.shadowRoot.querySelector('slot.custom-section');
|
787
666
|
const assignedNodesToCustomSections = customSections === null || customSections === void 0 ? void 0 : customSections.assignedNodes();
|
788
|
-
|
789
667
|
if (assignedNodesToCustomSections) {
|
790
668
|
try {
|
791
669
|
assignedNodesToCustomSections.map(customSection => {
|
792
670
|
customSection.classList.remove('active');
|
793
671
|
});
|
794
672
|
const newActiveCustomSection = assignedNodesToCustomSections[elementIndex];
|
795
|
-
|
796
673
|
if (newActiveCustomSection && !newActiveCustomSection.classList.contains('active')) {
|
797
674
|
newActiveCustomSection.classList.add('active');
|
798
675
|
}
|
@@ -801,69 +678,66 @@ class OpenApiExplorer extends _lit.LitElement {
|
|
801
678
|
console.error('Failed to switch between custom sections, usually happens because the DOM is not ready and has not loaded these sections yet.', error);
|
802
679
|
}
|
803
680
|
}
|
804
|
-
|
805
681
|
const navSectionSlot = this.shadowRoot.querySelector('slot.custom-nav-section');
|
806
682
|
const assignedNodes = navSectionSlot === null || navSectionSlot === void 0 ? void 0 : navSectionSlot.assignedNodes();
|
807
|
-
newNavEl = assignedNodes === null || assignedNodes === void 0 ? void 0 : assignedNodes[elementIndex];
|
683
|
+
newNavEl = assignedNodes === null || assignedNodes === void 0 ? void 0 : assignedNodes[elementIndex];
|
808
684
|
|
685
|
+
// Update Location Hash
|
809
686
|
(0, _commonUtils.replaceState)(`section--${elementIndex + 1}`);
|
810
687
|
} else if (elementId.match('cmp--')) {
|
811
688
|
const component = this.resolvedSpec.components.find(c => c.subComponents.find(sub => elementId.includes(sub.id)));
|
812
|
-
|
813
689
|
if (component && !component.expanded) {
|
814
690
|
waitForComponentToExpand = true;
|
815
691
|
component.expanded = true;
|
816
692
|
}
|
817
|
-
|
818
693
|
contentEl.scrollIntoView({
|
819
694
|
behavior: 'auto',
|
820
695
|
block: 'start'
|
821
|
-
});
|
696
|
+
});
|
822
697
|
|
698
|
+
// Update Location Hash
|
823
699
|
(0, _commonUtils.replaceState)(elementId);
|
824
700
|
newNavEl = this.shadowRoot.getElementById(`link-${elementId}`);
|
825
701
|
} else if (!elementId.match('cmp--') && !elementId.match('tag--')) {
|
826
702
|
this.shadowRoot.getElementById('operations-root').scrollIntoView({
|
827
703
|
behavior: 'auto',
|
828
704
|
block: 'start'
|
829
|
-
});
|
705
|
+
});
|
830
706
|
|
707
|
+
// Update Location Hash
|
831
708
|
(0, _commonUtils.replaceState)(elementId);
|
832
709
|
newNavEl = this.shadowRoot.getElementById(`link-${elementId}`);
|
833
710
|
} else {
|
834
711
|
contentEl.scrollIntoView({
|
835
712
|
behavior: 'auto',
|
836
713
|
block: 'start'
|
837
|
-
});
|
714
|
+
});
|
838
715
|
|
716
|
+
// Update Location Hash
|
839
717
|
(0, _commonUtils.replaceState)(elementId);
|
840
718
|
newNavEl = this.shadowRoot.getElementById(`link-${elementId}`);
|
841
|
-
}
|
842
|
-
|
719
|
+
}
|
843
720
|
|
721
|
+
// for focused style it is important to reset request-body-selection and response selection which maintains the state for in case of multiple req-body or multiple response mime-type
|
844
722
|
const requestEl = this.shadowRoot.querySelector('api-request');
|
845
|
-
|
846
723
|
if (requestEl) {
|
847
724
|
requestEl.resetRequestBodySelection();
|
848
725
|
}
|
849
|
-
|
850
726
|
const responseEl = this.shadowRoot.querySelector('api-response');
|
851
|
-
|
852
727
|
if (responseEl) {
|
853
728
|
responseEl.resetSelection();
|
854
|
-
}
|
855
|
-
|
729
|
+
}
|
856
730
|
|
731
|
+
// Update NavBar View and Styles
|
857
732
|
if (!newNavEl) {
|
858
733
|
return;
|
859
734
|
}
|
860
|
-
|
861
735
|
if (scrollNavItemToView) {
|
862
736
|
newNavEl.scrollIntoView({
|
863
737
|
behavior: 'auto',
|
864
738
|
block: 'center'
|
865
|
-
});
|
866
|
-
|
739
|
+
});
|
740
|
+
// Also force it into view again if for some reason it isn't there
|
867
741
|
if (waitForComponentToExpand) {
|
868
742
|
setTimeout(() => newNavEl.scrollIntoView({
|
869
743
|
behavior: 'auto',
|
@@ -871,42 +745,35 @@ class OpenApiExplorer extends _lit.LitElement {
|
|
871
745
|
}), 600);
|
872
746
|
}
|
873
747
|
}
|
874
|
-
|
875
748
|
await (0, _commonUtils.sleep)(0);
|
876
749
|
const oldNavEl = this.shadowRoot.querySelector('.nav-bar-tag.active, .nav-bar-path.active, .nav-bar-info.active, .nav-bar-h1.active, .nav-bar-h2.active');
|
877
|
-
|
878
750
|
if (oldNavEl) {
|
879
751
|
oldNavEl.classList.remove('active');
|
880
752
|
}
|
881
|
-
|
882
753
|
const navSectionSlot = this.shadowRoot.querySelector('slot.custom-nav-section');
|
883
754
|
const assignedNodes = navSectionSlot === null || navSectionSlot === void 0 ? void 0 : navSectionSlot.assignedNodes();
|
884
755
|
(assignedNodes || []).filter((n, nodeIndex) => isNaN(elementIndex) || nodeIndex !== elementIndex).forEach(node => {
|
885
756
|
node.classList.remove('active');
|
886
757
|
});
|
887
758
|
newNavEl.classList.add('active'); // must add the class after scrolling
|
888
|
-
|
889
759
|
this.requestUpdate();
|
890
|
-
}
|
891
|
-
|
760
|
+
}
|
892
761
|
|
762
|
+
// Event handler for Advanced Search text-inputs and checkboxes
|
893
763
|
onAdvancedSearch(ev) {
|
894
764
|
const eventTargetEl = ev.target;
|
895
765
|
clearTimeout(this.timeoutId);
|
896
766
|
this.timeoutId = setTimeout(() => {
|
897
767
|
let searchInputEl;
|
898
|
-
|
899
768
|
if (eventTargetEl.type === 'text') {
|
900
769
|
searchInputEl = eventTargetEl;
|
901
770
|
} else {
|
902
771
|
searchInputEl = eventTargetEl.closest('.advanced-search-options').querySelector('input[type=text]');
|
903
772
|
}
|
904
|
-
|
905
773
|
const searchOptions = [...eventTargetEl.closest('.advanced-search-options').querySelectorAll('input:checked')].map(v => v.id);
|
906
774
|
this.advancedSearchMatches = (0, _commonUtils.advancedSearch)(searchInputEl.value, this.resolvedSpec.tags, searchOptions);
|
907
775
|
}, 0);
|
908
776
|
}
|
909
|
-
|
910
777
|
emitOperationChangedEvent(elementId) {
|
911
778
|
const operation = this.resolvedSpec.tags.map(t => t.paths).flat(1).find(p => p.elementId === elementId);
|
912
779
|
const event = {
|
@@ -920,11 +787,8 @@ class OpenApiExplorer extends _lit.LitElement {
|
|
920
787
|
};
|
921
788
|
this.dispatchEvent(new CustomEvent('event', event));
|
922
789
|
}
|
923
|
-
|
924
790
|
}
|
925
|
-
|
926
791
|
exports.default = OpenApiExplorer;
|
927
|
-
|
928
792
|
if (!customElements.get('openapi-explorer')) {
|
929
793
|
customElements.define('openapi-explorer', OpenApiExplorer);
|
930
794
|
}
|