openapi-explorer 0.8.290 → 0.8.293
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 -0
- package/dist/openapi-explorer.min.js +5 -5
- package/dist/openapi-explorer.min.js.LICENSE.txt +1 -1
- package/dist/openapi-explorer.min.js.LICENSE.txt.gz +0 -0
- package/dist/openapi-explorer.min.js.gz +0 -0
- package/dist/openapi-explorer.min.js.map +1 -1
- package/dist/openapi-explorer.min.js.map.gz +0 -0
- package/dist/report.html +2 -2
- package/package.json +1 -1
- package/src/components/api-request.js +4 -4
- package/src/components/api-response.js +3 -3
- package/src/openapi-explorer.js +4 -5
- package/src/templates/security-scheme-template.js +2 -2
- package/src/templates/server-template.js +1 -1
- package/src/utils/spec-parser.js +7 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openapi-explorer",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.293",
|
|
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": {
|
|
@@ -245,7 +245,7 @@ export default class ApiRequest extends LitElement {
|
|
|
245
245
|
return html`
|
|
246
246
|
<div class="table-title top-gap">${title}${paramType === 'path' ? html`<span style='color:var(--red);'>*</span>` : ''}</div>
|
|
247
247
|
<div style="display:block; overflow-x:auto; max-width:100%;">
|
|
248
|
-
<table class="m-table" style="width:100%; word-break:break-word;">
|
|
248
|
+
<table role="presentation" class="m-table" style="width:100%; word-break:break-word;">
|
|
249
249
|
${tableRows}
|
|
250
250
|
</table>
|
|
251
251
|
</div>`;
|
|
@@ -313,7 +313,7 @@ export default class ApiRequest extends LitElement {
|
|
|
313
313
|
reqBodyTypeSelectorHtml = requestBodyTypes.length === 1
|
|
314
314
|
? ''
|
|
315
315
|
: html`
|
|
316
|
-
<select style="min-width:100px; max-width:100%; margin-bottom:-1px;" @change = '${(e) => this.onMimeTypeChange(e)}'>
|
|
316
|
+
<select aria-label="mime type" style="min-width:100px; max-width:100%; margin-bottom:-1px;" @change = '${(e) => this.onMimeTypeChange(e)}'>
|
|
317
317
|
${requestBodyTypes.map((reqBody) => html`
|
|
318
318
|
<option value = '${reqBody.mimeType}' ?selected = '${reqBody.mimeType === this.selectedRequestBodyType}'>
|
|
319
319
|
${reqBody.mimeType}
|
|
@@ -348,7 +348,7 @@ export default class ApiRequest extends LitElement {
|
|
|
348
348
|
${reqBodyExamples.length === 1
|
|
349
349
|
? ''
|
|
350
350
|
: html`
|
|
351
|
-
<select style="min-width:100px; max-width:100%; margin-bottom:-1px;" @change='${(e) => this.onSelectExample(e)}'>
|
|
351
|
+
<select aria-label='request body example' style="min-width:100px; max-width:100%; margin-bottom:-1px;" @change='${(e) => this.onSelectExample(e)}'>
|
|
352
352
|
${reqBodyExamples.map((v) => html`<option value="${v.exampleId}" ?selected=${v.exampleId === this.selectedRequestBodyExample} >
|
|
353
353
|
${v.exampleSummary.length > 80 ? v.exampleId : v.exampleSummary ? v.exampleSummary : v.exampleId}
|
|
354
354
|
</option>`)}
|
|
@@ -683,7 +683,7 @@ export default class ApiRequest extends LitElement {
|
|
|
683
683
|
}`);
|
|
684
684
|
}
|
|
685
685
|
return html`
|
|
686
|
-
<table style="width:100%;" class="m-table">
|
|
686
|
+
<table role="presentation" style="width:100%;" class="m-table">
|
|
687
687
|
${formDataTableRows}
|
|
688
688
|
</table>
|
|
689
689
|
`;
|
|
@@ -216,7 +216,7 @@ export default class ApiResponse extends LitElement {
|
|
|
216
216
|
responseHeaderListTemplate(respHeaders) {
|
|
217
217
|
return html`
|
|
218
218
|
<div style="padding:16px 0 8px 0" class="resp-headers small-font-size bold-text">RESPONSE HEADERS</div>
|
|
219
|
-
<table style="border-collapse: collapse; margin-bottom:16px; border:1px solid var(--border-color); border-radius: var(--border-radius)" class="small-font-size mono-font">
|
|
219
|
+
<table role="presentation" style="border-collapse: collapse; margin-bottom:16px; border:1px solid var(--border-color); border-radius: var(--border-radius)" class="small-font-size mono-font">
|
|
220
220
|
${respHeaders.map((v) => html`
|
|
221
221
|
<tr>
|
|
222
222
|
<td style="padding:8px; vertical-align: baseline; min-width:120px; border-top: 1px solid var(--light-border-color); text-overflow: ellipsis;">
|
|
@@ -238,7 +238,7 @@ export default class ApiResponse extends LitElement {
|
|
|
238
238
|
|
|
239
239
|
mimeTypeDropdownTemplate(mimeTypes) {
|
|
240
240
|
return html`
|
|
241
|
-
<select @change="${(e) => { this.selectedMimeType = e.target.value; }}" style='margin-bottom: -1px; z-index:1'>
|
|
241
|
+
<select aria-label='mime type' @change="${(e) => { this.selectedMimeType = e.target.value; }}" style='margin-bottom: -1px; z-index:1'>
|
|
242
242
|
${mimeTypes.map((mimeType) => html`<option value='${mimeType}' ?selected = '${mimeType === this.selectedMimeType}'> ${mimeType} </option>`)}
|
|
243
243
|
</select>`;
|
|
244
244
|
}
|
|
@@ -276,7 +276,7 @@ export default class ApiResponse extends LitElement {
|
|
|
276
276
|
}`
|
|
277
277
|
: html`
|
|
278
278
|
<span class = 'example-panel generic-tree ${this.renderStyle === 'read' ? 'border pad-8-16' : 'border-top pad-top-8'}'>
|
|
279
|
-
<select @change='${(e) => this.onSelectExample(e)}'>
|
|
279
|
+
<select aria-label='response body example' @change='${(e) => this.onSelectExample(e)}'>
|
|
280
280
|
${mimeRespDetails.examples.map((v) => html`<option value="${v.exampleId}" ?selected=${v.exampleId === mimeRespDetails.selectedExample} >
|
|
281
281
|
${v.exampleSummary.length > 80 ? v.exampleId : v.exampleSummary}
|
|
282
282
|
</option>`)}
|
package/src/openapi-explorer.js
CHANGED
|
@@ -510,16 +510,15 @@ export default class OpenApiExplorer extends LitElement {
|
|
|
510
510
|
this.resolvedSpec = null;
|
|
511
511
|
this.loading = true;
|
|
512
512
|
this.loadFailed = false;
|
|
513
|
-
const
|
|
514
|
-
if (!this.serverUrl && isServerUrl) {
|
|
515
|
-
this.serverUrl = new URL(specUrlOrObject).origin;
|
|
516
|
-
}
|
|
517
|
-
const spec = await ProcessSpec(isServerUrl, specUrlOrObject, this.serverUrl);
|
|
513
|
+
const spec = await ProcessSpec(specUrlOrObject, this.serverUrl);
|
|
518
514
|
this.loading = false;
|
|
519
515
|
if (spec === undefined || spec === null) {
|
|
520
516
|
console.error('Unable to resolve the API spec. '); // eslint-disable-line no-console
|
|
521
517
|
return;
|
|
522
518
|
}
|
|
519
|
+
if (!this.serverUrl) {
|
|
520
|
+
this.serverUrl = spec.servers[0].url;
|
|
521
|
+
}
|
|
523
522
|
this.afterSpecParsedAndValidated(spec);
|
|
524
523
|
} catch (err) {
|
|
525
524
|
this.loading = false;
|
|
@@ -270,7 +270,7 @@ function oAuthFlowTemplate(flowName, securityObj, authFlow) {
|
|
|
270
270
|
${flowName === 'clientCredentials'
|
|
271
271
|
? html`
|
|
272
272
|
<input type="password" part="textbox textbox-auth-client-secret" value = "" placeholder="Client Secret" spellcheck="false" class="oauth-client-secret" style = "margin:0 5px;">
|
|
273
|
-
<select style="margin-right:5px;" class="oauth-send-client-secret-in">
|
|
273
|
+
<select aria-label='oauth client secret location' style="margin-right:5px;" class="oauth-send-client-secret-in">
|
|
274
274
|
<option value = 'header' selected> Authorization Header </option>
|
|
275
275
|
<option value = 'request-body'> Request Body </option>
|
|
276
276
|
</select>`
|
|
@@ -314,7 +314,7 @@ export default function securitySchemeTemplate() {
|
|
|
314
314
|
</div>
|
|
315
315
|
${schemes.length > 0
|
|
316
316
|
? html`
|
|
317
|
-
<table class='m-table' style
|
|
317
|
+
<table role="presentation" class='m-table' style="width:100%">
|
|
318
318
|
${schemes.map((v) => html`
|
|
319
319
|
<tr>
|
|
320
320
|
<td style="max-width:500px; overflow-wrap: break-word;">
|
|
@@ -26,7 +26,7 @@ function serverVarsTemplate() {
|
|
|
26
26
|
return this.selectedServer && this.selectedServer.variables
|
|
27
27
|
? html`
|
|
28
28
|
<div class="table-title"> SERVER VARIABLES</div>
|
|
29
|
-
<table class='m-table'>
|
|
29
|
+
<table role="presentation" class='m-table'>
|
|
30
30
|
${Object.entries(this.selectedServer.variables).map((kv) => html`
|
|
31
31
|
<tr>
|
|
32
32
|
<td style="vertical-align: middle;" >${kv[0]}</td>
|
package/src/utils/spec-parser.js
CHANGED
|
@@ -3,7 +3,8 @@ import { marked } from 'marked';
|
|
|
3
3
|
import yaml from 'js-yaml';
|
|
4
4
|
import { invalidCharsRegEx } from './common-utils';
|
|
5
5
|
|
|
6
|
-
export default async function ProcessSpec(
|
|
6
|
+
export default async function ProcessSpec(specUrlOrObject, serverUrl = '') {
|
|
7
|
+
const inputSpecIsAUrl = typeof specUrlOrObject === 'string' && specUrlOrObject.match(/^http/);
|
|
7
8
|
let specMeta;
|
|
8
9
|
|
|
9
10
|
// Dynamically resolve non yaml or json files and insert their descriptions where necessary
|
|
@@ -14,7 +15,7 @@ export default async function ProcessSpec(requiresLookup, specUrlOrObject, serve
|
|
|
14
15
|
return val;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
if (
|
|
18
|
+
if (inputSpecIsAUrl) {
|
|
18
19
|
specMeta = await SwaggerClient({ allowMetaPatches: false, url: specUrlOrObject, responseInterceptor });
|
|
19
20
|
} else if (typeof specUrlOrObject === 'string') {
|
|
20
21
|
specMeta = await SwaggerClient({ allowMetaPatches: false, spec: yaml.load(specUrlOrObject), responseInterceptor });
|
|
@@ -71,7 +72,7 @@ export default async function ProcessSpec(requiresLookup, specUrlOrObject, serve
|
|
|
71
72
|
|
|
72
73
|
// Servers
|
|
73
74
|
let servers = [];
|
|
74
|
-
if (
|
|
75
|
+
if (Array.isArray(jsonParsedSpec.servers) && jsonParsedSpec.servers.length) {
|
|
75
76
|
jsonParsedSpec.servers.forEach((v) => {
|
|
76
77
|
let computedUrl = v.url.trim();
|
|
77
78
|
if (!(computedUrl.startsWith('http') || computedUrl.startsWith('//') || computedUrl.startsWith('{'))) {
|
|
@@ -90,11 +91,13 @@ export default async function ProcessSpec(requiresLookup, specUrlOrObject, serve
|
|
|
90
91
|
}
|
|
91
92
|
v.computedUrl = computedUrl;
|
|
92
93
|
});
|
|
93
|
-
if (serverUrl) {
|
|
94
|
+
if (serverUrl && !jsonParsedSpec.servers.some(s => s.url === serverUrl || s.computedUrl === serverUrl)) {
|
|
94
95
|
jsonParsedSpec.servers.push({ url: serverUrl, computedUrl: serverUrl });
|
|
95
96
|
}
|
|
96
97
|
} else if (serverUrl) {
|
|
97
98
|
jsonParsedSpec.servers = [{ url: serverUrl, computedUrl: serverUrl }];
|
|
99
|
+
} else if (inputSpecIsAUrl) {
|
|
100
|
+
jsonParsedSpec.servers = [{ url: new URL(specUrlOrObject).origin, computedUrl: new URL(specUrlOrObject).origin }];
|
|
98
101
|
} else if (window.location.origin.startsWith('http')) {
|
|
99
102
|
jsonParsedSpec.servers = [{ url: window.location.origin, computedUrl: window.location.origin }];
|
|
100
103
|
} else {
|