openapi-explorer 0.9.310 → 0.9.314

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 (121) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/dist/{openapi-explorer.min.js → browser/openapi-explorer.min.js} +3 -3
  3. package/dist/{openapi-explorer.min.js.map → browser/openapi-explorer.min.js.map} +0 -0
  4. package/dist/es/components/api-request.js +936 -0
  5. package/dist/es/components/api-response.js +184 -0
  6. package/dist/es/components/json-tree.js +67 -0
  7. package/{src → dist/es}/components/mime-types.js +11 -17
  8. package/dist/es/components/schema-table.js +156 -0
  9. package/dist/es/components/schema-tree.js +191 -0
  10. package/dist/es/components/tag-input.js +67 -0
  11. package/{src → dist/es}/openapi-explorer-oauth-handler.js +2 -2
  12. package/{src → dist/es}/openapi-explorer.js +364 -371
  13. package/dist/es/styles/advanced-search-styles.js +2 -0
  14. package/dist/es/styles/api-request-styles.js +2 -0
  15. package/dist/es/styles/border-styles.js +2 -0
  16. package/dist/es/styles/endpoint-styles.js +2 -0
  17. package/dist/es/styles/flex-styles.js +2 -0
  18. package/dist/es/styles/font-styles.js +2 -0
  19. package/dist/es/styles/info-styles.js +2 -0
  20. package/dist/es/styles/input-styles.js +4 -0
  21. package/dist/es/styles/nav-styles.js +2 -0
  22. package/dist/es/styles/prism-styles.js +2 -0
  23. package/dist/es/styles/schema-styles.js +2 -0
  24. package/dist/es/styles/tab-styles.js +2 -0
  25. package/dist/es/styles/table-styles.js +2 -0
  26. package/dist/es/templates/advance-search-template.js +37 -0
  27. package/dist/es/templates/callback-template.js +7 -0
  28. package/dist/es/templates/code-samples-template.js +26 -0
  29. package/dist/es/templates/components-template.js +17 -0
  30. package/dist/es/templates/endpoint-template.js +94 -0
  31. package/dist/es/templates/expanded-endpoint-template.js +32 -0
  32. package/{src → dist/es}/templates/focused-endpoint-template.js +15 -15
  33. package/dist/es/templates/navbar-template.js +46 -0
  34. package/dist/es/templates/overview-template.js +9 -0
  35. package/dist/es/templates/responsiveViewMainBodyTemplate.js +30 -0
  36. package/dist/es/templates/security-scheme-template.js +330 -0
  37. package/dist/es/templates/server-template.js +42 -0
  38. package/{src → dist/es}/utils/color-utils.js +53 -16
  39. package/{src → dist/es}/utils/common-utils.js +18 -18
  40. package/{src → dist/es}/utils/schema-utils.js +248 -124
  41. package/{src → dist/es}/utils/spec-parser.js +112 -71
  42. package/dist/es/utils/theme.js +75 -0
  43. package/{src → dist/es}/utils/xml/xml.js +41 -38
  44. package/dist/lib/components/api-request.js +957 -0
  45. package/dist/lib/components/api-response.js +206 -0
  46. package/dist/lib/components/json-tree.js +82 -0
  47. package/dist/lib/components/mime-types.js +70 -0
  48. package/dist/lib/components/schema-table.js +170 -0
  49. package/dist/lib/components/schema-tree.js +206 -0
  50. package/dist/lib/components/tag-input.js +76 -0
  51. package/dist/lib/openapi-explorer-oauth-handler.js +19 -0
  52. package/dist/lib/openapi-explorer.js +817 -0
  53. package/dist/lib/styles/advanced-search-styles.js +10 -0
  54. package/dist/lib/styles/api-request-styles.js +10 -0
  55. package/dist/lib/styles/border-styles.js +10 -0
  56. package/dist/lib/styles/endpoint-styles.js +10 -0
  57. package/dist/lib/styles/flex-styles.js +10 -0
  58. package/dist/lib/styles/font-styles.js +10 -0
  59. package/dist/lib/styles/info-styles.js +10 -0
  60. package/dist/lib/styles/input-styles.js +11 -0
  61. package/dist/lib/styles/nav-styles.js +10 -0
  62. package/dist/lib/styles/prism-styles.js +10 -0
  63. package/dist/lib/styles/schema-styles.js +10 -0
  64. package/dist/lib/styles/tab-styles.js +10 -0
  65. package/dist/lib/styles/table-styles.js +10 -0
  66. package/dist/lib/templates/advance-search-template.js +42 -0
  67. package/dist/lib/templates/callback-template.js +12 -0
  68. package/dist/lib/templates/code-samples-template.js +36 -0
  69. package/dist/lib/templates/components-template.js +27 -0
  70. package/dist/lib/templates/endpoint-template.js +111 -0
  71. package/dist/lib/templates/expanded-endpoint-template.js +48 -0
  72. package/dist/lib/templates/focused-endpoint-template.js +95 -0
  73. package/dist/lib/templates/navbar-template.js +54 -0
  74. package/dist/lib/templates/overview-template.js +16 -0
  75. package/dist/lib/templates/responsiveViewMainBodyTemplate.js +47 -0
  76. package/dist/lib/templates/security-scheme-template.js +342 -0
  77. package/dist/lib/templates/server-template.js +49 -0
  78. package/dist/lib/utils/color-utils.js +112 -0
  79. package/dist/lib/utils/common-utils.js +156 -0
  80. package/dist/lib/utils/schema-utils.js +743 -0
  81. package/dist/lib/utils/spec-parser.js +361 -0
  82. package/dist/lib/utils/theme.js +84 -0
  83. package/dist/lib/utils/xml/xml.js +239 -0
  84. package/package.json +19 -6
  85. package/dist/openapi-explorer.min.js.LICENSE.txt +0 -71
  86. package/dist/openapi-explorer.min.js.LICENSE.txt.gz +0 -0
  87. package/dist/openapi-explorer.min.js.gz +0 -0
  88. package/dist/openapi-explorer.min.js.map.gz +0 -0
  89. package/dist/report.html +0 -38
  90. package/src/components/api-request.js +0 -1244
  91. package/src/components/api-response.js +0 -340
  92. package/src/components/json-tree.js +0 -129
  93. package/src/components/schema-table.js +0 -250
  94. package/src/components/schema-tree.js +0 -280
  95. package/src/components/tag-input.js +0 -109
  96. package/src/styles/advanced-search-styles.js +0 -84
  97. package/src/styles/api-request-styles.js +0 -111
  98. package/src/styles/border-styles.js +0 -24
  99. package/src/styles/css/main.css +0 -24
  100. package/src/styles/endpoint-styles.js +0 -222
  101. package/src/styles/flex-styles.js +0 -15
  102. package/src/styles/font-styles.js +0 -266
  103. package/src/styles/info-styles.js +0 -20
  104. package/src/styles/input-styles.js +0 -236
  105. package/src/styles/nav-styles.js +0 -141
  106. package/src/styles/prism-styles.js +0 -107
  107. package/src/styles/schema-styles.js +0 -121
  108. package/src/styles/tab-styles.js +0 -44
  109. package/src/styles/table-styles.js +0 -48
  110. package/src/templates/advance-search-template.js +0 -81
  111. package/src/templates/callback-template.js +0 -63
  112. package/src/templates/code-samples-template.js +0 -35
  113. package/src/templates/components-template.js +0 -43
  114. package/src/templates/endpoint-template.js +0 -175
  115. package/src/templates/expanded-endpoint-template.js +0 -104
  116. package/src/templates/navbar-template.js +0 -175
  117. package/src/templates/overview-template.js +0 -58
  118. package/src/templates/responsiveViewMainBodyTemplate.js +0 -72
  119. package/src/templates/security-scheme-template.js +0 -487
  120. package/src/templates/server-template.js +0 -106
  121. package/src/utils/theme.js +0 -163
