openapi-explorer 2.1.656 → 2.1.659
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 +1 -1
- 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 +0 -5
- 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
@@ -2,25 +2,15 @@
|
|
2
2
|
|
3
3
|
exports.__esModule = true;
|
4
4
|
exports.default = ProcessSpec;
|
5
|
-
|
6
5
|
var _openapiResolverBrowser = _interopRequireDefault(require("openapi-resolver/dist/openapi-resolver.browser.js"));
|
7
|
-
|
8
6
|
var _marked = require("marked");
|
9
|
-
|
10
7
|
var _commonUtils = require("./common-utils.js");
|
11
|
-
|
12
|
-
var _index = require("../languages/index.js");
|
13
|
-
|
14
8
|
var _lodash = _interopRequireDefault(require("lodash.clonedeep"));
|
15
|
-
|
16
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
17
|
-
|
18
10
|
async function ProcessSpec(specUrlOrObject, serverUrl = '') {
|
19
11
|
var _jsonParsedSpec$info, _jsonParsedSpec$compo;
|
20
|
-
|
21
12
|
const inputSpecIsAUrl = typeof specUrlOrObject === 'string' && specUrlOrObject.match(/^http/) || typeof specUrlOrObject === 'object' && typeof specUrlOrObject.href === 'string';
|
22
13
|
let jsonParsedSpec;
|
23
|
-
|
24
14
|
try {
|
25
15
|
jsonParsedSpec = await (0, _openapiResolverBrowser.default)(specUrlOrObject);
|
26
16
|
} catch (error) {
|
@@ -28,20 +18,21 @@ async function ProcessSpec(specUrlOrObject, serverUrl = '') {
|
|
28
18
|
console.error('Error parsing specification', error);
|
29
19
|
throw Error('SpecificationNotFound');
|
30
20
|
}
|
31
|
-
|
32
21
|
if (!jsonParsedSpec) {
|
33
22
|
throw Error('SpecificationNotFound');
|
34
|
-
}
|
35
|
-
|
23
|
+
}
|
36
24
|
|
37
|
-
|
25
|
+
// Tags with Paths and WebHooks
|
26
|
+
const tags = groupByTags(jsonParsedSpec);
|
38
27
|
|
39
|
-
|
28
|
+
// Components
|
29
|
+
const components = getComponents(jsonParsedSpec);
|
40
30
|
|
41
|
-
|
31
|
+
// Info Description Headers
|
32
|
+
const infoDescriptionHeaders = (_jsonParsedSpec$info = jsonParsedSpec.info) !== null && _jsonParsedSpec$info !== void 0 && _jsonParsedSpec$info.description ? getHeadersFromMarkdown(jsonParsedSpec.info.description) : [];
|
42
33
|
|
34
|
+
// Security Scheme
|
43
35
|
const securitySchemes = [];
|
44
|
-
|
45
36
|
if ((_jsonParsedSpec$compo = jsonParsedSpec.components) !== null && _jsonParsedSpec$compo !== void 0 && _jsonParsedSpec$compo.securitySchemes) {
|
46
37
|
Object.entries(jsonParsedSpec.components.securitySchemes).forEach(kv => {
|
47
38
|
const securityObj = {
|
@@ -50,7 +41,6 @@ async function ProcessSpec(specUrlOrObject, serverUrl = '') {
|
|
50
41
|
};
|
51
42
|
securityObj.value = '';
|
52
43
|
securityObj.finalKeyValue = '';
|
53
|
-
|
54
44
|
if (kv[1].type === 'apiKey' || kv[1].type === 'http') {
|
55
45
|
securityObj.name = kv[1].name || 'Authorization';
|
56
46
|
securityObj.user = '';
|
@@ -60,26 +50,22 @@ async function ProcessSpec(specUrlOrObject, serverUrl = '') {
|
|
60
50
|
securityObj.clientId = '';
|
61
51
|
securityObj.clientSecret = '';
|
62
52
|
}
|
63
|
-
|
64
53
|
securitySchemes.push(securityObj);
|
65
54
|
});
|
66
|
-
}
|
67
|
-
|
55
|
+
}
|
68
56
|
|
57
|
+
// Servers
|
69
58
|
let servers = [];
|
70
|
-
|
71
59
|
if (Array.isArray(jsonParsedSpec.servers) && jsonParsedSpec.servers.length) {
|
72
60
|
jsonParsedSpec.servers.filter(s => s).forEach(v => {
|
73
61
|
let computedUrl = v.url.trim();
|
74
|
-
|
75
62
|
if (!(computedUrl.startsWith('http') || computedUrl.startsWith('//') || computedUrl.startsWith('{'))) {
|
76
63
|
if (window.location.origin.startsWith('http')) {
|
77
64
|
v.url = window.location.origin + v.url;
|
78
65
|
computedUrl = v.url;
|
79
66
|
}
|
80
|
-
}
|
81
|
-
|
82
|
-
|
67
|
+
}
|
68
|
+
// Apply server-variables to generate final computed-url
|
83
69
|
if (v.variables) {
|
84
70
|
Object.entries(v.variables).forEach(kv => {
|
85
71
|
const regex = new RegExp(`{${kv[0]}}`, 'g');
|
@@ -87,7 +73,6 @@ async function ProcessSpec(specUrlOrObject, serverUrl = '') {
|
|
87
73
|
kv[1].value = kv[1].default || '';
|
88
74
|
});
|
89
75
|
}
|
90
|
-
|
91
76
|
v.computedUrl = computedUrl;
|
92
77
|
});
|
93
78
|
const explicitServers = serverUrl && !jsonParsedSpec.servers.some(s => s.url === serverUrl || s.computedUrl === serverUrl) ? [{
|
@@ -116,7 +101,6 @@ async function ProcessSpec(specUrlOrObject, serverUrl = '') {
|
|
116
101
|
computedUrl: 'http://localhost'
|
117
102
|
}];
|
118
103
|
}
|
119
|
-
|
120
104
|
const parsedSpec = {
|
121
105
|
info: jsonParsedSpec.info,
|
122
106
|
infoDescriptionHeaders,
|
@@ -129,97 +113,36 @@ async function ProcessSpec(specUrlOrObject, serverUrl = '') {
|
|
129
113
|
};
|
130
114
|
return parsedSpec;
|
131
115
|
}
|
132
|
-
|
133
116
|
function getHeadersFromMarkdown(markdownContent) {
|
134
117
|
const tokens = _marked.marked.lexer(markdownContent);
|
135
|
-
|
136
118
|
const headers = tokens.filter(v => v.type === 'heading' && v.depth <= 2);
|
137
119
|
return headers || [];
|
138
120
|
}
|
139
|
-
|
140
121
|
function getComponents(openApiSpec) {
|
141
122
|
if (!openApiSpec.components) {
|
142
123
|
return [];
|
143
124
|
}
|
144
|
-
|
145
125
|
const components = [];
|
146
|
-
|
147
|
-
|
148
|
-
const subComponents = Object.keys(openApiSpec.components[component]).map(sComponent => ({
|
126
|
+
for (const componentKeyId in openApiSpec.components) {
|
127
|
+
const subComponents = Object.keys(openApiSpec.components[componentKeyId]).map(sComponent => ({
|
149
128
|
expanded: true,
|
150
|
-
id: `${
|
129
|
+
id: `${componentKeyId.toLowerCase()}-${sComponent.toLowerCase()}`.replace(_commonUtils.invalidCharsRegEx, '-'),
|
151
130
|
name: sComponent,
|
152
|
-
component: openApiSpec.components[
|
131
|
+
component: openApiSpec.components[componentKeyId][sComponent]
|
153
132
|
})).sort((a, b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase()));
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
switch (component) {
|
158
|
-
case 'schemas':
|
159
|
-
cmpName = (0, _index.getI18nText)('menu.schemas');
|
160
|
-
cmpDescription = '';
|
161
|
-
break;
|
162
|
-
|
163
|
-
case 'responses':
|
164
|
-
cmpName = 'Responses';
|
165
|
-
cmpDescription = 'Describes responses from an API Operation, including design-time, static links to operations based on the response.';
|
166
|
-
break;
|
167
|
-
|
168
|
-
case 'parameters':
|
169
|
-
cmpName = 'Parameters';
|
170
|
-
cmpDescription = 'Describes operation parameters. A unique parameter is defined by a combination of a name and location.';
|
171
|
-
break;
|
172
|
-
|
173
|
-
case 'examples':
|
174
|
-
cmpName = 'Examples';
|
175
|
-
cmpDescription = 'List of Examples for operations, can be requests, responses and objects examples.';
|
176
|
-
break;
|
177
|
-
|
178
|
-
case 'requestBodies':
|
179
|
-
break;
|
180
|
-
|
181
|
-
case 'headers':
|
182
|
-
cmpName = 'Headers';
|
183
|
-
cmpDescription = 'Headers follows the structure of the Parameters but they are explicitly in "header"';
|
184
|
-
break;
|
185
|
-
|
186
|
-
case 'securitySchemes':
|
187
|
-
case 'securitySchemas':
|
188
|
-
break;
|
189
|
-
|
190
|
-
case 'links':
|
191
|
-
cmpName = 'Links';
|
192
|
-
cmpDescription = 'Links represent a possible design-time link for a response. The presence of a link does not guarantee the caller\'s ability to successfully invoke it, rather it provides a known relationship and traversal mechanism between responses and other operations.';
|
193
|
-
break;
|
194
|
-
|
195
|
-
case 'callbacks':
|
196
|
-
cmpName = 'Callbacks'; // eslint-disable-next-line max-len
|
197
|
-
|
198
|
-
cmpDescription = 'A map of possible out-of band callbacks related to the parent operation. Each value in the map is a Path Item Object that describes a set of requests that may be initiated by the API provider and the expected responses. The key value used to identify the path item object is an expression, evaluated at runtime, that identifies a URL to use for the callback operation.';
|
199
|
-
break;
|
200
|
-
|
201
|
-
default:
|
202
|
-
cmpName = component;
|
203
|
-
cmpDescription = component;
|
204
|
-
break;
|
205
|
-
}
|
206
|
-
|
207
|
-
if (cmpName) {
|
208
|
-
components.push({
|
209
|
-
expanded: true,
|
210
|
-
name: cmpName,
|
211
|
-
description: cmpDescription,
|
212
|
-
subComponents
|
213
|
-
});
|
133
|
+
if (componentKeyId === 'requestBodies' || componentKeyId === 'securitySchemes' || componentKeyId === 'securitySchemas') {
|
134
|
+
continue;
|
214
135
|
}
|
136
|
+
components.push({
|
137
|
+
expanded: true,
|
138
|
+
componentKeyId,
|
139
|
+
subComponents
|
140
|
+
});
|
215
141
|
}
|
216
|
-
|
217
142
|
return components;
|
218
143
|
}
|
219
|
-
|
220
144
|
function groupByTags(openApiSpec) {
|
221
145
|
const supportedMethods = ['get', 'query', 'put', 'post', 'patch', 'delete', 'head', 'options']; // this is also used for ordering endpoints by methods
|
222
|
-
|
223
146
|
const tags = openApiSpec.tags && Array.isArray(openApiSpec.tags) ? openApiSpec.tags.map(t => {
|
224
147
|
const name = typeof t === 'string' ? t : t.name;
|
225
148
|
return {
|
@@ -232,42 +155,32 @@ function groupByTags(openApiSpec) {
|
|
232
155
|
};
|
233
156
|
}) : [];
|
234
157
|
const pathsAndWebhooks = openApiSpec.paths || {};
|
235
|
-
|
236
158
|
if (openApiSpec.webhooks) {
|
237
159
|
for (const [key, value] of Object.entries(openApiSpec.webhooks)) {
|
238
160
|
value._type = 'webhook'; // eslint-disable-line no-underscore-dangle
|
239
|
-
|
240
161
|
pathsAndWebhooks[key] = value;
|
241
162
|
}
|
242
|
-
}
|
243
|
-
|
244
|
-
|
163
|
+
}
|
164
|
+
// For each path find the tag and push it into the corresponding tag
|
245
165
|
for (const pathOrHookName in pathsAndWebhooks) {
|
246
166
|
const commonPathPropServers = pathsAndWebhooks[pathOrHookName].servers || [];
|
247
167
|
const isWebhook = pathsAndWebhooks[pathOrHookName]._type === 'webhook'; // eslint-disable-line no-underscore-dangle
|
248
|
-
|
249
168
|
supportedMethods.forEach(methodName => {
|
250
169
|
const commonParams = (0, _lodash.default)(pathsAndWebhooks[pathOrHookName].parameters);
|
251
|
-
|
252
170
|
if (pathsAndWebhooks[pathOrHookName][methodName]) {
|
253
|
-
const pathOrHookObj = openApiSpec.paths[pathOrHookName][methodName];
|
254
|
-
|
171
|
+
const pathOrHookObj = openApiSpec.paths[pathOrHookName][methodName];
|
172
|
+
// If path.methods are tagged, else generate it from path
|
255
173
|
const pathTags = Array.isArray(pathOrHookObj.tags) ? pathOrHookObj.tags : pathOrHookObj.tags && [pathOrHookObj.tags] || [];
|
256
|
-
|
257
174
|
if (pathTags.length === 0) {
|
258
175
|
pathTags.push('General ⦂');
|
259
176
|
}
|
260
|
-
|
261
177
|
pathTags.forEach(tag => {
|
262
178
|
let tagObj;
|
263
179
|
let specTagsItem;
|
264
|
-
|
265
180
|
if (openApiSpec.tags) {
|
266
181
|
specTagsItem = tags.find(v => v.name.toLowerCase() === tag.toLowerCase());
|
267
182
|
}
|
268
|
-
|
269
183
|
tagObj = tags.find(v => v.name === tag);
|
270
|
-
|
271
184
|
if (!tagObj) {
|
272
185
|
tagObj = {
|
273
186
|
elementId: `tag--${tag.replace(_commonUtils.invalidCharsRegEx, '-')}`,
|
@@ -278,25 +191,21 @@ function groupByTags(openApiSpec) {
|
|
278
191
|
expanded: true
|
279
192
|
};
|
280
193
|
tags.push(tagObj);
|
281
|
-
}
|
282
|
-
|
194
|
+
}
|
283
195
|
|
196
|
+
// Generate a short summary which is broken
|
284
197
|
let shortSummary = (pathOrHookObj.summary || pathOrHookObj.description || `${methodName.toUpperCase()} ${pathOrHookName}`).trim();
|
285
|
-
|
286
198
|
if (shortSummary.length > 100) {
|
287
199
|
shortSummary = shortSummary.split(/[.|!|?]\s|[\r?\n]/)[0]; // take the first line (period or carriage return)
|
288
|
-
}
|
289
|
-
|
290
|
-
|
200
|
+
}
|
201
|
+
// Merge Common Parameters with This methods parameters
|
291
202
|
let finalParameters = [];
|
292
|
-
|
293
203
|
if (commonParams) {
|
294
204
|
if (pathOrHookObj.parameters) {
|
295
205
|
finalParameters = commonParams.filter(commonParam => {
|
296
206
|
if (!pathOrHookObj.parameters.some(param => commonParam.name === param.name && commonParam.in === param.in)) {
|
297
207
|
return commonParam;
|
298
208
|
}
|
299
|
-
|
300
209
|
return undefined;
|
301
210
|
}).concat(pathOrHookObj.parameters);
|
302
211
|
} else {
|
@@ -304,22 +213,21 @@ function groupByTags(openApiSpec) {
|
|
304
213
|
}
|
305
214
|
} else {
|
306
215
|
finalParameters = pathOrHookObj.parameters ? pathOrHookObj.parameters.slice(0) : [];
|
307
|
-
}
|
308
|
-
|
216
|
+
}
|
309
217
|
|
218
|
+
// Remove bad callbacks
|
310
219
|
if (pathOrHookObj.callbacks) {
|
311
220
|
for (const [callbackName, callbackConfig] of Object.entries(pathOrHookObj.callbacks)) {
|
312
221
|
const originalCallbackEntries = Object.entries(callbackConfig);
|
313
222
|
const filteredCallbacks = originalCallbackEntries.filter(entry => typeof entry[1] === 'object') || [];
|
314
223
|
pathOrHookObj.callbacks[callbackName] = Object.fromEntries(filteredCallbacks);
|
315
|
-
|
316
224
|
if (filteredCallbacks.length !== originalCallbackEntries.length) {
|
317
225
|
console.warn(`OpenAPI Explorer: Invalid Callback found in ${callbackName}`); // eslint-disable-line no-console
|
318
226
|
}
|
319
227
|
}
|
320
|
-
}
|
321
|
-
|
228
|
+
}
|
322
229
|
|
230
|
+
// Update Responses
|
323
231
|
const pathObject = {
|
324
232
|
expanded: false,
|
325
233
|
isWebhook,
|
@@ -351,6 +259,5 @@ function groupByTags(openApiSpec) {
|
|
351
259
|
}
|
352
260
|
}); // End of Methods
|
353
261
|
}
|
354
|
-
|
355
262
|
return tags;
|
356
263
|
}
|
package/dist/lib/utils/theme.js
CHANGED
@@ -2,50 +2,36 @@
|
|
2
2
|
|
3
3
|
exports.__esModule = true;
|
4
4
|
exports.default = setTheme;
|
5
|
-
|
6
5
|
var _lit = require("lit");
|
7
|
-
|
8
6
|
var _color = _interopRequireDefault(require("color"));
|
9
|
-
|
10
7
|
var _colorUtils = _interopRequireDefault(require("./color-utils.js"));
|
11
|
-
|
12
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
-
|
14
9
|
/* Generates an schema object containing type and constraint info */
|
15
|
-
// TODO: possible drive theme from:
|
16
10
|
|
11
|
+
// TODO: possible drive theme from:
|
17
12
|
/*
|
18
13
|
if (!this.theme || !'light, dark,'.includes(`${this.theme},`)) {
|
19
14
|
this.theme = (window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches) ? 'light' : 'dark';
|
20
15
|
}
|
21
16
|
*/
|
17
|
+
|
22
18
|
function setTheme(theme = {}) {
|
23
19
|
const bg1 = theme.bg1 ? theme.bg1 : '#ffffff';
|
24
20
|
const fg1 = theme.fg1 ? theme.fg1 : '#444444';
|
25
21
|
const bg2 = theme.bg2 ? theme.bg2 : _colorUtils.default.color.brightness(bg1, -5); // or '#fafafa'
|
26
|
-
|
27
22
|
const bg3 = theme.bg3 ? theme.bg3 : _colorUtils.default.color.brightness(bg1, -15); // or '#f6f6f6'
|
28
|
-
|
29
23
|
const lightBg = theme.bg3 ? theme.bg3 : _colorUtils.default.color.brightness(bg1, -45);
|
30
24
|
const fg2 = theme.fg2 ? theme.fg2 : _colorUtils.default.color.brightness(fg1, 17); // or '#555'
|
31
|
-
|
32
25
|
const fg3 = theme.fg3 ? theme.fg3 : _colorUtils.default.color.brightness(fg1, 30); // or #666
|
33
|
-
|
34
26
|
const lightFg = theme.fg3 ? theme.fg3 : _colorUtils.default.color.brightness(fg1, 70); // or #999
|
35
|
-
|
36
27
|
const inlineCodeFg = theme.inlineCodeFg ? theme.inlineCodeFg : 'brown';
|
37
28
|
const selectionBg = '#444';
|
38
29
|
const selectionFg = '#eee';
|
39
|
-
|
40
30
|
const headerColor = theme.headerColor || theme.primaryColor || _colorUtils.default.color.brightness(bg1, -180);
|
41
|
-
|
42
31
|
const navBgColor = theme.navBgColor || theme.primaryColor || _colorUtils.default.color.brightness(bg1, -180);
|
43
|
-
|
44
32
|
const navTextColor = theme.navTextColor ? theme.navTextColor : _colorUtils.default.color.opacity(_colorUtils.default.color.invert(navBgColor), '0.65');
|
45
33
|
const navHoverBgColor = theme.navHoverBgColor ? theme.navHoverBgColor : _colorUtils.default.color.brightness(navBgColor, -25);
|
46
|
-
|
47
34
|
const navHoverScrollbarColor = _colorUtils.default.color.brightness(navHoverBgColor, -5);
|
48
|
-
|
49
35
|
const navHoverTextColor = theme.navHoverTextColor ? theme.navHoverTextColor : _colorUtils.default.color.invert(navBgColor);
|
50
36
|
const overlayBg = 'rgba(0, 0, 0, 0.4)';
|
51
37
|
const defaultColors = [`--purple: ${getComputedStyle(this).getPropertyValue('--purple').trim() || '#6f42c1'}`, `--red: ${getComputedStyle(this).getPropertyValue('--red').trim() || '#dc3545'}`, `--orange: ${getComputedStyle(this).getPropertyValue('--orange').trim() || '#fd7e14'}`, `--yellow: ${getComputedStyle(this).getPropertyValue('--yellow').trim() || '#ffc107'}`, `--green: ${getComputedStyle(this).getPropertyValue('--green').trim() || '#28a745'}`, `--blue: ${getComputedStyle(this).getPropertyValue('--blue').trim() || '#38b3f9'}`, `--gray: ${getComputedStyle(this).getPropertyValue('--gray').trim() || '#465865'}`, '--pink: #e83e8c', '--white: #fff', ''];
|
@@ -80,6 +66,7 @@ function setTheme(theme = {}) {
|
|
80
66
|
// #dedede
|
81
67
|
hoverColor: theme.hoverColor || _colorUtils.default.color.brightness(bg1, -5),
|
82
68
|
// # f1f1f1
|
69
|
+
|
83
70
|
codeFg: theme.codeFg || '#666',
|
84
71
|
codePropertyColor: theme.codePropertyColor || '#905',
|
85
72
|
codeKeywordColor: theme.codeKeywordColor || '#07a',
|
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
exports.__esModule = true;
|
4
4
|
exports.default = xml;
|
5
|
-
|
6
5
|
/* eslint-disable no-underscore-dangle */
|
6
|
+
|
7
7
|
const XML_CHARACTER_MAP = {
|
8
8
|
'&': '&',
|
9
9
|
'"': '"',
|
@@ -11,48 +11,38 @@ const XML_CHARACTER_MAP = {
|
|
11
11
|
'<': '<',
|
12
12
|
'>': '>'
|
13
13
|
};
|
14
|
-
|
15
14
|
function escapeForXML(string) {
|
16
15
|
return string && string.replace ? string.replace(/([&"<>'])/g, function (str, item) {
|
17
16
|
return XML_CHARACTER_MAP[item];
|
18
17
|
}) : string;
|
19
18
|
}
|
20
|
-
|
21
19
|
const DEFAULT_INDENT = ' ';
|
22
|
-
|
23
20
|
function xml(input, rawOptions) {
|
24
21
|
let options = rawOptions;
|
25
|
-
|
26
22
|
if (typeof options !== 'object') {
|
27
23
|
options = {
|
28
24
|
indent: options
|
29
25
|
};
|
30
26
|
}
|
31
|
-
|
32
27
|
let output = '';
|
33
28
|
const indent = !options.indent ? '' : options.indent === true ? DEFAULT_INDENT : options.indent;
|
34
|
-
|
35
29
|
function append(_, out) {
|
36
30
|
if (out !== undefined) {
|
37
31
|
output += out;
|
38
32
|
}
|
39
33
|
}
|
40
|
-
|
41
34
|
function add(value, last) {
|
42
35
|
format(append, resolve(value, indent, indent ? 1 : 0), last);
|
43
36
|
}
|
44
|
-
|
45
37
|
function addXmlDeclaration(declaration) {
|
46
38
|
const encoding = declaration.encoding || 'UTF-8';
|
47
39
|
const attr = {
|
48
40
|
version: '1.0',
|
49
41
|
encoding: encoding
|
50
42
|
};
|
51
|
-
|
52
43
|
if (declaration.standalone) {
|
53
44
|
attr.standalone = declaration.standalone;
|
54
45
|
}
|
55
|
-
|
56
46
|
add({
|
57
47
|
'?xml': {
|
58
48
|
_attr: attr
|
@@ -60,11 +50,9 @@ function xml(input, rawOptions) {
|
|
60
50
|
});
|
61
51
|
output = output.replace('/>', '?>');
|
62
52
|
}
|
63
|
-
|
64
53
|
if (options.declaration) {
|
65
54
|
addXmlDeclaration(options.declaration);
|
66
55
|
}
|
67
|
-
|
68
56
|
if (input && input.forEach) {
|
69
57
|
input.forEach(function (value, i) {
|
70
58
|
add(value, i + 1 === input.length);
|
@@ -72,26 +60,21 @@ function xml(input, rawOptions) {
|
|
72
60
|
} else {
|
73
61
|
add(input, true);
|
74
62
|
}
|
75
|
-
|
76
63
|
return output;
|
77
64
|
}
|
78
|
-
|
79
65
|
function create_indent(character, count) {
|
80
66
|
return new Array(count || 0).join(character || '');
|
81
67
|
}
|
82
|
-
|
83
68
|
function resolve(data, indent, indent_count_raw) {
|
84
69
|
const indent_count = indent_count_raw || 0;
|
85
70
|
const indent_spaces = create_indent(indent, indent_count);
|
86
71
|
let name;
|
87
72
|
let values = data;
|
88
73
|
const interrupt = false;
|
89
|
-
|
90
74
|
if (typeof data === 'object') {
|
91
75
|
const keys = Object.keys(data);
|
92
76
|
name = keys[0];
|
93
77
|
values = data[name];
|
94
|
-
|
95
78
|
if (values && values._elem) {
|
96
79
|
values._elem.name = name;
|
97
80
|
values._elem.icount = indent_count;
|
@@ -101,39 +84,32 @@ function resolve(data, indent, indent_count_raw) {
|
|
101
84
|
return values._elem;
|
102
85
|
}
|
103
86
|
}
|
104
|
-
|
105
87
|
const attributes = [];
|
106
88
|
const content = [];
|
107
89
|
let isStringContent;
|
108
|
-
|
109
90
|
function get_attributes(obj) {
|
110
91
|
const keys = Object.keys(obj);
|
111
92
|
keys.forEach(function (key) {
|
112
93
|
attributes.push(attribute(key, obj[key]));
|
113
94
|
});
|
114
95
|
}
|
115
|
-
|
116
96
|
switch (typeof values) {
|
117
97
|
case 'object':
|
118
98
|
if (values === null) {
|
119
99
|
break;
|
120
100
|
}
|
121
|
-
|
122
101
|
if (values._attr) {
|
123
102
|
get_attributes(values._attr);
|
124
103
|
}
|
125
|
-
|
126
104
|
if (values._cdata) {
|
127
105
|
content.push(`${`<![CDATA[${values._cdata}`.replace(/\]\]>/g, ']]]]><![CDATA[>')}]]>`);
|
128
106
|
}
|
129
|
-
|
130
107
|
if (values.forEach) {
|
131
108
|
isStringContent = false;
|
132
109
|
content.push('');
|
133
110
|
values.forEach(function (value) {
|
134
111
|
if (typeof value === 'object') {
|
135
112
|
const _name = Object.keys(value)[0];
|
136
|
-
|
137
113
|
if (_name === '_attr') {
|
138
114
|
get_attributes(value._attr);
|
139
115
|
} else {
|
@@ -146,19 +122,15 @@ function resolve(data, indent, indent_count_raw) {
|
|
146
122
|
content.push(escapeForXML(value));
|
147
123
|
}
|
148
124
|
});
|
149
|
-
|
150
125
|
if (!isStringContent) {
|
151
126
|
content.push('');
|
152
127
|
}
|
153
128
|
}
|
154
|
-
|
155
129
|
break;
|
156
|
-
|
157
130
|
default:
|
158
131
|
// string
|
159
132
|
content.push(escapeForXML(values));
|
160
133
|
}
|
161
|
-
|
162
134
|
return {
|
163
135
|
name: name,
|
164
136
|
interrupt: interrupt,
|
@@ -169,33 +141,25 @@ function resolve(data, indent, indent_count_raw) {
|
|
169
141
|
indent: indent
|
170
142
|
};
|
171
143
|
}
|
172
|
-
|
173
144
|
function format(append, elem, end) {
|
174
145
|
if (typeof elem !== 'object') {
|
175
146
|
append(false, elem);
|
176
147
|
return;
|
177
148
|
}
|
178
|
-
|
179
149
|
const len = elem.interrupt ? 1 : elem.content.length;
|
180
|
-
|
181
150
|
function proceed() {
|
182
151
|
while (elem.content.length) {
|
183
152
|
const value = elem.content.shift();
|
184
|
-
|
185
153
|
if (value === undefined) {
|
186
154
|
continue;
|
187
155
|
}
|
188
|
-
|
189
156
|
if (interrupt(value)) {
|
190
157
|
return;
|
191
158
|
}
|
192
|
-
|
193
159
|
format(append, value);
|
194
160
|
}
|
195
|
-
|
196
161
|
append(false, (len > 1 ? elem.indents : '') + (elem.name ? `</${elem.name}>` : '') + (elem.indent && !end ? '\n' : ''));
|
197
162
|
}
|
198
|
-
|
199
163
|
function interrupt(value) {
|
200
164
|
if (value.interrupt) {
|
201
165
|
value.interrupt.append = append;
|
@@ -204,22 +168,17 @@ function format(append, elem, end) {
|
|
204
168
|
append(true);
|
205
169
|
return true;
|
206
170
|
}
|
207
|
-
|
208
171
|
return false;
|
209
172
|
}
|
210
|
-
|
211
173
|
append(false, elem.indents + (elem.name ? `<${elem.name}` : '') + (elem.attributes.length ? ` ${elem.attributes.join(' ')}` : '') + (len ? elem.name ? '>' : '' : elem.name ? '/>' : '') + (elem.indent && len > 1 ? '\n' : ''));
|
212
|
-
|
213
174
|
if (!len) {
|
214
175
|
append(false, elem.indent ? '\n' : '');
|
215
176
|
return;
|
216
177
|
}
|
217
|
-
|
218
178
|
if (!interrupt(elem)) {
|
219
179
|
proceed();
|
220
180
|
}
|
221
181
|
}
|
222
|
-
|
223
182
|
function attribute(key, value) {
|
224
183
|
return `${key}=` + `"${escapeForXML(value)}"`;
|
225
184
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "openapi-explorer",
|
3
|
-
"version": "2.1.
|
3
|
+
"version": "2.1.659",
|
4
4
|
"description": "OpenAPI Explorer - API viewer with dynamically generated components, documentation, and interaction console",
|
5
5
|
"author": "Authress Developers <developers@authress.io>",
|
6
6
|
"type": "module",
|
@@ -62,7 +62,7 @@
|
|
62
62
|
"lodash.merge": "^4.6.2",
|
63
63
|
"marked": "^4.0.16",
|
64
64
|
"openapi-data-validator": "^2.0.40",
|
65
|
-
"openapi-resolver": "^4.1.
|
65
|
+
"openapi-resolver": "^4.1.49",
|
66
66
|
"prismjs": "^1.29.0",
|
67
67
|
"randexp": "^0.5.3",
|
68
68
|
"xml-but-prettier": "^1.0.1"
|