rapidoc 9.3.7 → 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/README.md +193 -61
  2. package/dist/rapidoc-min.js +279 -3912
  3. package/package.json +24 -47
  4. package/.babelrc.json +0 -42
  5. package/.eslintrc +0 -53
  6. package/.github/FUNDING.yml +0 -13
  7. package/.github/workflow/words.yaml +0 -22
  8. package/CONTRIBUTING.md +0 -35
  9. package/dist/index.html +0 -6
  10. package/dist/index.html.gz +0 -0
  11. package/dist/rapidoc-min.js.LICENSE.txt +0 -64
  12. package/dist/rapidoc-min.js.LICENSE.txt.gz +0 -0
  13. package/dist/rapidoc-min.js.gz +0 -0
  14. package/dist/rapidoc-min.js.map +0 -1
  15. package/dist/rapidoc-min.js.map.gz +0 -0
  16. package/dist/rapidoc.js +0 -21594
  17. package/dist/report.html +0 -39
  18. package/index-hashroute.html +0 -65
  19. package/index.html +0 -249
  20. package/index1.html +0 -244
  21. package/jsconfig.json +0 -11
  22. package/logo.png +0 -0
  23. package/performance.html +0 -31
  24. package/src/components/api-request.js +0 -1787
  25. package/src/components/api-response.js +0 -335
  26. package/src/components/dialog-box.js +0 -73
  27. package/src/components/json-tree.js +0 -145
  28. package/src/components/schema-table.js +0 -358
  29. package/src/components/schema-tree.js +0 -378
  30. package/src/components/tag-input.js +0 -135
  31. package/src/index.js +0 -7
  32. package/src/json-schema-viewer.js +0 -345
  33. package/src/oauth-receiver.js +0 -56
  34. package/src/rapidoc-mini.js +0 -380
  35. package/src/rapidoc.js +0 -1082
  36. package/src/styles/border-styles.js +0 -24
  37. package/src/styles/custom-styles.js +0 -10
  38. package/src/styles/dialog-box-styles.js +0 -75
  39. package/src/styles/endpoint-styles.js +0 -202
  40. package/src/styles/flex-styles.js +0 -15
  41. package/src/styles/font-styles.js +0 -268
  42. package/src/styles/info-styles.js +0 -21
  43. package/src/styles/input-styles.js +0 -202
  44. package/src/styles/nav-styles.js +0 -198
  45. package/src/styles/prism-styles.js +0 -105
  46. package/src/styles/schema-styles.js +0 -121
  47. package/src/styles/tab-styles.js +0 -47
  48. package/src/styles/table-styles.js +0 -58
  49. package/src/templates/advance-search-template.js +0 -72
  50. package/src/templates/callback-template.js +0 -73
  51. package/src/templates/code-samples-template.js +0 -34
  52. package/src/templates/components-template.js +0 -76
  53. package/src/templates/endpoint-template.js +0 -249
  54. package/src/templates/expanded-endpoint-template.js +0 -197
  55. package/src/templates/focused-endpoint-template.js +0 -110
  56. package/src/templates/header-template.js +0 -66
  57. package/src/templates/json-schema-viewer-template.js +0 -185
  58. package/src/templates/logo-template.js +0 -18
  59. package/src/templates/main-body-template.js +0 -121
  60. package/src/templates/navbar-template.js +0 -272
  61. package/src/templates/overview-template.js +0 -79
  62. package/src/templates/security-scheme-template.js +0 -610
  63. package/src/templates/server-template.js +0 -115
  64. package/src/utils/color-utils.js +0 -59
  65. package/src/utils/common-utils.js +0 -168
  66. package/src/utils/schema-utils.js +0 -1086
  67. package/src/utils/spec-parser.js +0 -462
  68. package/src/utils/theme.js +0 -288
  69. package/webpack.config.js +0 -142
