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