@@ -1,8 +1,7 @@
1
1
  import { css, LitElement, unsafeCSS } from 'lit-element';
2
2
  import { marked } from 'marked';
3
- import Prism from 'prismjs';
3
+ import Prism from 'prismjs'; // It's possible none of these imports are actually necessary and should just be removed
4
4
 
5
- // It's possible none of these imports are actually necessary and should just be removed
6
5
  import 'prismjs/components/prism-css';
7
6
  import 'prismjs/components/prism-yaml';
8
7
  import 'prismjs/components/prism-go';
@@ -11,9 +10,8 @@ import 'prismjs/components/prism-json';
11
10
  import 'prismjs/components/prism-bash';
12
11
  import 'prismjs/components/prism-python';
13
12
  import 'prismjs/components/prism-http';
14
- import 'prismjs/components/prism-csharp';
13
+ import 'prismjs/components/prism-csharp'; // Styles
15
14
 
16
- // Styles
17
15
  import FontStyles from './styles/font-styles';
18
16
  import InputStyles from './styles/input-styles';
19
17
  import FlexStyles from './styles/flex-styles';
@@ -24,13 +22,11 @@ import TabStyles from './styles/tab-styles';
24
22
  import NavStyles from './styles/nav-styles';
25
23
  import InfoStyles from './styles/info-styles';
26
24
  import advancedSearchStyles from './styles/advanced-search-styles';
27
-
28
25
  import { advancedSearch, getCurrentElement, pathIsInSearch, replaceState, sleep, componentIsInSearch } from './utils/common-utils';
29
26
  import ProcessSpec from './utils/spec-parser';
30
27
  import responsiveViewMainBodyTemplate from './templates/responsiveViewMainBodyTemplate';
31
28
  import apiRequestStyles from './styles/api-request-styles';
32
29
  import { checkForAuthToken } from './templates/security-scheme-template';