package/src/rapidoc.js DELETED
@@ -1,1082 +0,0 @@
1
- import { css, LitElement, unsafeCSS } from 'lit';
2
- import { marked } from 'marked';
3
- import Prism from 'prismjs';
4
- import 'prismjs/components/prism-css';
5
- import 'prismjs/components/prism-yaml';
6
- import 'prismjs/components/prism-go';
7
- import 'prismjs/components/prism-java';
8
- import 'prismjs/components/prism-json';
9
- import 'prismjs/components/prism-bash';
10
- import 'prismjs/components/prism-python';
11
- import 'prismjs/components/prism-http';
12
- import 'prismjs/components/prism-csharp';
13
-
14
- // Styles
15
- import FontStyles from '~/styles/font-styles';
16
- import InputStyles from '~/styles/input-styles';
17
- import FlexStyles from '~/styles/flex-styles';
18
- import TableStyles from '~/styles/table-styles';
19
- import EndpointStyles from '~/styles/endpoint-styles';
20
- import PrismStyles from '~/styles/prism-styles';
21
- import TabStyles from '~/styles/tab-styles';
22
- import NavStyles from '~/styles/nav-styles';
23
- import InfoStyles from '~/styles/info-styles';
24
- import CustomStyles from '~/styles/custom-styles';
25
- // import { expandCollapseNavBarTag } from '@/templates/navbar-template';
26
- import { advancedSearch, getMatchedPaths, getMatchedComponents, rapidocApiKey, sleep } from '~/utils/common-utils';
27
- import ProcessSpec from '~/utils/spec-parser';
28
- import mainBodyTemplate from '~/templates/main-body-template';
29
- import { applyApiKey, onClearAllApiKeys } from '~/templates/security-scheme-template';
30
- import { setApiServer } from '~/templates/server-template';
31
-
32
- export default class RapiDoc extends LitElement {
33
- constructor() {
34
- super();
35
- const intersectionObserverOptions = {
36
- root: this.getRootNode().host,
37
- rootMargin: '-50px 0px -50px 0px', // when the element is visible 100px from bottom
38
- threshold: 0,
39
- };
40
- this.showSummaryWhenCollapsed = true;
41
- // Will activate intersection observer only after spec load and hash analyze
42
- // to scroll to the proper element without being reverted by observer behavior
43
- this.isIntersectionObserverActive = false;
44
- this.intersectionObserver = new IntersectionObserver((entries) => { this.onIntersect(entries); }, intersectionObserverOptions);
45
- }
46
-
47
- static get properties() {
48
- return {
49
- // Heading
50
- headingText: { type: String, attribute: 'heading-text' },
51
- gotoPath: { type: String, attribute: 'goto-path' },
52
-
53
- // Spec
54
- updateRoute: { type: String, attribute: 'update-route' },
55
- routePrefix: { type: String, attribute: 'route-prefix' },
56
- specUrl: { type: String, attribute: 'spec-url' },
57
- sortTags: { type: String, attribute: 'sort-tags' },
58
- sortSchemas: { type: String, attribute: 'sort-schemas' },
59
- generateMissingTags: { type: String, attribute: 'generate-missing-tags' },
60
- sortEndpointsBy: { type: String, attribute: 'sort-endpoints-by' },
61
- specFile: { type: String, attribute: false },
62
-
63
- // UI Layouts
64
- layout: { type: String },
65
- renderStyle: { type: String, attribute: 'render-style' },
66
- defaultSchemaTab: { type: String, attribute: 'default-schema-tab' },
67
- responseAreaHeight: { type: String, attribute: 'response-area-height' },
68
- fillRequestFieldsWithExample: { type: String, attribute: 'fill-request-fields-with-example' },
69
- persistAuth: { type: String, attribute: 'persist-auth' },
70
- onNavTagClick: { type: String, attribute: 'on-nav-tag-click' },
71
-
72
- // Schema Styles
73
- schemaStyle: { type: String, attribute: 'schema-style' },
74
- schemaExpandLevel: { type: Number, attribute: 'schema-expand-level' },
75
- schemaDescriptionExpanded: { type: String, attribute: 'schema-description-expanded' },
76
- schemaHideReadOnly: { type: String, attribute: 'schema-hide-read-only' },
77
- schemaHideWriteOnly: { type: String, attribute: 'schema-hide-write-only' },
78
-
79
- // API Server
80
- apiKeyName: { type: String, attribute: 'api-key-name' },
81
- apiKeyLocation: { type: String, attribute: 'api-key-location' },
82
- apiKeyValue: { type: String, attribute: 'api-key-value' },
83
- defaultApiServerUrl: { type: String, attribute: 'default-api-server' },
84
- serverUrl: { type: String, attribute: 'server-url' },
85
- oauthReceiver: { type: String, attribute: 'oauth-receiver' },
86
-
87
- // Hide/Show Sections & Enable Disable actions
88
- showHeader: { type: String, attribute: 'show-header' },
89
- showSideNav: { type: String, attribute: 'show-side-nav' },
90
- showInfo: { type: String, attribute: 'show-info' },
91
- allowAuthentication: { type: String, attribute: 'allow-authentication' },
92
- allowTry: { type: String, attribute: 'allow-try' },
93
- showCurlBeforeTry: { type: String, attribute: 'show-curl-before-try' },
94
- allowSpecUrlLoad: { type: String, attribute: 'allow-spec-url-load' },
95
- allowSpecFileLoad: { type: String, attribute: 'allow-spec-file-load' },
96
- allowSpecFileDownload: { type: String, attribute: 'allow-spec-file-download' },
97
- allowSearch: { type: String, attribute: 'allow-search' },
98
- allowAdvancedSearch: { type: String, attribute: 'allow-advanced-search' },
99
- allowServerSelection: { type: String, attribute: 'allow-server-selection' },
100
- allowSchemaDescriptionExpandToggle: { type: String, attribute: 'allow-schema-description-expand-toggle' },
101
- showComponents: { type: String, attribute: 'show-components' },
102
- pageDirection: { type: String, attribute: 'page-direction' },
103
- scrollBehavior: { type: String, attribute: 'scroll-behavior' },
104
-
105
- // Main Colors and Font
106
- theme: { type: String },
107
- bgColor: { type: String, attribute: 'bg-color' },
108
- textColor: { type: String, attribute: 'text-color' },
109
- headerColor: { type: String, attribute: 'header-color' },
110
- primaryColor: { type: String, attribute: 'primary-color' },
111
- fontSize: { type: String, attribute: 'font-size' },
112
- regularFont: { type: String, attribute: 'regular-font' },
113
- monoFont: { type: String, attribute: 'mono-font' },
114
- loadFonts: { type: String, attribute: 'load-fonts' },
115
- cssFile: { type: String, attribute: 'css-file' },
116
- cssClasses: { type: String, attribute: 'css-classes' },
117
-
118
- // Nav Bar Colors
119
- navBgColor: { type: String, attribute: 'nav-bg-color' },
120
- navTextColor: { type: String, attribute: 'nav-text-color' },
121
- navHoverBgColor: { type: String, attribute: 'nav-hover-bg-color' },
122
- navHoverTextColor: { type: String, attribute: 'nav-hover-text-color' },
123
- navAccentColor: { type: String, attribute: 'nav-accent-color' },
124
- navAccentTextColor: { type: String, attribute: 'nav-accent-text-color' },
125
- navActiveItemMarker: { type: String, attribute: 'nav-active-item-marker' },
126
- navItemSpacing: { type: String, attribute: 'nav-item-spacing' },
127
- showMethodInNavBar: { type: String, attribute: 'show-method-in-nav-bar' },
128
- usePathInNavBar: { type: String, attribute: 'use-path-in-nav-bar' },
129
- infoDescriptionHeadingsInNavBar: { type: String, attribute: 'info-description-headings-in-navbar' },
130
-
131
- // Fetch Options
132
- fetchCredentials: { type: String, attribute: 'fetch-credentials' },
133
-
134
- // Filters
135
- matchPaths: { type: String, attribute: 'match-paths' },
136
- matchType: { type: String, attribute: 'match-type' },
137
- removeEndpointsWithBadgeLabelAs: { type: String, attribute: 'remove-endpoints-with-badge-label-as' },
138
-
139
- // Internal Properties
140
- loading: { type: Boolean }, // indicates spec is being loaded
141
- focusedElementId: { type: String }, // updating the focusedElementId will automatically render appropriate section in focused mode
142
- showAdvancedSearchDialog: { type: Boolean },
143
- advancedSearchMatches: { type: Object },
144
- searchVal: { type: String },
145
- };
146
- }
147
-
148
- static get styles() {
149
- return [
150
- FontStyles,
151
- InputStyles,
152
- FlexStyles,
153
- TableStyles,
154
- EndpointStyles,
155
- PrismStyles,
156
- TabStyles,
157
- NavStyles,
158
- InfoStyles,
159
- css`
160
- :host {
161
- display:flex;
162
- flex-direction: column;
163
- min-width:360px;
164
- width:100%;
165
- height:100%;
166
- margin:0;
167
- padding:0;
168
- overflow: hidden;
169
- letter-spacing:normal;
170
- color:var(--fg);
171
- background-color:var(--bg);
172
- font-family:var(--font-regular);
173
- container-type: inline-size;
174
- }
175
- :where(button, input[type="checkbox"], [tabindex="0"]):focus-visible { box-shadow: var(--focus-shadow); }
176
- :where(input[type="text"], input[type="password"], select, textarea):focus-visible { border-color: var(--primary-color); }
177
- .body {
178
- display:flex;
179
- height:100%;
180
- width:100%;
181
- overflow:hidden;
182
- }
183
- .main-content {
184
- margin:0;
185
- padding: 0;
186
- display:block;
187
- flex:1;
188
- height:100%;
189
- overflow-y: auto;
190
- overflow-x: hidden;
191
- scrollbar-width: thin;
192
- scrollbar-color: var(--border-color) transparent;
193
- }
194
-
195
- .main-content-inner--view-mode {
196
- padding: 0 8px;
197
- }
198
- .main-content::-webkit-scrollbar {
199
- width: 8px;
200
- height: 8px;
201
- }
202
- .main-content::-webkit-scrollbar-track {
203
- background:transparent;
204
- }
205
- .main-content::-webkit-scrollbar-thumb {
206
- background-color: var(--border-color);
207
- }
208
-
209
- .section-gap.section-tag {
210
- border-bottom:1px solid var(--border-color);
211
- }
212
- .section-gap,
213
- .section-gap--focused-mode,
214
- .section-gap--read-mode {
215
- padding: 0px 4px;
216
- }
217
- .section-tag-header {
218
- position:relative;
219
- cursor: n-resize;
220
- padding: 12px 0;
221
- }
222
- .collapsed .section-tag-header:hover {
223
- cursor: s-resize;
224
- }
225
-
226
- .section-tag-header:hover {
227
- background-image: linear-gradient(to right, rgba(0,0,0,0), var(--border-color), rgba(0,0,0,0));
228
- }
229
-
230
- .section-tag-header:hover::after {
231
- position:absolute;
232
- margin-left:-24px;
233
- font-size:20px;
234
- top: calc(50% - 14px);
235
- color:var(--primary-color);
236
- content: '⬆';
237
- }
238
-
239
- .collapsed .section-tag-header::after {
240
- position:absolute;
241
- margin-left:-24px;
242
- font-size:20px;
243
- top: calc(50% - 14px);
244
- color: var(--border-color);
245
- content: '⬇';
246
- }
247
- .collapsed .section-tag-header:hover::after {
248
- color:var(--primary-color);
249
- }
250
-
251
- .collapsed .section-tag-body {
252
- display:none;
253
- }
254
-
255
- .logo {
256
- height:36px;
257
- width:36px;
258
- margin-left:5px;
259
- }
260
- .only-large-screen-flex,
261
- .only-large-screen {
262
- display:none;
263
- }
264
- .tag.title {
265
- text-transform: uppercase;
266
- }
267
- .main-header {
268
- background-color:var(--header-bg);
269
- color:var(--header-fg);
270
- width:100%;
271
- }
272
- .header-title {
273
- font-size:calc(var(--font-size-regular) + 8px);
274
- padding:0 8px;
275
- }
276
- input.header-input{
277
- background:var(--header-color-darker);
278
- color:var(--header-fg);
279
- border:1px solid var(--header-color-border);
280
- flex:1;
281
- padding-right:24px;
282
- border-radius:3px;
283
- }
284
- input.header-input::placeholder {
285
- opacity:0.4;
286
- }
287
- .loader {
288
- margin: 16px auto 16px auto;
289
- border: 4px solid var(--bg3);
290
- border-radius: 50%;
291
- border-top: 4px solid var(--primary-color);
292
- width: 36px;
293
- height: 36px;
294
- animation: spin 2s linear infinite;
295
- }
296
- .expanded-endpoint-body {
297
- position: relative;
298
- padding: 6px 0px;
299
- }
300
- .expanded-endpoint-body .tag-description {
301
- background: var(--code-bg);
302
- border-radius: var(--border-radius);
303
- transition: max-height .2s ease-out;
304
- }
305
- .expanded-endpoint-body .tag-icon {
306
- transition: transform .2s ease-out;
307
- }
308
- .expanded-endpoint-body .tag-icon.expanded {
309
- transform: rotate(180deg);
310
- }
311
- .divider {
312
- border-top: 2px solid var(--border-color);
313
- margin: 24px 0;
314
- width:100%;
315
- }
316
-
317
- .tooltip {
318
- cursor:pointer;
319
- border: 1px solid var(--border-color);
320
- border-left-width: 4px;
321
- margin-left:2px;
322
- }
323
- .tooltip a {
324
- color: var(--fg2);
325
- text-decoration: none;
326
- }
327
- .tooltip-text {
328
- color: var(--fg2);
329
- max-width: 400px;
330
- position: absolute;
331
- z-index:1;
332
- background-color: var(--bg2);
333
- visibility: hidden;
334
-
335
- overflow-wrap: break-word;
336
- }
337
- .tooltip:hover {
338
- color: var(--primary-color);
339
- border-color: var(--primary-color);
340
- }
341
- .tooltip:hover a:hover {
342
- color: var(--primary-color);
343
- }
344
-
345
- .tooltip:hover .tooltip-text {
346
- visibility: visible;
347
- }
348
-
349
- @keyframes spin {
350
- 0% { transform: rotate(0deg); }
351
- 100% { transform: rotate(360deg); }
352
- }
353
-
354
- .nav-method { font-weight: bold; margin-right: 4px; font-size: calc(var(--font-size-small) - 2px); white-space: nowrap; }
355
- .nav-method.false { display: none; }
356
-
357
- .nav-method.as-colored-text.get { color:var(--nav-get-color); }
358
- .nav-method.as-colored-text.put { color:var(--nav-put-color); }
359
- .nav-method.as-colored-text.post { color:var(--nav-post-color); }
360
- .nav-method.as-colored-text.delete { color:var(--nav-delete-color); }
361
- .nav-method.as-colored-text.head, .nav-method.as-colored-text.patch, .nav-method.as-colored-text.options { color:var(--nav-head-color); }
362
-
363
- .nav-method.as-colored-block {
364
- padding: 1px 4px;
365
- min-width: 30px;
366
- border-radius: 4px 0 0 4px;
367
- color: #000;
368
- }
369
- .colored-block .nav-method.as-colored-block {
370
- outline: 1px solid;
371
- }
372
-
373
- .nav-method.as-colored-block.get { background-color: var(--blue); }
374
- .nav-method.as-colored-block.put { background-color: var(--orange); }
375
- .nav-method.as-colored-block.post { background-color: var(--green); }
376
- .nav-method.as-colored-block.delete { background-color: var(--red); }
377
- .nav-method.as-colored-block.head, .nav-method.as-colored-block.patch , .nav-method.as-colored-block.options {
378
- background-color: var(--yellow);
379
- }
380
-
381
- @container (min-width: 768px) {
382
- .nav-bar {
383
- width: 260px;
384
- display:flex;
385
- }
386
- .only-large-screen {
387
- display:block;
388
- }
389
- .only-large-screen-flex {
390
- display:flex;
391
- }
392
- .section-gap {
393
- padding: 0 0 0 24px;
394
- }
395
- .section-gap--focused-mode {
396
- padding: 24px 8px;
397
- }
398
- .section-gap--read-mode {
399
- padding: 24px 8px;
400
- }
401
- .endpoint-body {
402
- position: relative;
403
- padding:36px 0 48px 0;
404
- }
405
- }
406
-
407
- @container (min-width: 1024px) {
408
- .nav-bar {
409
- width: ${unsafeCSS(this.fontSize === 'default' ? '300px' : this.fontSize === 'large' ? '315px' : '330px')};
410
- display:flex;
411
- }
412
- .section-gap--focused-mode {
413
- padding: 12px 80px 12px 80px;
414
- }
415
- .section-gap--read-mode {
416
- padding: 24px 80px 12px 80px;
417
- }
418
- }`,
419
- CustomStyles,
420
- ];
421
- }
422
-
423
- // Startup
424
- connectedCallback() {
425
- super.connectedCallback();
426
- const parent = this.parentElement;
427
- if (parent) {
428
- if (parent.offsetWidth === 0 && parent.style.width === '') {
429
- parent.style.width = '100vw';
430
- }
431
- if (parent.offsetHeight === 0 && parent.style.height === '') {
432
- parent.style.height = '100vh';
433
- }
434
- if (parent.tagName === 'BODY') {
435
- if (!parent.style.marginTop) { parent.style.marginTop = '0'; }
436
- if (!parent.style.marginRight) { parent.style.marginRight = '0'; }
437
- if (!parent.style.marginBottom) { parent.style.marginBottom = '0'; }
438
- if (!parent.style.marginLeft) { parent.style.marginLeft = '0'; }
439
- }
440
- }
441
-
442
- if (this.loadFonts !== 'false') {
443
- const fontDescriptor = {
444
- family: 'Open Sans',
445
- style: 'normal',
446
- weight: '300',
447
- unicodeRange: 'U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD',
448
- };
449
- const fontWeight300 = new FontFace(
450
- 'Open Sans',
451
- "url(https://fonts.gstatic.com/s/opensans/v18/mem5YaGs126MiZpBA-UN_r8OUuhpKKSTjw.woff2) format('woff2')",
452
- fontDescriptor,
453
- );
454
- fontDescriptor.weight = '600';
455
- const fontWeight600 = new FontFace(
456
- 'Open Sans',
457
- "url(https://fonts.gstatic.com/s/opensans/v18/mem5YaGs126MiZpBA-UNirkOUuhpKKSTjw.woff2) format('woff2')",
458
- fontDescriptor,
459
- );
460
- fontWeight300.load().then((font) => { document.fonts.add(font); });
461
- fontWeight600.load().then((font) => { document.fonts.add(font); });
462
- }
463
-
464
- if (!this.layout || !'row, column,'.includes(`${this.layout},`)) { this.layout = 'row'; }
465
- if (!this.renderStyle || !'read, view, focused,'.includes(`${this.renderStyle},`)) { this.renderStyle = 'focused'; }
466
- if (!this.schemaStyle || !'tree, table,'.includes(`${this.schemaStyle},`)) { this.schemaStyle = 'tree'; }
467
- if (!this.theme || !'light, dark,'.includes(`${this.theme},`)) {
468
- this.theme = (window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches) ? 'light' : 'dark';
469
- }
470
- if (!this.defaultSchemaTab || !'example, schema, model,'.includes(`${this.defaultSchemaTab},`)) {
471
- this.defaultSchemaTab = 'example';
472
- } else if (this.defaultSchemaTab === 'model') {
473
- this.defaultSchemaTab = 'schema';
474
- }
475
- if (!this.schemaExpandLevel || this.schemaExpandLevel < 1) { this.schemaExpandLevel = 99999; }
476
- if (!this.schemaDescriptionExpanded || !'true, false,'.includes(`${this.schemaDescriptionExpanded},`)) { this.schemaDescriptionExpanded = 'false'; }
477
-
478
- if (!this.schemaHideReadOnly || !'default, never,'.includes(`${this.schemaHideReadOnly},`)) { this.schemaHideReadOnly = 'default'; }
479
- if (!this.schemaHideWriteOnly || !'default, never,'.includes(`${this.schemaHideWriteOnly},`)) { this.schemaHideWriteOnly = 'default'; }
480
-
481
- if (!this.fillRequestFieldsWithExample || !'true, false,'.includes(`${this.fillRequestFieldsWithExample},`)) { this.fillRequestFieldsWithExample = 'true'; }
482
- if (!this.persistAuth || !'true, false,'.includes(`${this.persistAuth},`)) { this.persistAuth = 'false'; }
483
- if (!this.responseAreaHeight) {
484
- this.responseAreaHeight = '400px';
485
- }
486
-
487
- if (!this.allowSearch || !'true, false,'.includes(`${this.allowSearch},`)) { this.allowSearch = 'true'; }
488
- if (!this.allowAdvancedSearch || !'true, false,'.includes(`${this.allowAdvancedSearch},`)) { this.allowAdvancedSearch = 'true'; }
489
-
490
- if (!this.allowTry || !'true, false,'.includes(`${this.allowTry},`)) { this.allowTry = 'true'; }
491
- if (!this.apiKeyValue) { this.apiKeyValue = '-'; }
492
- if (!this.apiKeyLocation) { this.apiKeyLocation = 'header'; }
493
- if (!this.apiKeyName) { this.apiKeyName = ''; }
494
-
495
- if (!this.oauthReceiver) { this.oauthReceiver = 'oauth-receiver.html'; }
496
- if (!this.updateRoute || !'true, false,'.includes(`${this.updateRoute},`)) { this.updateRoute = 'true'; }
497
- if (!this.routePrefix) { this.routePrefix = '#'; }
498
- if (!this.sortTags || !'true, false,'.includes(`${this.sortTags},`)) { this.sortTags = 'false'; }
499
- if (!this.sortSchemas || !'true, false,'.includes(`${this.sortSchemas},`)) { this.sortSchemas = 'false'; }
500
- if (!this.generateMissingTags || !'true, false,'.includes(`${this.generateMissingTags},`)) { this.generateMissingTags = 'false'; }
501
- if (!this.sortEndpointsBy || !'method, path, summary, none,'.includes(`${this.sortEndpointsBy},`)) { this.sortEndpointsBy = 'path'; }
502
-
503
- if (!this.onNavTagClick || !'expand-collapse, show-description,'.includes(`${this.onNavTagClick},`)) { this.onNavTagClick = 'expand-collapse'; }
504
- if (!this.navItemSpacing || !'compact, relaxed, default,'.includes(`${this.navItemSpacing},`)) { this.navItemSpacing = 'default'; }
505
- if (!this.showMethodInNavBar || !'false, as-plain-text, as-colored-text, as-colored-block,'.includes(`${this.showMethodInNavBar},`)) { this.showMethodInNavBar = 'false'; }
506
- if (!this.usePathInNavBar || !'true, false,'.includes(`${this.usePathInNavBar},`)) { this.usePathInNavBar = 'false'; }
507
- if (!this.navActiveItemMarker || !'left-bar, colored-block'.includes(`${this.navActiveItemMarker},`)) { this.navActiveItemMarker = 'left-bar'; }
508
-
509
- if (!this.fontSize || !'default, large, largest,'.includes(`${this.fontSize},`)) { this.fontSize = 'default'; }
510
- if (!this.showInfo || !'true, false,'.includes(`${this.showInfo},`)) { this.showInfo = 'true'; }
511
- if (!this.allowServerSelection || !'true, false,'.includes(`${this.allowServerSelection},`)) { this.allowServerSelection = 'true'; }
512
- if (!this.allowAuthentication || !'true, false,'.includes(`${this.allowAuthentication},`)) { this.allowAuthentication = 'true'; }
513
- if (!this.allowSchemaDescriptionExpandToggle || !'true, false,'.includes(`${this.allowSchemaDescriptionExpandToggle},`)) { this.allowSchemaDescriptionExpandToggle = 'true'; }
514
-
515
- if (!this.showSideNav || !'true false'.includes(this.showSideNav)) { this.showSideNav = 'true'; }
516
- if (!this.showComponents || !'true false'.includes(this.showComponents)) { this.showComponents = 'false'; }
517
- if (!this.infoDescriptionHeadingsInNavBar || !'true, false,'.includes(`${this.infoDescriptionHeadingsInNavBar},`)) { this.infoDescriptionHeadingsInNavBar = 'false'; }
518
- if (!this.fetchCredentials || !'omit, same-origin, include,'.includes(`${this.fetchCredentials},`)) { this.fetchCredentials = ''; }
519
- if (!this.scrollBehavior || !'smooth, auto,'.includes(`${this.scrollBehavior},`)) { this.scrollBehavior = 'auto'; }
520
-
521
- if (!this.matchType || !'includes regex'.includes(this.matchType)) { this.matchType = 'includes'; }
522
- if (!this.matchPaths) { this.matchPaths = ''; }
523
- if (!this.removeEndpointsWithBadgeLabelAs) { this.removeEndpointsWithBadgeLabelAs = ''; }
524
- if (!this.showAdvancedSearchDialog) { this.showAdvancedSearchDialog = false; }
525
-
526
- if (!this.cssFile) { this.cssFile = null; }
527
- if (!this.cssClasses) { this.cssClasses = ''; }
528
-
529
- marked.setOptions({
530
- highlight: (code, lang) => {
531
- if (Prism.languages[lang]) {
532
- return Prism.highlight(code, Prism.languages[lang], lang);
533
- }
534
- return code;
535
- },
536
- });
537
-
538
- window.addEventListener('hashchange', () => {
539
- this.scrollToPath(this.getElementIDFromURL());
540
- }, true);
541
- }
542
-
543
- // Cleanup
544
- disconnectedCallback() {
545
- if (this.intersectionObserver) {
546
- this.intersectionObserver.disconnect();
547
- }
548
- super.disconnectedCallback();
549
- }
550
-
551
- infoDescriptionHeadingRenderer() {
552
- const renderer = new marked.Renderer();
553
- renderer.heading = ((text, level, raw, slugger) => `<h${level} class="observe-me" id="${slugger.slug(raw)}">${text}</h${level}>`);
554
- return renderer;
555
- }
556
-
557
- render() {
558
- // return render(mainBodyTemplate(this), this.shadowRoot, { eventContext: this });
559
- const cssLinkEl = document.querySelector(`link[href*="${this.cssFile}"]`);
560
- // adding custom style for RapiDoc
561
- if (cssLinkEl) {
562
- this.shadowRoot.appendChild(cssLinkEl.cloneNode());
563
- }
564
- return mainBodyTemplate.call(this);
565
- }
566
-
567
- observeExpandedContent() {
568
- // Main Container
569
- const observeOverviewEls = this.shadowRoot.querySelectorAll('.observe-me');
570
- observeOverviewEls.forEach((targetEl) => {
571
- this.intersectionObserver.observe(targetEl);
572
- });
573
- }
574
-
575
- attributeChangedCallback(name, oldVal, newVal) {
576
- if (name === 'spec-url') {
577
- if (oldVal !== newVal) {
578
- // put it at the end of event-loop to load all the attributes
579
- window.setTimeout(async () => {
580
- await this.loadSpec(newVal);
581
- // If goto-path is provided and no location-hash is present then try to scroll there
582
- if (this.gotoPath && !window.location.hash) {
583
- this.scrollToPath(this.gotoPath);
584
- }
585
- }, 0);
586
- }
587
- }
588
- if (name === 'match-paths' || name === 'match-type' || name === 'remove-endpoints-with-badge-label-as') {
589
- if (oldVal !== newVal) {
590
- window.setTimeout(async () => {
591
- await this.loadSpec(this.specUrl);
592
- }, 0);
593
- }
594
- }
595
- if (name === 'render-style') {
596
- if (newVal === 'read') {
597
- window.setTimeout(() => {
598
- this.observeExpandedContent();
599
- }, 100);
600
- } else {
601
- this.intersectionObserver.disconnect();
602
- }
603
- }
604
- if (name === 'api-key-name' || name === 'api-key-location' || name === 'api-key-value') {
605
- let updateSelectedApiKey = false;
606
- let apiKeyName = '';
607
- let apiKeyLocation = '';
608
- let apiKeyValue = '';
609
-
610
- if (name === 'api-key-name') {
611
- if (this.getAttribute('api-key-location') && this.getAttribute('api-key-value')) {
612
- apiKeyName = newVal;
613
- apiKeyLocation = this.getAttribute('api-key-location');
614
- apiKeyValue = this.getAttribute('api-key-value');
615
- updateSelectedApiKey = true;
616
- }
617
- } else if (name === 'api-key-location') {
618
- if (this.getAttribute('api-key-name') && this.getAttribute('api-key-value')) {
619
- apiKeyLocation = newVal;
620
- apiKeyName = this.getAttribute('api-key-name');
621
- apiKeyValue = this.getAttribute('api-key-value');
622
- updateSelectedApiKey = true;
623
- }
624
- } else if (name === 'api-key-value') {
625
- if (this.getAttribute('api-key-name') && this.getAttribute('api-key-location')) {
626
- apiKeyValue = newVal;
627
- apiKeyLocation = this.getAttribute('api-key-location');
628
- apiKeyName = this.getAttribute('api-key-name');
629
- updateSelectedApiKey = true;
630
- }
631
- }
632
-
633
- if (updateSelectedApiKey) {
634
- if (this.resolvedSpec) {
635
- const rapiDocApiKey = this.resolvedSpec.securitySchemes.find((v) => v.securitySchemeId === rapidocApiKey);
636
- if (!rapiDocApiKey) {
637
- this.resolvedSpec.securitySchemes.push({
638
- securitySchemeId: rapidocApiKey,
639
- description: 'api-key provided in rapidoc element attributes',
640
- type: 'apiKey',
641
- name: apiKeyName,
642
- in: apiKeyLocation,
643
- value: apiKeyValue,
644
- finalKeyValue: apiKeyValue,
645
- });
646
- } else {
647
- rapiDocApiKey.name = apiKeyName;
648
- rapiDocApiKey.in = apiKeyLocation;
649
- rapiDocApiKey.value = apiKeyValue;
650
- rapiDocApiKey.finalKeyValue = apiKeyValue;
651
- }
652
- this.requestUpdate();
653
- }
654
- }
655
- }
656
- super.attributeChangedCallback(name, oldVal, newVal);
657
- }
658
-
659
- onSpecUrlChange() {
660
- this.setAttribute('spec-url', this.shadowRoot.getElementById('spec-url').value);
661
- }
662
-
663
- onSpecFileChange(e) {
664
- this.setAttribute('spec-file', this.shadowRoot.getElementById('spec-file').value);
665
- const specFile = e.target.files[0];
666
- const reader = new FileReader();
667
- reader.onload = () => {
668
- try {
669
- const specObj = JSON.parse(reader.result);
670
- this.loadSpec(specObj);
671
- this.shadowRoot.getElementById('spec-url').value = '';
672
- } catch {
673
- console.error('RapiDoc: Unable to read or parse json'); // eslint-disable-line no-console
674
- }
675
- };
676
- // Read the Text file
677
- reader.readAsText(specFile);
678
- }
679
-
680
- onFileLoadClick() {
681
- this.shadowRoot.getElementById('spec-file').click();
682
- }
683
-
684
- onSearchChange(e) {
685
- // this.matchPaths = e.target.value;
686
- this.searchVal = e.target.value;
687
- this.resolvedSpec.tags.forEach((tag) => tag.paths.filter((path) => {
688
- if (this.searchVal) {
689
- if (getMatchedPaths(this.searchVal, path, tag.name)) {
690
- tag.expanded = true;
691
- }
692
- }
693
- }));
694
- this.resolvedSpec.components.forEach((component) => component.subComponents.filter((v) => {
695
- v.expanded = false;
696
- if (getMatchedComponents(this.searchVal, v)) {
697
- v.expanded = true;
698
- }
699
- }));
700
- this.requestUpdate();
701
- }
702
-
703
- onClearSearch() {
704
- const searchEl = this.shadowRoot.getElementById('nav-bar-search');
705
- searchEl.value = '';
706
- this.searchVal = '';
707
- this.resolvedSpec.components.forEach((component) => component.subComponents.filter((v) => {
708
- v.expanded = true;
709
- }));
710
- }
711
-
712
- onShowSearchModalClicked() {
713
- this.showAdvancedSearchDialog = true;
714
- }
715
-
716
- // Event Handler on Dialog-Box is opened
717
- async onOpenSearchDialog(e) {
718
- // Set focus to text input
719
- const inputEl = e.detail.querySelector('input');
720
- await sleep(0);
721
- if (inputEl) {
722
- inputEl.focus();
723
- }
724
- }
725
-
726
- // Public Method
727
- async loadSpec(specUrl) {
728
- if (!specUrl) {
729
- return;
730
- }
731
- this.searchVal = '';
732
- try {
733
- this.resolvedSpec = {
734
- specLoadError: false,
735
- isSpecLoading: true,
736
- tags: [],
737
- };
738
- this.loading = true;
739
- this.loadFailed = false;
740
- const spec = await ProcessSpec.call(
741
- this,
742
- specUrl,
743
- this.generateMissingTags === 'true',
744
- this.sortTags === 'true',
745
- this.sortSchemas === 'true',
746
- this.getAttribute('sort-endpoints-by'),
747
- this.getAttribute('api-key-name'),
748
- this.getAttribute('api-key-location'),
749
- this.getAttribute('api-key-value'),
750
- this.getAttribute('server-url'),
751
- this.matchPaths,
752
- this.matchType,
753
- this.removeEndpointsWithBadgeLabelAs,
754
- );
755
- this.loading = false;
756
- this.afterSpecParsedAndValidated(spec);
757
- } catch (err) {
758
- this.loading = false;
759
- this.loadFailed = true;
760
- this.resolvedSpec = null;
761
- console.error(`RapiDoc: Unable to resolve the API spec.. ${err.message}`); // eslint-disable-line no-console
762
- }
763
- }
764
-
765
- async afterSpecParsedAndValidated(spec) {
766
- this.resolvedSpec = spec;
767
- this.selectedServer = undefined;
768
- if (this.defaultApiServerUrl) {
769
- if (this.defaultApiServerUrl === this.serverUrl) {
770
- this.selectedServer = {
771
- url: this.serverUrl,
772
- computedUrl: this.serverUrl,
773
- };
774
- } else if (this.resolvedSpec.servers) {
775
- this.selectedServer = this.resolvedSpec.servers.find((v) => (v.url === this.defaultApiServerUrl));
776
- }
777
- }
778
- if (!this.selectedServer) {
779
- if (this.resolvedSpec.servers) {
780
- this.selectedServer = this.resolvedSpec.servers[0]; // eslint-disable-line prefer-destructuring
781
- }
782
- }
783
- this.requestUpdate();
784
- // eslint-disable-next-line no-await-in-loop
785
- while (!await this.updateComplete);
786
- const specLoadedEvent = new CustomEvent('spec-loaded', { detail: spec });
787
- this.dispatchEvent(specLoadedEvent);
788
-
789
- // Initiate IntersectionObserver and put it at the end of event loop, to allow loading all the child elements (must for larger specs)
790
- this.intersectionObserver.disconnect();
791
- if (this.renderStyle === 'read') {
792
- await sleep(100);
793
- this.observeExpandedContent(); // This will auto-highlight the selected nav-item in read-mode
794
- }
795
-
796
- this.isIntersectionObserverActive = true;
797
-
798
- // On first time Spec load, try to navigate to location hash if provided
799
- const elementId = this.getElementIDFromURL();
800
-
801
- if (elementId) {
802
- if (this.renderStyle === 'view') {
803
- this.expandAndGotoOperation(elementId, true, true);
804
- } else {
805
- this.scrollToPath(elementId);
806
- }
807
- } else if (this.renderStyle === 'focused') {
808
- // If goto-path is provided and no location-hash is present then try to scroll to default element
809
- if (!this.gotoPath) {
810
- const defaultElementId = this.showInfo ? 'overview' : this.resolvedSpec.tags[0]?.paths[0];
811
- this.scrollToPath(defaultElementId);
812
- }
813
- }
814
- }
815
-
816
- /**
817
- * Return the URL from where is served the RapiDoc component, removing any hash and route prefix
818
- */
819
- getComponentBaseURL() {
820
- const { href } = window.location;
821
-
822
- // Remove end of string # or /
823
- const cleanRouterPrefix = this.routePrefix.replace(/(#|\/)$/, '');
824
-
825
- if (!cleanRouterPrefix) {
826
- return href.split('#')[0];
827
- }
828
-
829
- const indexOfRoutePrefix = href.lastIndexOf(cleanRouterPrefix);
830
-
831
- if (indexOfRoutePrefix === -1) {
832
- return href;
833
- }
834
-
835
- return href.slice(0, indexOfRoutePrefix);
836
- }
837
-
838
- /**
839
- * From the URL return the ID of the element whether it is in the hash or if used a router prefix without a hash
840
- */
841
- getElementIDFromURL() {
842
- const baseURL = this.getComponentBaseURL();
843
- const elementId = window.location.href.replace(baseURL + this.routePrefix, '');
844
- return elementId;
845
- }
846
-
847
- replaceHistoryState(hashId) {
848
- const baseURL = this.getComponentBaseURL();
849
- window.history.replaceState(null, null, `${baseURL}${this.routePrefix || '#'}${hashId}`);
850
- }
851
-
852
- expandAndGotoOperation(elementId, scrollToElement = true) {
853
- if (!this.resolvedSpec) {
854
- return;
855
- }
856
- // Expand full operation and tag
857
- let isExpandingNeeded = true;
858
- const tmpElementId = elementId.indexOf('#') === -1 ? elementId : elementId.substring(1);
859
- if (tmpElementId.startsWith('overview') || tmpElementId === 'servers' || tmpElementId === 'auth') {
860
- isExpandingNeeded = false;
861
- } else {
862
- for (let i = 0; i < this.resolvedSpec.tags?.length; i++) {
863
- const tag = this.resolvedSpec.tags[i];
864
- const path = tag.paths?.find((p) => p.elementId === elementId);
865
- if (path) {
866
- if (path.expanded && tag.expanded) {
867
- isExpandingNeeded = false;
868
- } else {
869
- path.expanded = true;
870
- tag.expanded = true;
871
- }
872
- }
873
- }
874
- }
875
- if (scrollToElement) {
876
- // requestUpdate() and delay required, else we cant find element
877
- if (isExpandingNeeded) {
878
- this.requestUpdate();
879
- }
880
- window.setTimeout(() => {
881
- const gotoEl = this.shadowRoot.getElementById(tmpElementId);
882
- if (gotoEl) {
883
- gotoEl.scrollIntoView({ behavior: this.scrollBehavior, block: 'start' });
884
- if (this.updateRoute === 'true') {
885
- this.replaceHistoryState(tmpElementId);
886
- }
887
- }
888
- }, isExpandingNeeded ? 150 : 0);
889
- }
890
- }
891
-
892
- isValidTopId(id) {
893
- return (id.startsWith('overview') || id === 'servers' || id === 'auth');
894
- }
895
-
896
- isValidPathId(id) {
897
- if (id === 'overview' && this.showInfo) {
898
- return true;
899
- }
900
- if (id === 'servers' && this.allowServerSelection) {
901
- return true;
902
- }
903
- if (id === 'auth' && this.allowAuthentication) {
904
- return true;
905
- }
906
- if (id.startsWith('tag--')) {
907
- return this.resolvedSpec?.tags?.find((tag) => tag.elementId === id);
908
- }
909
- return this.resolvedSpec?.tags?.find((tag) => tag.paths.find((path) => path.elementId === id));
910
- }
911
-
912
- onIntersect(entries) {
913
- if (this.isIntersectionObserverActive === false) {
914
- return;
915
- }
916
-
917
- entries.forEach((entry) => {
918
- if (entry.isIntersecting && entry.intersectionRatio > 0) {
919
- 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, .operations.active');
920
- const newNavEl = this.shadowRoot.getElementById(`link-${entry.target.id}`);
921
-
922
- // Add active class in the new element
923
- if (newNavEl) {
924
- if (this.updateRoute === 'true') {
925
- this.replaceHistoryState(entry.target.id);
926
- }
927
- newNavEl.scrollIntoView({ behavior: this.scrollBehavior, block: 'center' });
928
- newNavEl.classList.add('active');
929
- newNavEl.part.add('section-navbar-active-item');
930
- }
931
-
932
- // Remove active class from previous element
933
- // if it is different from the new one (edge case on loading in read render style)
934
- if (oldNavEl && oldNavEl !== newNavEl) {
935
- oldNavEl.classList.remove('active');
936
- oldNavEl.part.remove('section-navbar-active-item');
937
- }
938
- }
939
- });
940
- }
941
-
942
- // Called by anchor tags created using markdown
943
- handleHref(e) {
944
- if (e.target.tagName.toLowerCase() === 'a') {
945
- if (e.target.getAttribute('href').startsWith('#')) {
946
- const gotoEl = this.shadowRoot.getElementById(e.target.getAttribute('href').replace('#', ''));
947
- if (gotoEl) {
948
- gotoEl.scrollIntoView({ behavior: this.scrollBehavior, block: 'start' });
949
- }
950
- }
951
- }
952
- }
953
-
954
- /**
955
- * Called by
956
- * - onClick of Navigation Bar
957
- * - onClick of Advanced Search items
958
- *
959
- * Functionality:
960
- * 1. First deactivate IntersectionObserver
961
- * 2. Scroll to the element
962
- * 3. Activate IntersectionObserver (after little delay)
963
- *
964
- */
965
- async scrollToEventTarget(event, scrollNavItemToView = true) {
966
- if (!(event.type === 'click' || (event.type === 'keyup' && event.keyCode === 13))) {
967
- return;
968
- }
969
- const navEl = event.target;
970
- if (!navEl.dataset.contentId) {
971
- return;
972
- }
973
- this.isIntersectionObserverActive = false;
974
- if (this.renderStyle === 'focused') {
975
- const requestEl = this.shadowRoot.querySelector('api-request');
976
- if (requestEl) {
977
- requestEl.beforeNavigationFocusedMode();
978
- }
979
- }
980
- this.scrollToPath(navEl.dataset.contentId, true, scrollNavItemToView);
981
- setTimeout(() => {
982
- this.isIntersectionObserverActive = true;
983
- }, 300);
984
- }
985
-
986
- // Public Method (scrolls to a given path and highlights the left-nav selection)
987
- async scrollToPath(elementId, expandPath = true, scrollNavItemToView = true) {
988
- if (this.renderStyle === 'focused') {
989
- // for focused mode update this.focusedElementId to update the rendering, else it wont find the needed html elements
990
- // focusedElementId will get validated in the template
991
- this.focusedElementId = elementId;
992
- await sleep(0);
993
- }
994
- if (this.renderStyle === 'view') {
995
- this.expandAndGotoOperation(elementId, expandPath, true);
996
- } else {
997
- let isValidElementId = false;
998
- const contentEl = this.shadowRoot.getElementById(elementId);
999
- if (contentEl) {
1000
- isValidElementId = true;
1001
- contentEl.scrollIntoView({ behavior: this.scrollBehavior, block: 'start' });
1002
- } else {
1003
- isValidElementId = false;
1004
- }
1005
- if (isValidElementId) {
1006
- // 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
1007
- if (this.renderStyle === 'focused') {
1008
- const requestEl = this.shadowRoot.querySelector('api-request');
1009
- if (requestEl) {
1010
- requestEl.afterNavigationFocusedMode();
1011
- }
1012
- const responseEl = this.shadowRoot.querySelector('api-response');
1013
- if (responseEl) {
1014
- responseEl.resetSelection();
1015
- }
1016
- }
1017
-
1018
- // Update Location Hash
1019
- if (this.updateRoute === 'true') {
1020
- this.replaceHistoryState(elementId);
1021
- }
1022
-
1023
- // Update NavBar View and Styles
1024
- const newNavEl = this.shadowRoot.getElementById(`link-${elementId}`);
1025
-
1026
- if (newNavEl) {
1027
- if (scrollNavItemToView) {
1028
- newNavEl.scrollIntoView({ behavior: this.scrollBehavior, block: 'center' });
1029
- }
1030
- await sleep(0);
1031
- 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, .operations.active');
1032
- if (oldNavEl) {
1033
- oldNavEl.classList.remove('active');
1034
- oldNavEl.part.remove('active');
1035
- oldNavEl.part.remove('section-navbar-active-item');
1036
- }
1037
- newNavEl.classList.add('active'); // must add the class after scrolling
1038
- newNavEl.part.add('section-navbar-active-item');
1039
- // this.requestUpdate();
1040
- }
1041
- }
1042
- }
1043
- }
1044
-
1045
- // Public Method - to update security-scheme of type http
1046
- setHttpUserNameAndPassword(securitySchemeId, username, password) {
1047
- return applyApiKey.call(this, securitySchemeId, username, password);
1048
- }
1049
-
1050
- // Public Method - to update security-scheme of type apiKey or OAuth
1051
- setApiKey(securitySchemeId, apiKeyValue) {
1052
- return applyApiKey.call(this, securitySchemeId, '', '', apiKeyValue);
1053
- }
1054
-
1055
- // Public Method
1056
- removeAllSecurityKeys() {
1057
- return onClearAllApiKeys.call(this);
1058
- }
1059
-
1060
- // Public Method
1061
- setApiServer(apiServerUrl) {
1062
- // return apiServerUrl;
1063
- return setApiServer.call(this, apiServerUrl);
1064
- }
1065
-
1066
- // Event handler for Advanced Search text-inputs and checkboxes
1067
- onAdvancedSearch(ev, delay) {
1068
- const eventTargetEl = ev.target;
1069
- clearTimeout(this.timeoutId);
1070
- this.timeoutId = setTimeout(() => {
1071
- let searchInputEl;
1072
- if (eventTargetEl.type === 'text') {
1073
- searchInputEl = eventTargetEl;
1074
- } else {
1075
- searchInputEl = eventTargetEl.closest('.advanced-search-options').querySelector('input[type=text]');
1076
- }
1077
- const searchOptions = [...eventTargetEl.closest('.advanced-search-options').querySelectorAll('input:checked')].map((v) => v.id);
1078
- this.advancedSearchMatches = advancedSearch(searchInputEl.value, this.resolvedSpec.tags, searchOptions);
1079
- }, delay);
1080
- }
1081
- }
1082
- customElements.define('rapi-doc', RapiDoc);