openapi-explorer 0.7.243 → 0.7.248
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/dist/openapi-explorer.min.js +4 -4
- 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/report.html +2 -2
- package/package.json +1 -1
- package/src/components/tag-input.js +17 -24
- package/src/openapi-explorer.js +1 -3
- package/src/templates/navbar-template.js +1 -1
- package/src/templates/security-scheme-template.js +2 -3
- package/src/utils/spec-parser.js +4 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openapi-explorer",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.248",
|
|
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": {
|
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit-element';
|
|
2
2
|
|
|
3
3
|
export default class TagInput extends LitElement {
|
|
4
|
-
/* eslint-disable indent */
|
|
5
4
|
render() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
.filter((v) => v.trim() !== '')
|
|
10
|
-
.map((v) => html`<span class='tag'>${v}</span>`)
|
|
11
|
-
}`;
|
|
12
|
-
}
|
|
5
|
+
const tagItemTemplate = html`${
|
|
6
|
+
(this.value || []).filter(v => v.trim()).map((v) => html`<span class='tag'>${v}</span>`)
|
|
7
|
+
}`;
|
|
13
8
|
return html`
|
|
14
9
|
<div class='tags' tabindex="0">
|
|
15
|
-
${
|
|
10
|
+
${tagItemTemplate}
|
|
16
11
|
<input type="text" class='editor' @paste="${(e) => this.afterPaste(e)}" @keydown="${this.afterKeyDown}" placeholder="${this.placeholder || ''}">
|
|
17
12
|
</div>
|
|
18
13
|
`;
|
|
19
14
|
}
|
|
20
|
-
/* eslint-enable indent */
|
|
21
15
|
|
|
22
16
|
static get properties() {
|
|
23
17
|
return {
|
|
@@ -26,10 +20,17 @@ export default class TagInput extends LitElement {
|
|
|
26
20
|
};
|
|
27
21
|
}
|
|
28
22
|
|
|
23
|
+
connectedCallback() {
|
|
24
|
+
super.connectedCallback();
|
|
25
|
+
if (!Array.isArray(this.value)) {
|
|
26
|
+
this.value = this.value !== '' ? [this.value] : [];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
29
30
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
30
31
|
if (name === 'value') {
|
|
31
32
|
if (newVal && oldVal !== newVal) {
|
|
32
|
-
this.value = newVal.split(',').filter(
|
|
33
|
+
this.value = newVal.split(',').filter(v => v.trim());
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
super.attributeChangedCallback(name, oldVal, newVal);
|
|
@@ -38,7 +39,8 @@ export default class TagInput extends LitElement {
|
|
|
38
39
|
afterPaste(e) {
|
|
39
40
|
const clipboardData = e.clipboardData || window.clipboardData;
|
|
40
41
|
const pastedData = clipboardData.getData('Text');
|
|
41
|
-
|
|
42
|
+
const pastedArray = pastedData && pastedData.split(',').filter(v => v.trim()) || [];
|
|
43
|
+
this.value = this.value.concat(pastedArray);
|
|
42
44
|
e.preventDefault();
|
|
43
45
|
}
|
|
44
46
|
|
|
@@ -46,20 +48,11 @@ export default class TagInput extends LitElement {
|
|
|
46
48
|
if (e.keyCode === 13) {
|
|
47
49
|
e.stopPropagation();
|
|
48
50
|
e.preventDefault();
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
this.value = [...this.value, e.target.value];
|
|
52
|
-
} else {
|
|
53
|
-
this.value = [e.target.value];
|
|
54
|
-
}
|
|
55
|
-
e.target.value = '';
|
|
56
|
-
}
|
|
51
|
+
this.value = this.value.concat(e.target.value || []);
|
|
52
|
+
e.target.value = '';
|
|
57
53
|
} else if (e.keyCode === 8) {
|
|
58
54
|
if (e.target.value.length === 0) {
|
|
59
|
-
|
|
60
|
-
this.value.splice(-1);
|
|
61
|
-
this.value = [...this.value];
|
|
62
|
-
}
|
|
55
|
+
this.value = this.value.slice(0, -1);
|
|
63
56
|
}
|
|
64
57
|
}
|
|
65
58
|
}
|
package/src/openapi-explorer.js
CHANGED
|
@@ -57,7 +57,6 @@ export default class OpenApiExplorer extends LitElement {
|
|
|
57
57
|
|
|
58
58
|
// Spec
|
|
59
59
|
specUrl: { type: String, attribute: 'spec-url' },
|
|
60
|
-
generateMissingTags: { type: String, attribute: 'generate-missing-tags' },
|
|
61
60
|
specFile: { type: String, attribute: false },
|
|
62
61
|
|
|
63
62
|
// UI Layouts
|
|
@@ -399,7 +398,6 @@ export default class OpenApiExplorer extends LitElement {
|
|
|
399
398
|
|
|
400
399
|
if (!this.allowTry || !'true, false,'.includes(`${this.allowTry},`)) { this.allowTry = 'true'; }
|
|
401
400
|
|
|
402
|
-
if (!this.generateMissingTags || !'true, false,'.includes(`${this.generateMissingTags},`)) { this.generateMissingTags = 'false'; }
|
|
403
401
|
if (!this.navItemSpacing || !'compact, relaxed, default,'.includes(`${this.navItemSpacing},`)) { this.navItemSpacing = 'default'; }
|
|
404
402
|
if (!this.usePathInNavBar || !'true, false,'.includes(`${this.usePathInNavBar},`)) { this.usePathInNavBar = 'false'; }
|
|
405
403
|
if (!this.fontSize || !'default, large, largest,'.includes(`${this.fontSize},`)) { this.fontSize = 'default'; }
|
|
@@ -533,7 +531,7 @@ export default class OpenApiExplorer extends LitElement {
|
|
|
533
531
|
if (!this.serverUrl && isServerUrl) {
|
|
534
532
|
this.serverUrl = new URL(specUrlOrObject).origin;
|
|
535
533
|
}
|
|
536
|
-
const spec = await ProcessSpec(isServerUrl, specUrlOrObject, this.
|
|
534
|
+
const spec = await ProcessSpec(isServerUrl, specUrlOrObject, this.serverUrl);
|
|
537
535
|
this.loading = false;
|
|
538
536
|
if (spec === undefined || spec === null) {
|
|
539
537
|
console.error('Unable to resolve the API spec. '); // eslint-disable-line no-console
|
|
@@ -118,7 +118,7 @@ export default function navbarTemplate() {
|
|
|
118
118
|
<div id='link-paths' class='nav-bar-section' part="navbar-operations-header">
|
|
119
119
|
<div class='nav-bar-section-title'>OPERATIONS</div>
|
|
120
120
|
<div style="display:flex; margin-left:10px;">
|
|
121
|
-
${this.renderStyle === 'focused'
|
|
121
|
+
${this.renderStyle === 'focused' && this.resolvedSpec.tags.length > 1
|
|
122
122
|
? html`
|
|
123
123
|
${this.operationsCollapsed
|
|
124
124
|
? html`<div @click="${(e) => { onExpandCollapseAll.call(this, e, 'expand-all'); this.operationsCollapsed = false; }}" style="font-size: 16px; transform: rotate(0deg); cursor: pointer;">▸</div>`
|
|
@@ -170,7 +170,6 @@ async function onInvokeOAuthFlow(apiKeyId, flowType, authUrl, tokenUrl, e) {
|
|
|
170
170
|
|
|
171
171
|
const checkedScopeEls = [...authFlowDivEl.querySelectorAll('input[type="checkbox"]:checked')];
|
|
172
172
|
const securityObj = this.resolvedSpec.securitySchemes.find(v => v.apiKeyId === apiKeyId);
|
|
173
|
-
const redirectUrlObj = new URL(securityObj.redirectUri || window.location.href);
|
|
174
173
|
let grantType = '';
|
|
175
174
|
let responseType = '';
|
|
176
175
|
|
|
@@ -200,7 +199,7 @@ async function onInvokeOAuthFlow(apiKeyId, flowType, authUrl, tokenUrl, e) {
|
|
|
200
199
|
authCodeParams.set('scope', selectedScopes);
|
|
201
200
|
}
|
|
202
201
|
authCodeParams.set('client_id', clientId);
|
|
203
|
-
authCodeParams.set('redirect_uri',
|
|
202
|
+
authCodeParams.set('redirect_uri', securityObj.redirectUri || window.location.href);
|
|
204
203
|
authCodeParams.set('response_type', responseType);
|
|
205
204
|
authCodeParams.set('state', base64url.encode(JSON.stringify({ apiKeyId, flowId: flowType, url: window.location.href })));
|
|
206
205
|
|
|
@@ -209,7 +208,7 @@ async function onInvokeOAuthFlow(apiKeyId, flowType, authUrl, tokenUrl, e) {
|
|
|
209
208
|
} else if (flowType === 'clientCredentials') {
|
|
210
209
|
grantType = 'client_credentials';
|
|
211
210
|
const selectedScopes = checkedScopeEls.map((v) => v.value).join(' ');
|
|
212
|
-
fetchAccessToken.call(this, tokenUrl, clientId, clientSecret,
|
|
211
|
+
fetchAccessToken.call(this, tokenUrl, clientId, clientSecret, '', grantType, '', sendClientSecretIn, apiKeyId, authFlowDivEl, selectedScopes);
|
|
213
212
|
}
|
|
214
213
|
}
|
|
215
214
|
|
package/src/utils/spec-parser.js
CHANGED
|
@@ -3,7 +3,7 @@ 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(requiresLookup, specUrlOrObject,
|
|
6
|
+
export default async function ProcessSpec(requiresLookup, specUrlOrObject, serverUrl = '') {
|
|
7
7
|
let specMeta;
|
|
8
8
|
if (requiresLookup) {
|
|
9
9
|
specMeta = await SwaggerClient(specUrlOrObject);
|
|
@@ -19,7 +19,7 @@ export default async function ProcessSpec(requiresLookup, specUrlOrObject, gener
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
// Tags with Paths and WebHooks
|
|
22
|
-
const tags = groupByTags(jsonParsedSpec
|
|
22
|
+
const tags = groupByTags(jsonParsedSpec);
|
|
23
23
|
|
|
24
24
|
// Components
|
|
25
25
|
const components = getComponents(jsonParsedSpec);
|
|
@@ -188,7 +188,7 @@ function getComponents(openApiSpec) {
|
|
|
188
188
|
return components || [];
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
-
function groupByTags(openApiSpec
|
|
191
|
+
function groupByTags(openApiSpec) {
|
|
192
192
|
const supportedMethods = ['get', 'put', 'post', 'delete', 'patch', 'head', 'options']; // this is also used for ordering endpoints by methods
|
|
193
193
|
const tags = openApiSpec.tags && Array.isArray(openApiSpec.tags)
|
|
194
194
|
? openApiSpec.tags.map((t) => ({
|
|
@@ -223,18 +223,7 @@ function groupByTags(openApiSpec, generateMissingTags = false) {
|
|
|
223
223
|
// If path.methods are tagged, else generate it from path
|
|
224
224
|
const pathTags = pathOrHookObj.tags || [];
|
|
225
225
|
if (pathTags.length === 0) {
|
|
226
|
-
|
|
227
|
-
const pathOrHookNameKey = pathOrHookName.replace(/^\/+|\/+$/g, '');
|
|
228
|
-
const firstWordEndIndex = pathOrHookNameKey.indexOf('/');
|
|
229
|
-
if (firstWordEndIndex === -1) {
|
|
230
|
-
pathTags.push(pathOrHookNameKey);
|
|
231
|
-
} else {
|
|
232
|
-
// firstWordEndIndex -= 1;
|
|
233
|
-
pathTags.push(pathOrHookNameKey.substr(0, firstWordEndIndex));
|
|
234
|
-
}
|
|
235
|
-
} else {
|
|
236
|
-
pathTags.push('General ⦂');
|
|
237
|
-
}
|
|
226
|
+
pathTags.push('General ⦂');
|
|
238
227
|
}
|
|
239
228
|
|
|
240
229
|
pathTags.forEach((tag) => {
|