openapi-explorer 2.1.654 → 2.1.658
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/browser/openapi-explorer.min.js +2 -2
- package/dist/es/components/api-request.js +58 -140
- package/dist/es/components/api-response.js +9 -34
- package/dist/es/components/json-tree.js +4 -18
- package/dist/es/components/request-form-table.js +13 -36
- package/dist/es/components/schema-table.js +28 -42
- package/dist/es/components/schema-tree.js +31 -61
- package/dist/es/components/syntax-highlighter.js +7 -26
- package/dist/es/components/tag-input.js +2 -14
- package/dist/es/openapi-explorer-oauth-handler.js +0 -2
- package/dist/es/openapi-explorer.js +62 -174
- package/dist/es/react.js +4 -4
- package/dist/es/styles/input-styles.js +1 -1
- package/dist/es/styles/schema-styles.js +1 -1
- package/dist/es/templates/advance-search-template.js +1 -5
- package/dist/es/templates/callback-template.js +2 -2
- package/dist/es/templates/code-samples-template.js +1 -3
- package/dist/es/templates/components-template.js +41 -4
- package/dist/es/templates/endpoint-template.js +6 -17
- package/dist/es/templates/expanded-endpoint-template.js +4 -7
- package/dist/es/templates/focused-endpoint-template.js +0 -10
- package/dist/es/templates/mainBodyTemplate.js +3 -2
- package/dist/es/templates/navbar-template.js +9 -12
- package/dist/es/templates/overview-template.js +2 -2
- package/dist/es/templates/security-scheme-template.js +12 -73
- package/dist/es/templates/server-template.js +1 -8
- package/dist/es/utils/color-utils.js +2 -21
- package/dist/es/utils/common-utils.js +3 -20
- package/dist/es/utils/schema-utils.js +35 -132
- package/dist/es/utils/spec-parser.js +35 -120
- package/dist/es/utils/theme.js +3 -6
- package/dist/es/utils/xml/xml.js +1 -40
- package/dist/lib/components/api-request.js +58 -157
- package/dist/lib/components/api-response.js +9 -54
- package/dist/lib/components/json-tree.js +4 -27
- package/dist/lib/components/request-form-table.js +14 -42
- package/dist/lib/components/schema-table.js +28 -52
- package/dist/lib/components/schema-tree.js +31 -72
- package/dist/lib/components/syntax-highlighter.js +6 -49
- package/dist/lib/components/tag-input.js +2 -18
- package/dist/lib/languages/en.js +2 -3
- package/dist/lib/languages/fr.js +2 -3
- package/dist/lib/languages/index.js +0 -6
- package/dist/lib/openapi-explorer-oauth-handler.js +0 -6
- package/dist/lib/openapi-explorer.js +61 -197
- package/dist/lib/react.js +4 -5
- package/dist/lib/styles/advanced-search-styles.js +1 -5
- package/dist/lib/styles/api-request-styles.js +1 -5
- package/dist/lib/styles/border-styles.js +1 -5
- package/dist/lib/styles/endpoint-styles.js +1 -5
- package/dist/lib/styles/flex-styles.js +1 -5
- package/dist/lib/styles/font-styles.js +1 -5
- package/dist/lib/styles/info-styles.js +1 -5
- package/dist/lib/styles/input-styles.js +1 -5
- package/dist/lib/styles/key-frame-styles.js +1 -5
- package/dist/lib/styles/nav-styles.js +1 -5
- package/dist/lib/styles/prism-styles.js +1 -5
- package/dist/lib/styles/schema-styles.js +1 -5
- package/dist/lib/styles/tab-styles.js +1 -5
- package/dist/lib/styles/table-styles.js +1 -5
- package/dist/lib/styles/tag-input-styles.js +1 -5
- package/dist/lib/templates/advance-search-template.js +0 -6
- package/dist/lib/templates/callback-template.js +1 -3
- package/dist/lib/templates/code-samples-template.js +0 -4
- package/dist/lib/templates/components-template.js +43 -9
- package/dist/lib/templates/endpoint-template.js +6 -29
- package/dist/lib/templates/expanded-endpoint-template.js +3 -17
- package/dist/lib/templates/focused-endpoint-template.js +0 -19
- package/dist/lib/templates/mainBodyTemplate.js +2 -13
- package/dist/lib/templates/navbar-template.js +9 -20
- package/dist/lib/templates/overview-template.js +1 -6
- package/dist/lib/templates/security-scheme-template.js +12 -79
- package/dist/lib/templates/server-template.js +1 -12
- package/dist/lib/utils/color-utils.js +4 -25
- package/dist/lib/utils/common-utils.js +3 -33
- package/dist/lib/utils/schema-utils.js +33 -141
- package/dist/lib/utils/spec-parser.js +35 -128
- package/dist/lib/utils/theme.js +3 -16
- package/dist/lib/utils/xml/xml.js +1 -42
- package/package.json +2 -2
@@ -12,9 +12,7 @@ exports.pathIsInSearch = pathIsInSearch;
|
|
12
12
|
exports.replaceState = replaceState;
|
13
13
|
exports.schemaKeys = schemaKeys;
|
14
14
|
exports.sleep = sleep;
|
15
|
-
|
16
15
|
var _index = require("../languages/index.js");
|
17
|
-
|
18
16
|
/* For Delayed Event Handler Execution */
|
19
17
|
function debounce(fn, delay) {
|
20
18
|
let timeoutID = null;
|
@@ -26,40 +24,32 @@ function debounce(fn, delay) {
|
|
26
24
|
}, delay);
|
27
25
|
};
|
28
26
|
}
|
29
|
-
|
30
|
-
const invalidCharsRegEx = new RegExp(/[\s#:?&={}]/, 'g'); // used for generating valid html element ids by replacing the invalid chars with hyphen (-)
|
31
|
-
|
32
|
-
exports.invalidCharsRegEx = invalidCharsRegEx;
|
27
|
+
const invalidCharsRegEx = exports.invalidCharsRegEx = new RegExp(/[\s#:?&={}]/, 'g'); // used for generating valid html element ids by replacing the invalid chars with hyphen (-)
|
33
28
|
|
34
29
|
function sleep(ms) {
|
35
30
|
return new Promise(resolve => setTimeout(resolve, ms));
|
36
31
|
}
|
37
|
-
|
38
32
|
function copyToClipboard(copyData, eventTarget) {
|
39
33
|
// In lots of places we have more than a couple of spaces for <pre> display purposes, we remove those extra spaces here.
|
40
34
|
let data = copyData === null || copyData === void 0 ? void 0 : copyData.trim().replace(/\s{8}/g, ' ');
|
41
|
-
|
42
35
|
try {
|
43
36
|
// If the parsed type is a number, then leave it alone
|
44
37
|
if (typeof JSON.parse(data) === 'object') {
|
45
38
|
// Convert to 2 spaces in all JSON text
|
46
39
|
data = JSON.stringify(JSON.parse(data), null, 2).trim();
|
47
40
|
}
|
48
|
-
} catch (error) {
|
41
|
+
} catch (error) {
|
42
|
+
// Ignore non JSON text;
|
49
43
|
}
|
50
|
-
|
51
44
|
const textArea = document.createElement('textarea');
|
52
45
|
textArea.value = data;
|
53
46
|
textArea.style.position = 'fixed'; // avoid scrolling to bottom
|
54
|
-
|
55
47
|
document.body.appendChild(textArea);
|
56
48
|
textArea.focus();
|
57
49
|
textArea.select();
|
58
|
-
|
59
50
|
try {
|
60
51
|
document.execCommand('copy');
|
61
52
|
const btnEl = eventTarget === null || eventTarget === void 0 ? void 0 : eventTarget.target;
|
62
|
-
|
63
53
|
if (btnEl) {
|
64
54
|
btnEl.innerText = (0, _index.getI18nText)('operations.copied');
|
65
55
|
setTimeout(() => {
|
@@ -69,36 +59,28 @@ function copyToClipboard(copyData, eventTarget) {
|
|
69
59
|
} catch (err) {
|
70
60
|
console.error('Unable to copy', err); // eslint-disable-line no-console
|
71
61
|
}
|
72
|
-
|
73
62
|
document.body.removeChild(textArea);
|
74
63
|
}
|
75
|
-
|
76
64
|
function getBaseUrlFromUrl(url) {
|
77
65
|
const pathArray = url.split('/');
|
78
66
|
return `${pathArray[0]}//${pathArray[2]}`;
|
79
67
|
}
|
80
|
-
|
81
68
|
function componentIsInSearch(searchVal, component) {
|
82
69
|
return !searchVal || component.name.toLowerCase().includes(searchVal.toLowerCase());
|
83
70
|
}
|
84
|
-
|
85
71
|
function pathIsInSearch(searchVal, path) {
|
86
72
|
if (!searchVal) {
|
87
73
|
return true;
|
88
74
|
}
|
89
|
-
|
90
75
|
const stringToSearch = `${path.method} ${path.path} ${path.summary || ''} ${path.description || ''} ${path.operationId || ''}`;
|
91
76
|
return stringToSearch.includes(searchVal) || stringToSearch.toLowerCase().includes(searchVal) || stringToSearch.normalize('NFD').replace(/[\u0300-\u036f]/g, '').includes(searchVal) || stringToSearch.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '').includes(searchVal);
|
92
77
|
}
|
93
|
-
|
94
78
|
function schemaKeys(schemaProps, result = new Set()) {
|
95
79
|
if (!schemaProps) {
|
96
80
|
return result;
|
97
81
|
}
|
98
|
-
|
99
82
|
Object.keys(schemaProps).forEach(key => {
|
100
83
|
result.add(key);
|
101
|
-
|
102
84
|
if (schemaProps[key].properties) {
|
103
85
|
schemaKeys(schemaProps[key].properties, result);
|
104
86
|
} else if (schemaProps[key].items && schemaProps[key].items.properties) {
|
@@ -107,45 +89,35 @@ function schemaKeys(schemaProps, result = new Set()) {
|
|
107
89
|
});
|
108
90
|
return result;
|
109
91
|
}
|
110
|
-
|
111
92
|
function advancedSearch(searchVal, allSpecTags, searchOptions = []) {
|
112
93
|
if (!searchVal.trim() || searchOptions.length === 0) {
|
113
94
|
return undefined;
|
114
95
|
}
|
115
|
-
|
116
96
|
const pathsMatched = [];
|
117
97
|
allSpecTags.forEach(tag => {
|
118
98
|
tag.paths.forEach(path => {
|
119
99
|
let stringToSearch = '';
|
120
|
-
|
121
100
|
if (searchOptions.includes('search-api-path')) {
|
122
101
|
stringToSearch = path.path;
|
123
102
|
}
|
124
|
-
|
125
103
|
if (searchOptions.includes('search-api-descr')) {
|
126
104
|
stringToSearch = `${stringToSearch} ${path.summary || path.description || ''}`;
|
127
105
|
}
|
128
|
-
|
129
106
|
if (searchOptions.includes('search-api-params')) {
|
130
107
|
stringToSearch = `${stringToSearch} ${path.parameters && path.parameters.map(v => v.name).join(' ') || ''}`;
|
131
108
|
}
|
132
|
-
|
133
109
|
if (searchOptions.includes('search-api-request-body') && path.requestBody) {
|
134
110
|
let schemaKeySet = new Set();
|
135
|
-
|
136
111
|
for (const contentType in path.requestBody && path.requestBody.content) {
|
137
112
|
if (path.requestBody.content[contentType].schema && path.requestBody.content[contentType].schema.properties) {
|
138
113
|
schemaKeySet = schemaKeys(path.requestBody.content[contentType].schema.properties);
|
139
114
|
}
|
140
|
-
|
141
115
|
stringToSearch = `${stringToSearch} ${[...schemaKeySet].join(' ')}`;
|
142
116
|
}
|
143
117
|
}
|
144
|
-
|
145
118
|
if (searchOptions.includes('search-api-resp-descr')) {
|
146
119
|
stringToSearch = `${stringToSearch} ${Object.values(path.responses).map(v => v.description || '').join(' ')}`;
|
147
120
|
}
|
148
|
-
|
149
121
|
if (stringToSearch.toLowerCase().includes(searchVal.trim().toLowerCase())) {
|
150
122
|
pathsMatched.push({
|
151
123
|
elementId: path.elementId,
|
@@ -159,13 +131,11 @@ function advancedSearch(searchVal, allSpecTags, searchOptions = []) {
|
|
159
131
|
});
|
160
132
|
return pathsMatched;
|
161
133
|
}
|
162
|
-
|
163
134
|
function getCurrentElement() {
|
164
135
|
const currentQuery = (window.location.hash || '').split('?')[1];
|
165
136
|
const query = new URLSearchParams(currentQuery);
|
166
137
|
return decodeURIComponent(query.get('route') || '');
|
167
138
|
}
|
168
|
-
|
169
139
|
function replaceState(rawElementId) {
|
170
140
|
const elementId = rawElementId && rawElementId.replace(/^#/, '') || '';
|
171
141
|
const currentNavigationHashPart = (window.location.hash || '').split('?')[0].replace(/^#/, '');
|