33
-
34
30
  export default class OpenApiExplorer extends LitElement {
35
31
  constructor() {
36
32
  super();
@@ -38,380 +34,317 @@ export default class OpenApiExplorer extends LitElement {
38
34
  this.loading = true;
39
35
  const intersectionObserverOptions = {
40
36
  root: this.getRootNode().host,
41
- rootMargin: '-50px 0px -50px 0px', // when the element is visible 100px from bottom
42
- threshold: 0,
37
+ rootMargin: '-50px 0px -50px 0px',
38
+ // when the element is visible 100px from bottom
39
+ threshold: 0
43
40
  };
44
41
  this.isIntersectionObserverActive = true;
45
42
 
46
43
  if (typeof IntersectionObserver !== 'undefined') {
47
- this.intersectionObserver = new IntersectionObserver((entries) => { this.onIntersect(entries); }, intersectionObserverOptions);
44
+ this.intersectionObserver = new IntersectionObserver(entries => {
45
+ this.onIntersect(entries);
46
+ }, intersectionObserverOptions);
48
47
  } else {
49
- this.intersectionObserver = { disconnect() {}, observe() {} };
48
+ this.intersectionObserver = {
49
+ disconnect() {},
50
+
51
+ observe() {}
52
+
53
+ };
50
54
  }
51
55
  }
52
56
 
53
57
  static get properties() {
54
58
  return {
55
59
  // Heading
56
- headingText: { type: String, attribute: 'heading-text' },
57
- explorerLocation: { type: String, attribute: 'explorer-location' },
58
-
60
+ headingText: {
61
+ type: String,
62
+ attribute: 'heading-text'
63
+ },
64
+ explorerLocation: {
65
+ type: String,
66
+ attribute: 'explorer-location'
67
+ },
59
68
  // Spec
60
- specUrl: { type: String, attribute: 'spec-url' },
61
-
69
+ specUrl: {
70
+ type: String,
71
+ attribute: 'spec-url'
72
+ },
62
73
  // UI Layouts
63
- layout: { type: String },
64
- defaultSchemaTab: { type: String, attribute: 'default-schema-tab' },
65
- responseAreaHeight: { type: String, attribute: 'response-area-height' },
66
- fillRequestWithDefault: { type: String, attribute: 'fill-defaults' },
67
-
74
+ layout: {
75
+ type: String
76
+ },
77
+ defaultSchemaTab: {
78
+ type: String,
79
+ attribute: 'default-schema-tab'
80
+ },
81
+ responseAreaHeight: {
82
+ type: String,
83
+ attribute: 'response-area-height'
84
+ },
85
+ fillRequestWithDefault: {
86
+ type: String,
87
+ attribute: 'fill-defaults'
88
+ },
68
89
  // Schema Styles
69
- schemaStyle: { type: String, attribute: 'schema-style' },
70
- schemaExpandLevel: { type: Number, attribute: 'schema-expand-level' },
71
- schemaDescriptionExpanded: { type: String, attribute: 'schema-description-expanded' },
72
-
90
+ schemaStyle: {
91
+ type: String,
92
+ attribute: 'schema-style'
93
+ },
94
+ schemaExpandLevel: {
95
+ type: Number,
96
+ attribute: 'schema-expand-level'
97
+ },
98
+ schemaDescriptionExpanded: {
99
+ type: String,
100
+ attribute: 'schema-description-expanded'
101
+ },
73
102
  // API Server
74
- serverUrl: { type: String, attribute: 'server-url' },
75
-
103
+ serverUrl: {
104
+ type: String,
105
+ attribute: 'server-url'
106
+ },
76
107
  // Hide/Show Sections & Enable Disable actions
77
- showInfo: { type: String, attribute: 'show-info' },
78
- allowAuthentication: { type: String, attribute: 'show-authentication' },
79
- allowTry: { type: String, attribute: 'enable-console' },
80
- allowSearch: { type: String, attribute: 'allow-search' },
81
- allowAdvancedSearch: { type: String, attribute: 'allow-advanced-search' },
82
- allowServerSelection: { type: String, attribute: 'show-server-selection' },
83
- showComponents: { type: String, attribute: 'show-components' },
84
-
108
+ showInfo: {
109
+ type: String,
110
+ attribute: 'show-info'
111
+ },
112
+ allowAuthentication: {
113
+ type: String,
114
+ attribute: 'show-authentication'
115
+ },
116
+ allowTry: {
117
+ type: String,
118
+ attribute: 'enable-console'
119
+ },
120
+ allowSearch: {
121
+ type: String,
122
+ attribute: 'allow-search'
123
+ },
124
+ allowAdvancedSearch: {
125
+ type: String,
126
+ attribute: 'allow-advanced-search'
127
+ },
128
+ allowServerSelection: {
129
+ type: String,
130
+ attribute: 'show-server-selection'
131
+ },
132
+ showComponents: {
133
+ type: String,
134
+ attribute: 'show-components'
135
+ },
85
136
  // Main Colors and Font
86
- primaryColor: { type: String, attribute: 'primary-color' },
87
- secondaryColor: { type: String, attribute: 'secondary-color' },
88
- bgColor: { type: String, attribute: 'bg-color' },
89
- textColor: { type: String, attribute: 'text-color' },
90
- headerColor: { type: String, attribute: 'header-color' },
91
- fontSize: { type: String, attribute: 'font-size' },
92
-
137
+ primaryColor: {
138
+ type: String,
139
+ attribute: 'primary-color'
140
+ },
141
+ secondaryColor: {
142
+ type: String,
143
+ attribute: 'secondary-color'
144
+ },
145
+ bgColor: {
146
+ type: String,
147
+ attribute: 'bg-color'
148
+ },
149
+ textColor: {
150
+ type: String,
151
+ attribute: 'text-color'
152
+ },
153
+ headerColor: {
154
+ type: String,
155
+ attribute: 'header-color'
156
+ },
157
+ fontSize: {
158
+ type: String,
159
+ attribute: 'font-size'
160
+ },
93
161
  // Nav Bar Colors
94
- navBgColor: { type: String, attribute: 'nav-bg-color' },
95
- navTextColor: { type: String, attribute: 'nav-text-color' },
96
- navHoverBgColor: { type: String, attribute: 'nav-hover-bg-color' },
97
- navHoverTextColor: { type: String, attribute: 'nav-hover-text-color' },
98
- navItemSpacing: { type: String, attribute: 'nav-item-spacing' },
99
- usePathInNavBar: { type: String, attribute: 'use-path-in-nav-bar' },
100
-
162
+ navBgColor: {
163
+ type: String,
164
+ attribute: 'nav-bg-color'
165
+ },
166
+ navTextColor: {
167
+ type: String,
168
+ attribute: 'nav-text-color'
169
+ },
170
+ navHoverBgColor: {
171
+ type: String,
172
+ attribute: 'nav-hover-bg-color'
173
+ },
174
+ navHoverTextColor: {
175
+ type: String,
176
+ attribute: 'nav-hover-text-color'
177
+ },
178
+ navItemSpacing: {
179
+ type: String,
180
+ attribute: 'nav-item-spacing'
181
+ },
182
+ usePathInNavBar: {
183
+ type: String,
184
+ attribute: 'use-path-in-nav-bar'
185
+ },
101
186
  // Fetch Options
102
- fetchCredentials: { type: String, attribute: 'fetch-credentials' },
103
-
187
+ fetchCredentials: {
188
+ type: String,
189
+ attribute: 'fetch-credentials'
190
+ },
104
191
  // Filters
105
- matchPaths: { type: String, attribute: 'match-paths' },
106
-
192
+ matchPaths: {
193
+ type: String,
194
+ attribute: 'match-paths'
195
+ },
107
196
  // Internal Properties
108
- loading: { type: Boolean }, // indicates spec is being loaded
109
- operationsCollapsed: { type: Boolean },
110
- showAdvancedSearchDialog: { type: Boolean },
111
- advancedSearchMatches: { type: Object }
197
+ loading: {
198
+ type: Boolean
199
+ },
200
+ // indicates spec is being loaded
201
+ operationsCollapsed: {
202
+ type: Boolean
203
+ },
204
+ showAdvancedSearchDialog: {
205
+ type: Boolean
206
+ },
207
+ advancedSearchMatches: {
208
+ type: Object
209
+ }
112
210
  };
113
211
  }
114
212
 
115
213
  static get styles() {
116
- return [
117
- FontStyles,
118
- InputStyles,
119
- FlexStyles,
120
- TableStyles,
121
- EndpointStyles,
122
- PrismStyles,
123
- TabStyles,
124
- NavStyles,
125
- InfoStyles,
126
- advancedSearchStyles,
127
- apiRequestStyles,
128
- css`
129
- *:not(:defined) { display:none }
130
-
131
- :host {
132
- display:flex;
133
- flex-direction: column;
134
- width:100%;
135
- height:100%;
136
- margin:0;
137
- padding:0;
138
- overflow: hidden;
139
- letter-spacing:normal;
140
- color:var(--fg);
141
- background-color:var(--bg);
142
- font-family: var(--font-regular);
143
- }
144
- .body {
145
- display:flex;
146
- height:100%;
147
- width:100%;
148
- overflow:hidden;
149
- }
214
+ return [FontStyles, InputStyles, FlexStyles, TableStyles, EndpointStyles, PrismStyles, TabStyles, NavStyles, InfoStyles, advancedSearchStyles, apiRequestStyles, 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}.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{padding:24px 8px 0 4px}.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{position:relative;padding:6px 0}.divider{border-top:2px solid var(--border-color);margin:24px 0;width:100%}.tooltip{border:1px solid var(--border-color);border-left-width:4px;margin-left:2px}.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:hover a:hover{color:var(--primary-color)}.tooltip:hover .tooltip-text{visibility:visible;opacity:1}@keyframes spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}@media only screen and (max-width:767.98px){.section-padding{margin:1rem}.sub-title.tag{margin-left: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:2rem 3rem}.endpoint-body{position:relative;padding:36px 0 48px 0}}@media only screen and (min-width:1024px){.nav-bar{width:${unsafeCSS(this.fontSize === 'default' ? '300px' : this.fontSize === 'large' ? '315px' : '330px')};display:flex}.section-gap--read-mode{padding:24px 24px 12px}.main-content-inner{padding:24px}}`];
215
+ } // Startup
150
216
 
151
- .main-content {
152
- margin:0;
153
- padding: 0;
154
- display:block;
155
- flex:1;
156
- height:100%;
157
- overflow-y: overlay;
158
- overflow-x: hidden;
159
- scrollbar-width: thin;
160
- scrollbar-color: var(--border-color) transparent;
161
- }
162
217
 
163
- .main-content::-webkit-scrollbar {
164
- width: 8px;
165
- height: 8px;
166
- }
167
- .main-content::-webkit-scrollbar-track {
168
- background:transparent;
169
- }
170
- .main-content::-webkit-scrollbar-thumb {
171
- background-color: var(--border-color);
172
- }
173
-
174
- .section-gap.section-tag {
175
- border-bottom:1px solid var(--border-color);
176
- }
177
- .method-section-gap {
178
- padding: 24px 8px 0px 4px;
179
- }
180
- .section-gap {
181
- padding: 24px 0px 0px;
182
- }
183
- .section-tag-header {
184
- position:relative;
185
- cursor: n-resize;
186
- padding: 12px 0;
187
- }
188
- .collapsed .section-tag-header:hover{
189
- cursor: s-resize;
190
- }
191
-
192
- .section-tag-header:hover{
193
- background-image: linear-gradient(to right, rgba(0,0,0,0), var(--border-color), rgba(0,0,0,0));
194
- }
195
-
196
- .collapsed .section-tag-header:hover::after {
197
- color:var(--primary-color);
198
- }
199
-
200
- .collapsed .section-tag-body {
201
- display:none;
202
- }
203
-
204
- .logo {
205
- height:36px;
206
- width:36px;
207
- margin-left:5px;
208
- }
209
- .only-large-screen-flex,
210
- .only-large-screen{
211
- display:none;
212
- }
213
- .header-title{
214
- font-size:calc(var(--font-size-regular) + 8px);
215
- padding:0 8px;
216
- }
217
- .tag.title {
218
- text-transform: uppercase;
219
- }
220
- .header{
221
- background-color:var(--header-bg);
222
- color:var(--header-fg);
223
- width:100%;
224
- }
225
-
226
- input.header-input{
227
- background:var(--header-color-darker);
228
- color:var(--header-fg);
229
- border:1px solid var(--header-color-border);
230
- flex:1;
231
- padding-right:24px;
232
- border-radius:3px;
233
- }
234
- input.header-input::placeholder {
235
- opacity:0.4;
236
- }
237
- input:disabled {
238
- cursor: not-allowed;
239
- }
240
- .loader {
241
- margin: 16px auto 16px auto;
242
- border: 4px solid var(--bg3);
243
- border-radius: 50%;
244
- border-top: 4px solid var(--primary-color);
245
- width: 36px;
246
- height: 36px;
247
- animation: spin 2s linear infinite;
248
- }
249
- .expanded-endpoint-body{
250
- position: relative;
251
- padding: 6px 0px;
252
- }
253
- .divider {
254
- border-top: 2px solid var(--border-color);
255
- margin: 24px 0;
256
- width:100%;
257
- }
258
-
259
- .tooltip {
260
- border: 1px solid var(--border-color);
261
- border-left-width: 4px;
262
- margin-left:2px;
263
- }
264
- .tooltip a {
265
- color: var(--fg2);
266
- text-decoration: none;
267
- }
268
- .tooltip-text {
269
- color: var(--fg2);
270
- background-color: var(--bg2);
271
- visibility: hidden;
272
- overflow-wrap: break-word;
273
- }
274
- .tooltip:hover {
275
- color: var(--primary-color);
276
- border-color: var(--primary-color);
277
- }
278
- .tooltip:hover a:hover {
279
- color: var(--primary-color);
280
- }
281
-
282
- .tooltip:hover .tooltip-text {
283
- visibility: visible;
284
- opacity: 1;
285
- }
286
-
287
- @keyframes spin {
288
- 0% { transform: rotate(0deg); }
289
- 100% { transform: rotate(360deg); }
290
- }
291
-
292
- @media only screen and (max-width: 767.98px) {
293
- .section-padding {
294
- // margin-right: 1rem;
295
- margin: 1rem;
296
- }
297
-
298
- .sub-title.tag {
299
- margin-left: 1rem;
300
- }
301
- }
302
-
303
- @media only screen and (min-width: 768px) {
304
- .nav-bar {
305
- width: 260px;
306
- display:flex;
307
- }
308
- .only-large-screen{
309
- display:block;
310
- }
311
- .only-large-screen-flex{
312
- display:flex;
313
- }
314
- .section-gap {
315
- padding: 24px 24px;
316
- }
317
- .section-gap--read-mode {
318
- padding: 24px 8px;
319
- }
320
- .section-gap--focused-mode {
321
- padding: 2rem 3rem;
322
- }
323
- .endpoint-body {
324
- position: relative;
325
- padding:36px 0 48px 0;
326
- }
327
- }
328
-
329
- @media only screen and (min-width: 1024px) {
330
- .nav-bar {
331
- width: ${unsafeCSS(this.fontSize === 'default' ? '300px' : this.fontSize === 'large' ? '315px' : '330px')};
332
- display:flex;
333
- }
334
- .section-gap--read-mode {
335
- padding: 24px 24px 12px;
336
- }
337
- .main-content-inner {
338
- padding: 24px;
339
- }
340
- }`,
341
- ];
342
- }
343
-
344
- // Startup
345
218
  connectedCallback() {
346
219
  super.connectedCallback();
347
220
  this.handleResize = this.handleResize.bind(this);
348
221
  window.addEventListener('resize', this.handleResize);
349
-
350
222
  this.loading = true;
351
223
  const parent = this.parentElement;
224
+
352
225
  if (parent) {
353
226
  if (parent.offsetWidth === 0 && parent.style.width === '') {
354
227
  parent.style.width = '100vw';
355
228
  }
229
+
356
230
  if (parent.offsetHeight === 0 && parent.style.height === '') {
357
231
  parent.style.height = '100vh';
358
232
  }
233
+
359
234
  if (parent.tagName === 'BODY') {
360
- if (!parent.style.marginTop) { parent.style.marginTop = '0'; }
361
- if (!parent.style.marginRight) { parent.style.marginRight = '0'; }
362
- if (!parent.style.marginBottom) { parent.style.marginBottom = '0'; }
363
- if (!parent.style.marginLeft) { parent.style.marginLeft = '0'; }
235
+ if (!parent.style.marginTop) {
236
+ parent.style.marginTop = '0';
237
+ }
238
+
239
+ if (!parent.style.marginRight) {
240
+ parent.style.marginRight = '0';
241
+ }
242
+
243
+ if (!parent.style.marginBottom) {
244
+ parent.style.marginBottom = '0';
245
+ }
246
+
247
+ if (!parent.style.marginLeft) {
248
+ parent.style.marginLeft = '0';
249
+ }
364
250
  }
365
251
  }
366
252
 
367
253
  this.renderStyle = 'focused';
368
254
  this.explorerLocation = this.explorerLocation || getCurrentElement();
369
255
 
370
- if (!this.schemaStyle || !'tree, table,'.includes(`${this.schemaStyle},`)) { this.schemaStyle = 'tree'; }
371
- if (!this.defaultSchemaTab || !'body, model,'.includes(`${this.defaultSchemaTab},`)) { this.defaultSchemaTab = 'model'; }
372
- if (!this.schemaExpandLevel || this.schemaExpandLevel < 1) { this.schemaExpandLevel = 99999; }
373
- if (!this.schemaDescriptionExpanded || !'true, false,'.includes(`${this.schemaDescriptionExpanded},`)) { this.schemaDescriptionExpanded = 'true'; }
256
+ if (!this.schemaStyle || !'tree, table,'.includes(`${this.schemaStyle},`)) {
257
+ this.schemaStyle = 'tree';
258
+ }
259
+
260
+ if (!this.defaultSchemaTab || !'body, model,'.includes(`${this.defaultSchemaTab},`)) {
261
+ this.defaultSchemaTab = 'model';
262
+ }
263
+
264
+ if (!this.schemaExpandLevel || this.schemaExpandLevel < 1) {
265
+ this.schemaExpandLevel = 99999;
266
+ }
267
+
268
+ if (!this.schemaDescriptionExpanded || !'true, false,'.includes(`${this.schemaDescriptionExpanded},`)) {
269
+ this.schemaDescriptionExpanded = 'true';
270
+ }
271
+
374
272
  this.schemaHideReadOnly = ['post', 'put', 'patch'].join(',');
375
273
  this.schemaHideWriteOnly = true;
376
- if (!this.fillRequestWithDefault || !'true, false,'.includes(`${this.fillRequestWithDefault},`)) { this.fillRequestWithDefault = 'true'; }
274
+
275
+ if (!this.fillRequestWithDefault || !'true, false,'.includes(`${this.fillRequestWithDefault},`)) {
276
+ this.fillRequestWithDefault = 'true';
277
+ }
278
+
377
279
  if (!this.responseAreaHeight) {
378
280
  this.responseAreaHeight = '300px';
379
281
  }
380
282
 
381
- if (!this.allowSearch || !'true, false,'.includes(`${this.allowSearch},`)) { this.allowSearch = 'true'; }
382
- if (!this.allowAdvancedSearch || !'true, false,'.includes(`${this.allowAdvancedSearch},`)) { this.allowAdvancedSearch = 'true'; }
283
+ if (!this.allowSearch || !'true, false,'.includes(`${this.allowSearch},`)) {
284
+ this.allowSearch = 'true';
285
+ }
286
+
287
+ if (!this.allowAdvancedSearch || !'true, false,'.includes(`${this.allowAdvancedSearch},`)) {
288
+ this.allowAdvancedSearch = 'true';
289
+ }
290
+
291
+ if (!this.allowTry || !'true, false,'.includes(`${this.allowTry},`)) {
292
+ this.allowTry = 'true';
293
+ }
294
+
295
+ if (!this.navItemSpacing || !'compact, relaxed, default,'.includes(`${this.navItemSpacing},`)) {
296
+ this.navItemSpacing = 'default';
297
+ }
298
+
299
+ if (!this.usePathInNavBar || !'true, false,'.includes(`${this.usePathInNavBar},`)) {
300
+ this.usePathInNavBar = 'false';
301
+ }
302
+
303
+ if (!this.fontSize || !'default, large, largest,'.includes(`${this.fontSize},`)) {
304
+ this.fontSize = 'default';
305
+ }
306
+
307
+ if (!this.showInfo || !'true, false,'.includes(`${this.showInfo},`)) {
308
+ this.showInfo = 'true';
309
+ }
383
310
 
384
- if (!this.allowTry || !'true, false,'.includes(`${this.allowTry},`)) { this.allowTry = 'true'; }
311
+ if (!this.allowServerSelection || !'true, false,'.includes(`${this.allowServerSelection},`)) {
312
+ this.allowServerSelection = 'true';
313
+ }
385
314
 
386
- if (!this.navItemSpacing || !'compact, relaxed, default,'.includes(`${this.navItemSpacing},`)) { this.navItemSpacing = 'default'; }
387
- if (!this.usePathInNavBar || !'true, false,'.includes(`${this.usePathInNavBar},`)) { this.usePathInNavBar = 'false'; }
388
- if (!this.fontSize || !'default, large, largest,'.includes(`${this.fontSize},`)) { this.fontSize = 'default'; }
315
+ if (!this.allowAuthentication || !'true, false,'.includes(`${this.allowAuthentication},`)) {
316
+ this.allowAuthentication = 'true';
317
+ }
389
318
 
390
- if (!this.showInfo || !'true, false,'.includes(`${this.showInfo},`)) { this.showInfo = 'true'; }
391
- if (!this.allowServerSelection || !'true, false,'.includes(`${this.allowServerSelection},`)) { this.allowServerSelection = 'true'; }
392
- if (!this.allowAuthentication || !'true, false,'.includes(`${this.allowAuthentication},`)) { this.allowAuthentication = 'true'; }
319
+ if (!this.showComponents || !'true false'.includes(this.showComponents)) {
320
+ this.showComponents = 'true';
321
+ }
393
322
 
394
- if (!this.showComponents || !'true false'.includes(this.showComponents)) { this.showComponents = 'true'; }
395
- if (!this.fetchCredentials || !'omit, same-origin, include,'.includes(`${this.fetchCredentials},`)) { this.fetchCredentials = ''; }
323
+ if (!this.fetchCredentials || !'omit, same-origin, include,'.includes(`${this.fetchCredentials},`)) {
324
+ this.fetchCredentials = '';
325
+ }
396
326
 
397
- if (!this.showAdvancedSearchDialog) { this.showAdvancedSearchDialog = false; }
327
+ if (!this.showAdvancedSearchDialog) {
328
+ this.showAdvancedSearchDialog = false;
329
+ }
398
330
 
399
331
  marked.setOptions({
400
332
  highlight(code, lang) {
401
333
  if (Prism.languages[lang]) {
402
334
  return Prism.highlight(code, Prism.languages[lang], lang);
403
335
  }
336
+
404
337
  return code;
405
- },
406
- });
338
+ }
407
339
 
340
+ });
408
341
  window.addEventListener('hashchange', () => {
409
342
  this.scrollTo(getCurrentElement());
410
343
  }, true);
411
344
  this.handleResize();
412
- }
345
+ } // Cleanup
346
+
413
347
 
414
- // Cleanup
415
348
  disconnectedCallback() {
416
349
  this.intersectionObserver.disconnect();
417
350
  window.removeEventListener('resize', this.handleResize);
@@ -425,7 +358,7 @@ export default class OpenApiExplorer extends LitElement {
425
358
  observeExpandedContent() {
426
359
  // Main Container
427
360
  const observeOverviewEls = this.shadowRoot.querySelectorAll('.observe-me');
428
- observeOverviewEls.forEach((targetEl) => {
361
+ observeOverviewEls.forEach(targetEl => {
429
362
  this.intersectionObserver.observe(targetEl);
430
363
  });
431
364
  }
@@ -433,6 +366,7 @@ export default class OpenApiExplorer extends LitElement {
433
366
  handleResize() {
434
367
  const mediaQueryResult = window.matchMedia('(min-width: 768px)');
435
368
  const newDisplay = mediaQueryResult.matches ? 'focused' : 'view';
369
+
436
370
  if (this.renderStyle !== newDisplay) {
437
371
  this.renderStyle = newDisplay;
438
372
  this.requestUpdate();
@@ -444,14 +378,15 @@ export default class OpenApiExplorer extends LitElement {
444
378
  if (oldVal !== newVal) {
445
379
  // put it at the end of event-loop to load all the attributes
446
380
  window.setTimeout(async () => {
447
- await this.loadSpec(newVal);
448
- // If the initial location is set, then attempt to scroll there
381
+ await this.loadSpec(newVal); // If the initial location is set, then attempt to scroll there
382
+
449
383
  if (this.explorerLocation) {
450
384
  this.scrollTo(this.explorerLocation);
451
385
  }
452
386
  }, 0);
453
387
  }
454
388
  }
389
+
455
390
  if (name === 'render-style') {
456
391
  if (newVal === 'read') {
457
392
  window.setTimeout(() => {
@@ -461,18 +396,20 @@ export default class OpenApiExplorer extends LitElement {
461
396
  this.intersectionObserver.disconnect();
462
397
  }
463
398
  }
399
+
464
400
  if (name === 'explorer-location') {
465
401
  window.setTimeout(() => {
466
402
  this.scrollTo(newVal);
467
403
  }, 0);
468
404
  }
405
+
469
406
  super.attributeChangedCallback(name, oldVal, newVal);
470
407
  }
471
408
 
472
409
  onSearchChange(e) {
473
410
  this.operationsCollapsed = false;
474
411
  this.matchPaths = e.target.value;
475
- this.resolvedSpec.tags.forEach((tag) => tag.paths.filter((v) => {
412
+ this.resolvedSpec.tags.forEach(tag => tag.paths.filter(v => {
476
413
  if (this.matchPaths) {
477
414
  // v.expanded = false;
478
415
  if (pathIsInSearch(this.matchPaths, v)) {
@@ -480,9 +417,10 @@ export default class OpenApiExplorer extends LitElement {
480
417
  }
481
418
  }
482
419
  }));
483
- this.resolvedSpec.components.forEach((component) => {
484
- component.subComponents.forEach((subComponent) => {
420
+ this.resolvedSpec.components.forEach(component => {
421
+ component.subComponents.forEach(subComponent => {
485
422
  subComponent.expanded = false;
423
+
486
424
  if (!this.matchPaths || componentIsInSearch(this.matchPaths, subComponent)) {
487
425
  subComponent.expanded = true;
488
426
  }
@@ -495,43 +433,50 @@ export default class OpenApiExplorer extends LitElement {
495
433
  const searchEl = this.shadowRoot.getElementById('nav-bar-search');
496
434
  searchEl.value = '';
497
435
  this.matchPaths = '';
498
- this.resolvedSpec.components.forEach((component) => {
499
- component.subComponents.forEach((v) => {
436
+ this.resolvedSpec.components.forEach(component => {
437
+ component.subComponents.forEach(v => {
500
438
  v.expanded = true;
501
439
  });
502
440
  });
503
441
  }
504
442
 
505
443
  async onShowSearchModalClicked() {
506
- this.showAdvancedSearchDialog = true;
507
- // wait for the dialog to render
444
+ this.showAdvancedSearchDialog = true; // wait for the dialog to render
445
+
508
446
  await sleep(10);
509
447
  const inputEl = this.shadowRoot.getElementById('advanced-search-dialog-input');
448
+
510
449
  if (inputEl) {
511
450
  inputEl.focus();
512
451
  }
513
- }
452
+ } // Public Method
453
+
514
454
 
515
- // Public Method
516
455
  async loadSpec(specUrlOrObject) {
517
456
  if (!specUrlOrObject) {
518
457
  return;
519
458
  }
459
+
520
460
  this.matchPaths = '';
461
+
521
462
  try {
522
463
  this.resolvedSpec = null;
523
464
  this.loading = true;
524
465
  this.loadFailed = false;
525
466
  const spec = await ProcessSpec(specUrlOrObject, this.serverUrl);
526
467
  this.loading = false;
468
+
527
469
  if (spec === undefined || spec === null) {
528
470
  console.error('Unable to resolve the API spec. '); // eslint-disable-line no-console
471
+
529
472
  return;
530
473
  }
474
+
531
475
  if (!this.serverUrl) {
532
476
  this.serverUrl = spec.servers[0].computedUrl || spec.servers[0].url;
533
477
  }
534
- this.selectedServer = spec.servers.find((s) => s.url === this.serverUrl || !this.serverUrl) || spec.servers[0];
478
+
479
+ this.selectedServer = spec.servers.find(s => s.url === this.serverUrl || !this.serverUrl) || spec.servers[0];
535
480
  this.afterSpecParsedAndValidated(spec);
536
481
  } catch (err) {
537
482
  this.loading = false;
@@ -539,16 +484,23 @@ export default class OpenApiExplorer extends LitElement {
539
484
  this.resolvedSpec = null;
540
485
  console.error('OpenAPI Explorer: Unable to resolve the API spec..', err); // eslint-disable-line no-console
541
486
  }
542
- }
487
+ } // Public Method
488
+
489
+
490
+ async setAuthenticationConfiguration(apiKeyId, {
491
+ token,
492
+ clientId,
493
+ clientSecret,
494
+ redirectUri
495
+ }) {
496
+ const securityObj = this.resolvedSpec && this.resolvedSpec.securitySchemes.find(v => v.apiKeyId === apiKeyId);
543
497
 
544
- // Public Method
545
- async setAuthenticationConfiguration(apiKeyId, { token, clientId, clientSecret, redirectUri }) {
546
- const securityObj = this.resolvedSpec && this.resolvedSpec.securitySchemes.find((v) => (v.apiKeyId === apiKeyId));
547
498
  if (!securityObj) {
548
499
  throw Error('SecuritySchemeNotFound');
549
500
  }
550
501
 
551
502
  let authorizationToken = token && token.replace(/^(Bearer|Basic)\s+/i, '').trim();
503
+
552
504
  if (authorizationToken && securityObj.type && securityObj.type === 'http' && securityObj.scheme && securityObj.scheme.toLowerCase() === 'basic') {
553
505
  authorizationToken = `Basic ${btoa(authorizationToken)}`;
554
506
  } else if (authorizationToken && securityObj.scheme && securityObj.scheme.toLowerCase() === 'bearer') {
@@ -560,7 +512,6 @@ export default class OpenApiExplorer extends LitElement {
560
512
  securityObj.clientId = clientId && clientId.trim();
561
513
  securityObj.clientSecret = clientSecret && clientSecret.trim();
562
514
  securityObj.redirectUri = new URL(redirectUri && redirectUri.trim() || '', window.location.href).toString();
563
-
564
515
  securityObj.finalKeyValue = authorizationToken;
565
516
  await checkForAuthToken.call(this);
566
517
  this.requestUpdate();
@@ -568,11 +519,12 @@ export default class OpenApiExplorer extends LitElement {
568
519
 
569
520
  afterSpecParsedAndValidated(spec) {
570
521
  this.resolvedSpec = spec;
522
+ this.dispatchEvent(new CustomEvent('spec-loaded', {
523
+ bubbles: true,
524
+ detail: spec
525
+ }));
526
+ this.requestUpdate(); // Initiate IntersectionObserver and put it at the end of event loop, to allow loading all the child elements (must for larger specs)
571
527
 
572
- this.dispatchEvent(new CustomEvent('spec-loaded', { bubbles: true, detail: spec }));
573
- this.requestUpdate();
574
-
575
- // Initiate IntersectionObserver and put it at the end of event loop, to allow loading all the child elements (must for larger specs)
576
528
  this.intersectionObserver.disconnect();
577
529
 
578
530
  if (this.renderStyle === 'focused') {
@@ -588,83 +540,99 @@ export default class OpenApiExplorer extends LitElement {
588
540
  expandAndGotoOperation(elementId) {
589
541
  // Expand full operation and tag
590
542
  let isExpandingNeeded = false;
591
-
592
543
  const tag = this.resolvedSpec.tags.find(t => t.paths && t.paths.find(p => p.elementId === elementId));
593
- const path = tag && tag.paths && tag.paths.find((p) => p.elementId === elementId);
544
+ const path = tag && tag.paths && tag.paths.find(p => p.elementId === elementId);
545
+
594
546
  if (path && (!path.expanded || !tag.expanded)) {
595
547
  isExpandingNeeded = true;
596
548
  path.expanded = true;
597
549
  tag.expanded = true;
598
550
  this.requestUpdate();
599
- }
551
+ } // requestUpdate() and delay required, else we cant find element because it won't exist immediately
552
+
600
553
 
601
- // requestUpdate() and delay required, else we cant find element because it won't exist immediately
602
554
  const tmpElementId = elementId.indexOf('#') === -1 ? elementId : elementId.substring(1);
603
555
  window.setTimeout(() => {
604
556
  const gotoEl = this.shadowRoot.getElementById(tmpElementId);
557
+
605
558
  if (gotoEl) {
606
- gotoEl.scrollIntoView({ behavior: 'auto', block: 'start' });
559
+ gotoEl.scrollIntoView({
560
+ behavior: 'auto',
561
+ block: 'start'
562
+ });
607
563
  replaceState(tmpElementId);
608
564
  }
609
565
  }, isExpandingNeeded ? 150 : 0);
610
566
  }
611
567
 
612
568
  isValidTopId(id) {
613
- return (id.startsWith('overview') || id === 'servers' || id === 'auth');
569
+ return id.startsWith('overview') || id === 'servers' || id === 'auth';
614
570
  }
615
571
 
616
572
  isValidPathId(id) {
617
573
  if (id === 'overview' && this.showInfo) {
618
574
  return true;
619
575
  }
576
+
620
577
  if (id === 'servers' && this.allowServerSelection) {
621
578
  return true;
622
579
  }
580
+
623
581
  if (id === 'auth' && this.allowAuthentication) {
624
582
  return true;
625
583
  }
584
+
626
585
  if (id.startsWith('tag--')) {
627
- return this.resolvedSpec.tags && this.resolvedSpec.tags.find((tag) => tag.elementId === id);
586
+ return this.resolvedSpec.tags && this.resolvedSpec.tags.find(tag => tag.elementId === id);
628
587
  }
629
- return this.resolvedSpec.tags && this.resolvedSpec.tags.find((tag) => tag.paths.find((path) => path.elementId === id));
588
+
589
+ return this.resolvedSpec.tags && this.resolvedSpec.tags.find(tag => tag.paths.find(path => path.elementId === id));
630
590
  }
631
591
 
632
592
  onIntersect(entries) {
633
593
  if (this.isIntersectionObserverActive === false) {
634
594
  return;
635
595
  }
636
- entries.forEach((entry) => {
596
+
597
+ entries.forEach(entry => {
637
598
  if (entry.isIntersecting && entry.intersectionRatio > 0) {
638
599
  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');
639
- const newNavEl = this.shadowRoot.getElementById(`link-${entry.target.id}`);
600
+ const newNavEl = this.shadowRoot.getElementById(`link-${entry.target.id}`); // Add active class in the new element
640
601
 
641
- // Add active class in the new element
642
602
  if (newNavEl) {
643
603
  replaceState(entry.target.id);
644
- newNavEl.scrollIntoView({ behavior: 'auto', block: 'center' });
604
+ newNavEl.scrollIntoView({
605
+ behavior: 'auto',
606
+ block: 'center'
607
+ });
645
608
  newNavEl.classList.add('active');
646
- }
647
- // Remove active class from previous element
609
+ } // Remove active class from previous element
610
+
611
+
648
612
  if (oldNavEl) {
649
613
  oldNavEl.classList.remove('active');
650
614
  }
651
615
  }
652
616
  });
653
- }
617
+ } // Called by anchor tags created using markdown
618
+
654
619
 
655
- // Called by anchor tags created using markdown
656
620
  handleHref(e) {
657
621
  if (e.target.tagName.toLowerCase() === 'a') {
658
622
  const anchor = e.target.getAttribute('href');
623
+
659
624
  if (anchor && anchor.startsWith('#')) {
660
625
  const gotoEl = this.shadowRoot.getElementById(anchor.replace('#', ''));
626
+
661
627
  if (gotoEl) {
662
- gotoEl.scrollIntoView({ behavior: 'auto', block: 'start' });
628
+ gotoEl.scrollIntoView({
629
+ behavior: 'auto',
630
+ block: 'start'
631
+ });
663
632
  }
664
633
  }
665
634
  }
666
635
  }
667
-
668
636
  /**
669
637
  * Called by
670
638
  * - onClick of Navigation Bar
@@ -676,26 +644,31 @@ export default class OpenApiExplorer extends LitElement {
676
644
  * 3. Activate IntersectionObserver (after little delay)
677
645
  *
678
646
  */
647
+
648
+
679
649
  scrollToEventTarget(event, scrollNavItemToView = true) {
680
650
  const navEl = event.currentTarget;
651
+
681
652
  if (!navEl.dataset.contentId) {
682
653
  return;
683
654
  }
684
655
 
685
656
  let repeatedElementIndex;
657
+
686
658
  if (navEl.dataset.contentId === 'section') {
687
659
  const navSectionSlot = this.shadowRoot.querySelector('slot.custom-nav-section');
688
660
  const assignedNodes = navSectionSlot && navSectionSlot.assignedNodes();
689
- repeatedElementIndex = assignedNodes && [].findIndex.call(assignedNodes, (slot) => slot === event.target);
661
+ repeatedElementIndex = assignedNodes && [].findIndex.call(assignedNodes, slot => slot === event.target);
690
662
  }
663
+
691
664
  this.isIntersectionObserverActive = false;
692
665
  this.scrollTo(navEl.dataset.contentId, scrollNavItemToView, repeatedElementIndex);
693
666
  setTimeout(() => {
694
667
  this.isIntersectionObserverActive = true;
695
668
  }, 300);
696
- }
669
+ } // Public Method (scrolls to a given path and highlights the left-nav selection)
670
+
697
671
 
698
- // Public Method (scrolls to a given path and highlights the left-nav selection)
699
672
  async scrollTo(elementId, scrollNavItemToView = true, repeatedElementIndex) {
700
673
  if (!this.resolvedSpec) {
701
674
  return;
@@ -704,39 +677,48 @@ export default class OpenApiExplorer extends LitElement {
704
677
  if (this.renderStyle === 'view') {
705
678
  this.expandAndGotoOperation(elementId);
706
679
  return;
707
- }
680
+ } // explorerLocation will get validated in the focused-endpoint-template
681
+
708
682
 
709
- // explorerLocation will get validated in the focused-endpoint-template
710
683
  this.explorerLocation = elementId;
711
684
  await sleep(0);
712
-
713
685
  const contentEl = this.shadowRoot.getElementById(elementId);
686
+
714
687
  if (!contentEl) {
715
688
  return;
716
- }
689
+ } // For focused APIs, always scroll to the top of the component
690
+
717
691
 
718
- // For focused APIs, always scroll to the top of the component
719
692
  if (!elementId.match('cmp--')) {
720
- this.shadowRoot.getElementById('operations-root').scrollIntoView({ behavior: 'auto', block: 'start' });
693
+ this.shadowRoot.getElementById('operations-root').scrollIntoView({
694
+ behavior: 'auto',
695
+ block: 'start'
696
+ });
721
697
  } else {
722
- contentEl.scrollIntoView({ behavior: 'auto', block: 'start' });
723
- }
698
+ contentEl.scrollIntoView({
699
+ behavior: 'auto',
700
+ block: 'start'
701
+ });
702
+ } // 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
703
+
724
704
 
725
- // 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
726
705
  const requestEl = this.shadowRoot.querySelector('api-request');
706
+
727
707
  if (requestEl) {
728
708
  requestEl.resetRequestBodySelection();
729
709
  }
710
+
730
711
  const responseEl = this.shadowRoot.querySelector('api-response');
712
+
731
713
  if (responseEl) {
732
714
  responseEl.resetSelection();
733
- }
715
+ } // Update Location Hash
716
+
734
717
 
735
- // Update Location Hash
736
- replaceState(elementId);
718
+ replaceState(elementId); // Update NavBar View and Styles
737
719
 
738
- // Update NavBar View and Styles
739
720
  let newNavEl = this.shadowRoot.getElementById(`link-${elementId}`);
721
+
740
722
  if (elementId === 'section') {
741
723
  const navSectionSlot = this.shadowRoot.querySelector('slot.custom-nav-section');
742
724
  const assignedNodes = navSectionSlot && navSectionSlot.assignedNodes();
@@ -748,40 +730,51 @@ export default class OpenApiExplorer extends LitElement {
748
730
  }
749
731
 
750
732
  if (scrollNavItemToView) {
751
- newNavEl.scrollIntoView({ behavior: 'auto', block: 'center' });
733
+ newNavEl.scrollIntoView({
734
+ behavior: 'auto',
735
+ block: 'center'
736
+ });
752
737
  }
738
+
753
739
  await sleep(0);
754
740
  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');
741
+
755
742
  if (oldNavEl) {
756
743
  oldNavEl.classList.remove('active');
757
744
  }
745
+
758
746
  const navSectionSlot = this.shadowRoot.querySelector('slot.custom-nav-section');
759
747
  const assignedNodes = navSectionSlot && navSectionSlot.assignedNodes();
760
- (assignedNodes || []).filter((n, nodeIndex) => nodeIndex !== repeatedElementIndex).forEach((node) => {
748
+ (assignedNodes || []).filter((n, nodeIndex) => nodeIndex !== repeatedElementIndex).forEach(node => {
761
749
  node.classList.remove('active');
762
750
  });
763
751
  newNavEl.classList.add('active'); // must add the class after scrolling
752
+
764
753
  this.requestUpdate();
765
- }
754
+ } // Event handler for Advanced Search text-inputs and checkboxes
755
+
766
756
 
767
- // Event handler for Advanced Search text-inputs and checkboxes
768
757
  onAdvancedSearch(ev, delay) {
769
758
  const eventTargetEl = ev.target;
770
759
  clearTimeout(this.timeoutId);
771
760
  this.timeoutId = setTimeout(() => {
772
761
  let searchInputEl;
762
+
773
763
  if (eventTargetEl.type === 'text') {
774
764
  searchInputEl = eventTargetEl;
775
765
  } else {
776
766
  searchInputEl = eventTargetEl.closest('.advanced-search-options').querySelector('input[type=text]');
777
767
  }
778
- const searchOptions = [...eventTargetEl.closest('.advanced-search-options').querySelectorAll('input:checked')].map((v) => v.id);
768
+
769
+ const searchOptions = [...eventTargetEl.closest('.advanced-search-options').querySelectorAll('input:checked')].map(v => v.id);
779
770
  this.advancedSearchMatches = advancedSearch(searchInputEl.value, this.resolvedSpec.tags, searchOptions);
780
771
  }, delay);
781
772
  }
773
+
782
774
  }
783
775
 
784
776
  if (!customElements.get('openapi-explorer')) {
785
777
  customElements.define('openapi-explorer', OpenApiExplorer);
786
778
  }
787
- import './openapi-explorer-oauth-handler';
779
+
780
+ import './openapi-explorer-oauth-handler';