openapi-explorer 0.9.327 → 0.9.333
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -1
- package/dist/browser/openapi-explorer.min.js +3 -3
- package/dist/es/openapi-explorer.js +12 -10
- package/dist/es/templates/focused-endpoint-template.js +1 -1
- package/dist/es/templates/navbar-template.js +1 -1
- package/dist/es/utils/spec-parser.js +6 -9
- package/dist/lib/openapi-explorer.js +12 -10
- package/dist/lib/templates/focused-endpoint-template.js +1 -1
- package/dist/lib/templates/navbar-template.js +1 -1
- package/dist/lib/utils/spec-parser.js +6 -9
- package/package.json +1 -1
|
@@ -74,6 +74,10 @@ export default class OpenApiExplorer extends LitElement {
|
|
|
74
74
|
layout: {
|
|
75
75
|
type: String
|
|
76
76
|
},
|
|
77
|
+
operationsCollapsed: {
|
|
78
|
+
type: Boolean,
|
|
79
|
+
attribute: 'collapse'
|
|
80
|
+
},
|
|
77
81
|
defaultSchemaTab: {
|
|
78
82
|
type: String,
|
|
79
83
|
attribute: 'default-schema-tab'
|
|
@@ -129,9 +133,9 @@ export default class OpenApiExplorer extends LitElement {
|
|
|
129
133
|
type: String,
|
|
130
134
|
attribute: 'show-server-selection'
|
|
131
135
|
},
|
|
132
|
-
|
|
133
|
-
type:
|
|
134
|
-
attribute: '
|
|
136
|
+
hideComponents: {
|
|
137
|
+
type: Boolean,
|
|
138
|
+
attribute: 'hide-components'
|
|
135
139
|
},
|
|
136
140
|
// Main Colors and Font
|
|
137
141
|
primaryColor: {
|
|
@@ -198,9 +202,6 @@ export default class OpenApiExplorer extends LitElement {
|
|
|
198
202
|
type: Boolean
|
|
199
203
|
},
|
|
200
204
|
// indicates spec is being loaded
|
|
201
|
-
operationsCollapsed: {
|
|
202
|
-
type: Boolean
|
|
203
|
-
},
|
|
204
205
|
showAdvancedSearchDialog: {
|
|
205
206
|
type: Boolean
|
|
206
207
|
},
|
|
@@ -316,10 +317,6 @@ export default class OpenApiExplorer extends LitElement {
|
|
|
316
317
|
this.allowAuthentication = 'true';
|
|
317
318
|
}
|
|
318
319
|
|
|
319
|
-
if (!this.showComponents || !'true false'.includes(this.showComponents)) {
|
|
320
|
-
this.showComponents = 'true';
|
|
321
|
-
}
|
|
322
|
-
|
|
323
320
|
if (!this.fetchCredentials || !'omit, same-origin, include,'.includes(`${this.fetchCredentials},`)) {
|
|
324
321
|
this.fetchCredentials = '';
|
|
325
322
|
}
|
|
@@ -519,6 +516,11 @@ export default class OpenApiExplorer extends LitElement {
|
|
|
519
516
|
|
|
520
517
|
afterSpecParsedAndValidated(spec) {
|
|
521
518
|
this.resolvedSpec = spec;
|
|
519
|
+
|
|
520
|
+
if (this.operationsCollapsed) {
|
|
521
|
+
this.resolvedSpec.tags.forEach(t => t.expanded = false);
|
|
522
|
+
}
|
|
523
|
+
|
|
522
524
|
this.dispatchEvent(new CustomEvent('spec-loaded', {
|
|
523
525
|
bubbles: true,
|
|
524
526
|
detail: spec
|
|
@@ -47,7 +47,7 @@ export default function focusedEndpointTemplate() {
|
|
|
47
47
|
focusedTemplate = serverTemplate.call(this);
|
|
48
48
|
} else if (focusElId === 'section') {
|
|
49
49
|
focusedTemplate = html` <section id="section" class="observe-me"> <slot name="custom-section"></slot> </section>`;
|
|
50
|
-
} else if (focusElId.startsWith('cmp--') && this.
|
|
50
|
+
} else if (focusElId.startsWith('cmp--') && !this.hideComponents) {
|
|
51
51
|
focusedTemplate = componentsTemplate.call(this);
|
|
52
52
|
} else if (focusElId.startsWith('tag--')) {
|
|
53
53
|
const idToFocus = focusElId.indexOf('--', 4) > 0 ? focusElId.substring(0, focusElId.indexOf('--', 5)) : focusElId;
|
|
@@ -41,6 +41,6 @@ export default function navbarTemplate() {
|
|
|
41
41
|
return true;
|
|
42
42
|
}).map(p => html` <div class="nav-bar-path ${this.usePathInNavBar === 'true' ? 'small-font' : ''}" data-content-id="${p.elementId}" id="link-${p.elementId}" @click="${e => {
|
|
43
43
|
this.scrollToEventTarget(e, false);
|
|
44
|
-
}}"> <span style="line-break:anywhere;${p.deprecated ? 'filter:opacity(0.5)' : ''}"> ${this.usePathInNavBar === 'true' ? html`<span class="mono-font">${p.method.toUpperCase()} ${p.path}</span>` : p.summary || p.shortSummary} ${p.isWebhook ? '(Webhook)' : ''} </span> </div>`)} </div> </div> </slot> `)} ${this.resolvedSpec.components && this.
|
|
44
|
+
}}"> <span style="line-break:anywhere;${p.deprecated ? 'filter:opacity(0.5)' : ''}"> ${this.usePathInNavBar === 'true' ? html`<span class="mono-font">${p.method.toUpperCase()} ${p.path}</span>` : p.summary || p.shortSummary} ${p.isWebhook ? '(Webhook)' : ''} </span> </div>`)} </div> </div> </slot> `)} ${this.resolvedSpec.components && !this.hideComponents ? html` <div class="sticky-scroll-element"> <div id="link-components" class="nav-bar-section"> <div class="nav-bar-section-title">COMPONENTS</div> </div> </div> ${this.resolvedSpec.components.map(component => component.subComponents.filter(s => s.expanded).length ? html` <div class="nav-bar-tag" data-content-id="cmp--${component.name.toLowerCase()}" id="link-cmp--${component.name.toLowerCase()}" @click="${e => this.scrollToEventTarget(e, false)}"> ${component.name} </div> ${component.subComponents.filter(s => s.expanded).map(p => html` <div class="nav-bar-path" data-content-id="cmp--${p.id}" id="link-cmp--${p.id}" @click="${e => this.scrollToEventTarget(e, false)}"> <span> ${p.name} </span> </div>`)}` : '')}` : ''} </nav>`} </nav> `;
|
|
45
45
|
}
|
|
46
46
|
/* eslint-enable indent */
|
|
@@ -88,10 +88,10 @@ export default async function ProcessSpec(specUrlOrObject, serverUrl = '') {
|
|
|
88
88
|
});
|
|
89
89
|
|
|
90
90
|
if (serverUrl && !jsonParsedSpec.servers.some(s => s.url === serverUrl || s.computedUrl === serverUrl)) {
|
|
91
|
-
jsonParsedSpec.servers
|
|
91
|
+
jsonParsedSpec.servers = [{
|
|
92
92
|
url: serverUrl,
|
|
93
93
|
computedUrl: serverUrl
|
|
94
|
-
});
|
|
94
|
+
}].concat(jsonParsedSpec.servers);
|
|
95
95
|
}
|
|
96
96
|
} else if (serverUrl) {
|
|
97
97
|
jsonParsedSpec.servers = [{
|
|
@@ -203,7 +203,7 @@ function getComponents(openApiSpec) {
|
|
|
203
203
|
|
|
204
204
|
if (cmpName) {
|
|
205
205
|
components.push({
|
|
206
|
-
|
|
206
|
+
expanded: true,
|
|
207
207
|
name: cmpName,
|
|
208
208
|
description: cmpDescription,
|
|
209
209
|
subComponents
|
|
@@ -218,13 +218,12 @@ function groupByTags(openApiSpec) {
|
|
|
218
218
|
const supportedMethods = ['get', 'put', 'post', 'delete', 'patch', 'head', 'options']; // this is also used for ordering endpoints by methods
|
|
219
219
|
|
|
220
220
|
const tags = openApiSpec.tags && Array.isArray(openApiSpec.tags) ? openApiSpec.tags.map(t => ({
|
|
221
|
-
show: true,
|
|
222
221
|
elementId: `tag--${t.name.replace(invalidCharsRegEx, '-')}`,
|
|
223
222
|
name: t.name,
|
|
224
223
|
description: t.description || '',
|
|
225
224
|
headers: t.description ? getHeadersFromMarkdown(t.description) : [],
|
|
226
225
|
paths: [],
|
|
227
|
-
expanded:
|
|
226
|
+
expanded: true
|
|
228
227
|
})) : [];
|
|
229
228
|
const pathsAndWebhooks = openApiSpec.paths || {};
|
|
230
229
|
|
|
@@ -267,13 +266,12 @@ function groupByTags(openApiSpec) {
|
|
|
267
266
|
|
|
268
267
|
if (!tagObj) {
|
|
269
268
|
tagObj = {
|
|
270
|
-
show: true,
|
|
271
269
|
elementId: `tag--${tag.replace(invalidCharsRegEx, '-')}`,
|
|
272
270
|
name: tag,
|
|
273
271
|
description: specTagsItem && specTagsItem.description || '',
|
|
274
272
|
headers: specTagsItem && specTagsItem.description ? getHeadersFromMarkdown(specTagsItem.description) : [],
|
|
275
273
|
paths: [],
|
|
276
|
-
expanded:
|
|
274
|
+
expanded: true
|
|
277
275
|
};
|
|
278
276
|
tags.push(tagObj);
|
|
279
277
|
} // Generate a short summary which is broken
|
|
@@ -319,7 +317,6 @@ function groupByTags(openApiSpec) {
|
|
|
319
317
|
|
|
320
318
|
|
|
321
319
|
tagObj.paths.push({
|
|
322
|
-
show: true,
|
|
323
320
|
expanded: false,
|
|
324
321
|
isWebhook,
|
|
325
322
|
expandedAtLeastOnce: false,
|
|
@@ -336,7 +333,7 @@ function groupByTags(openApiSpec) {
|
|
|
336
333
|
responses: pathOrHookObj.responses,
|
|
337
334
|
callbacks: pathOrHookObj.callbacks,
|
|
338
335
|
deprecated: pathOrHookObj.deprecated,
|
|
339
|
-
security: pathOrHookObj.security,
|
|
336
|
+
security: pathOrHookObj.security || openApiSpec.security,
|
|
340
337
|
// commonSummary: commonPathProp.summary,
|
|
341
338
|
// commonDescription: commonPathProp.description,
|
|
342
339
|
xCodeSamples: pathOrHookObj['x-codeSamples'] || pathOrHookObj['x-code-samples'] || ''
|
|
@@ -110,6 +110,10 @@ class OpenApiExplorer extends _litElement.LitElement {
|
|
|
110
110
|
layout: {
|
|
111
111
|
type: String
|
|
112
112
|
},
|
|
113
|
+
operationsCollapsed: {
|
|
114
|
+
type: Boolean,
|
|
115
|
+
attribute: 'collapse'
|
|
116
|
+
},
|
|
113
117
|
defaultSchemaTab: {
|
|
114
118
|
type: String,
|
|
115
119
|
attribute: 'default-schema-tab'
|
|
@@ -165,9 +169,9 @@ class OpenApiExplorer extends _litElement.LitElement {
|
|
|
165
169
|
type: String,
|
|
166
170
|
attribute: 'show-server-selection'
|
|
167
171
|
},
|
|
168
|
-
|
|
169
|
-
type:
|
|
170
|
-
attribute: '
|
|
172
|
+
hideComponents: {
|
|
173
|
+
type: Boolean,
|
|
174
|
+
attribute: 'hide-components'
|
|
171
175
|
},
|
|
172
176
|
// Main Colors and Font
|
|
173
177
|
primaryColor: {
|
|
@@ -234,9 +238,6 @@ class OpenApiExplorer extends _litElement.LitElement {
|
|
|
234
238
|
type: Boolean
|
|
235
239
|
},
|
|
236
240
|
// indicates spec is being loaded
|
|
237
|
-
operationsCollapsed: {
|
|
238
|
-
type: Boolean
|
|
239
|
-
},
|
|
240
241
|
showAdvancedSearchDialog: {
|
|
241
242
|
type: Boolean
|
|
242
243
|
},
|
|
@@ -352,10 +353,6 @@ class OpenApiExplorer extends _litElement.LitElement {
|
|
|
352
353
|
this.allowAuthentication = 'true';
|
|
353
354
|
}
|
|
354
355
|
|
|
355
|
-
if (!this.showComponents || !'true false'.includes(this.showComponents)) {
|
|
356
|
-
this.showComponents = 'true';
|
|
357
|
-
}
|
|
358
|
-
|
|
359
356
|
if (!this.fetchCredentials || !'omit, same-origin, include,'.includes(`${this.fetchCredentials},`)) {
|
|
360
357
|
this.fetchCredentials = '';
|
|
361
358
|
}
|
|
@@ -556,6 +553,11 @@ class OpenApiExplorer extends _litElement.LitElement {
|
|
|
556
553
|
|
|
557
554
|
afterSpecParsedAndValidated(spec) {
|
|
558
555
|
this.resolvedSpec = spec;
|
|
556
|
+
|
|
557
|
+
if (this.operationsCollapsed) {
|
|
558
|
+
this.resolvedSpec.tags.forEach(t => t.expanded = false);
|
|
559
|
+
}
|
|
560
|
+
|
|
559
561
|
this.dispatchEvent(new CustomEvent('spec-loaded', {
|
|
560
562
|
bubbles: true,
|
|
561
563
|
detail: spec
|
|
@@ -61,7 +61,7 @@ function focusedEndpointTemplate() {
|
|
|
61
61
|
focusedTemplate = _serverTemplate.default.call(this);
|
|
62
62
|
} else if (focusElId === 'section') {
|
|
63
63
|
focusedTemplate = (0, _litElement.html)` <section id="section" class="observe-me"> <slot name="custom-section"></slot> </section>`;
|
|
64
|
-
} else if (focusElId.startsWith('cmp--') && this.
|
|
64
|
+
} else if (focusElId.startsWith('cmp--') && !this.hideComponents) {
|
|
65
65
|
focusedTemplate = _componentsTemplate.default.call(this);
|
|
66
66
|
} else if (focusElId.startsWith('tag--')) {
|
|
67
67
|
const idToFocus = focusElId.indexOf('--', 4) > 0 ? focusElId.substring(0, focusElId.indexOf('--', 5)) : focusElId;
|
|
@@ -49,6 +49,6 @@ function navbarTemplate() {
|
|
|
49
49
|
return true;
|
|
50
50
|
}).map(p => (0, _litElement.html)` <div class="nav-bar-path ${this.usePathInNavBar === 'true' ? 'small-font' : ''}" data-content-id="${p.elementId}" id="link-${p.elementId}" @click="${e => {
|
|
51
51
|
this.scrollToEventTarget(e, false);
|
|
52
|
-
}}"> <span style="line-break:anywhere;${p.deprecated ? 'filter:opacity(0.5)' : ''}"> ${this.usePathInNavBar === 'true' ? (0, _litElement.html)`<span class="mono-font">${p.method.toUpperCase()} ${p.path}</span>` : p.summary || p.shortSummary} ${p.isWebhook ? '(Webhook)' : ''} </span> </div>`)} </div> </div> </slot> `)} ${this.resolvedSpec.components && this.
|
|
52
|
+
}}"> <span style="line-break:anywhere;${p.deprecated ? 'filter:opacity(0.5)' : ''}"> ${this.usePathInNavBar === 'true' ? (0, _litElement.html)`<span class="mono-font">${p.method.toUpperCase()} ${p.path}</span>` : p.summary || p.shortSummary} ${p.isWebhook ? '(Webhook)' : ''} </span> </div>`)} </div> </div> </slot> `)} ${this.resolvedSpec.components && !this.hideComponents ? (0, _litElement.html)` <div class="sticky-scroll-element"> <div id="link-components" class="nav-bar-section"> <div class="nav-bar-section-title">COMPONENTS</div> </div> </div> ${this.resolvedSpec.components.map(component => component.subComponents.filter(s => s.expanded).length ? (0, _litElement.html)` <div class="nav-bar-tag" data-content-id="cmp--${component.name.toLowerCase()}" id="link-cmp--${component.name.toLowerCase()}" @click="${e => this.scrollToEventTarget(e, false)}"> ${component.name} </div> ${component.subComponents.filter(s => s.expanded).map(p => (0, _litElement.html)` <div class="nav-bar-path" data-content-id="cmp--${p.id}" id="link-cmp--${p.id}" @click="${e => this.scrollToEventTarget(e, false)}"> <span> ${p.name} </span> </div>`)}` : '')}` : ''} </nav>`} </nav> `;
|
|
53
53
|
}
|
|
54
54
|
/* eslint-enable indent */
|
|
@@ -98,10 +98,10 @@ async function ProcessSpec(specUrlOrObject, serverUrl = '') {
|
|
|
98
98
|
});
|
|
99
99
|
|
|
100
100
|
if (serverUrl && !jsonParsedSpec.servers.some(s => s.url === serverUrl || s.computedUrl === serverUrl)) {
|
|
101
|
-
jsonParsedSpec.servers
|
|
101
|
+
jsonParsedSpec.servers = [{
|
|
102
102
|
url: serverUrl,
|
|
103
103
|
computedUrl: serverUrl
|
|
104
|
-
});
|
|
104
|
+
}].concat(jsonParsedSpec.servers);
|
|
105
105
|
}
|
|
106
106
|
} else if (serverUrl) {
|
|
107
107
|
jsonParsedSpec.servers = [{
|
|
@@ -214,7 +214,7 @@ function getComponents(openApiSpec) {
|
|
|
214
214
|
|
|
215
215
|
if (cmpName) {
|
|
216
216
|
components.push({
|
|
217
|
-
|
|
217
|
+
expanded: true,
|
|
218
218
|
name: cmpName,
|
|
219
219
|
description: cmpDescription,
|
|
220
220
|
subComponents
|
|
@@ -229,13 +229,12 @@ function groupByTags(openApiSpec) {
|
|
|
229
229
|
const supportedMethods = ['get', 'put', 'post', 'delete', 'patch', 'head', 'options']; // this is also used for ordering endpoints by methods
|
|
230
230
|
|
|
231
231
|
const tags = openApiSpec.tags && Array.isArray(openApiSpec.tags) ? openApiSpec.tags.map(t => ({
|
|
232
|
-
show: true,
|
|
233
232
|
elementId: `tag--${t.name.replace(_commonUtils.invalidCharsRegEx, '-')}`,
|
|
234
233
|
name: t.name,
|
|
235
234
|
description: t.description || '',
|
|
236
235
|
headers: t.description ? getHeadersFromMarkdown(t.description) : [],
|
|
237
236
|
paths: [],
|
|
238
|
-
expanded:
|
|
237
|
+
expanded: true
|
|
239
238
|
})) : [];
|
|
240
239
|
const pathsAndWebhooks = openApiSpec.paths || {};
|
|
241
240
|
|
|
@@ -278,13 +277,12 @@ function groupByTags(openApiSpec) {
|
|
|
278
277
|
|
|
279
278
|
if (!tagObj) {
|
|
280
279
|
tagObj = {
|
|
281
|
-
show: true,
|
|
282
280
|
elementId: `tag--${tag.replace(_commonUtils.invalidCharsRegEx, '-')}`,
|
|
283
281
|
name: tag,
|
|
284
282
|
description: specTagsItem && specTagsItem.description || '',
|
|
285
283
|
headers: specTagsItem && specTagsItem.description ? getHeadersFromMarkdown(specTagsItem.description) : [],
|
|
286
284
|
paths: [],
|
|
287
|
-
expanded:
|
|
285
|
+
expanded: true
|
|
288
286
|
};
|
|
289
287
|
tags.push(tagObj);
|
|
290
288
|
} // Generate a short summary which is broken
|
|
@@ -330,7 +328,6 @@ function groupByTags(openApiSpec) {
|
|
|
330
328
|
|
|
331
329
|
|
|
332
330
|
tagObj.paths.push({
|
|
333
|
-
show: true,
|
|
334
331
|
expanded: false,
|
|
335
332
|
isWebhook,
|
|
336
333
|
expandedAtLeastOnce: false,
|
|
@@ -347,7 +344,7 @@ function groupByTags(openApiSpec) {
|
|
|
347
344
|
responses: pathOrHookObj.responses,
|
|
348
345
|
callbacks: pathOrHookObj.callbacks,
|
|
349
346
|
deprecated: pathOrHookObj.deprecated,
|
|
350
|
-
security: pathOrHookObj.security,
|
|
347
|
+
security: pathOrHookObj.security || openApiSpec.security,
|
|
351
348
|
// commonSummary: commonPathProp.summary,
|
|
352
349
|
// commonDescription: commonPathProp.description,
|
|
353
350
|
xCodeSamples: pathOrHookObj['x-codeSamples'] || pathOrHookObj['x-code-samples'] || ''
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openapi-explorer",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.333",
|
|
4
4
|
"description": "OpenAPI Explorer - API viewer with dynamically generated components, documentation, and interaction console",
|
|
5
5
|
"author": "Rhosys Developers <developers@rhosys.ch>",
|
|
6
6
|
"repository": {
|