openapi-explorer 0.8.282 → 0.8.285
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 +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/report.html +2 -2
- package/package.json +2 -3
- package/src/openapi-explorer-oauth-handler.js +4 -1
- package/src/openapi-explorer.js +8 -1
- package/src/utils/schema-utils.js +1 -2
- package/src/utils/xml/xml.js +258 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openapi-explorer",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.285",
|
|
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": {
|
|
@@ -39,11 +39,10 @@
|
|
|
39
39
|
],
|
|
40
40
|
"mode": "production",
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@kyleshockey/xml": "^1.0.2",
|
|
43
42
|
"authress-login": "^1.1.77",
|
|
44
43
|
"base64url": "^3.0.1",
|
|
45
44
|
"buffer": "^6.0.3",
|
|
46
|
-
"color": "^
|
|
45
|
+
"color": "^4.2.3",
|
|
47
46
|
"create-hash": "^1.2.0",
|
|
48
47
|
"js-yaml": "^4.0",
|
|
49
48
|
"lit-element": "2.4.0",
|
|
@@ -5,4 +5,7 @@ export default class OpenapiExplorerOauthHandler extends HTMLElement {
|
|
|
5
5
|
checkForAuthToken(true);
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
if (!customElements.get('openapi-explorer-oauth-handler')) {
|
|
10
|
+
customElements.define('openapi-explorer-oauth-handler', OpenapiExplorerOauthHandler);
|
|
11
|
+
}
|
package/src/openapi-explorer.js
CHANGED
|
@@ -31,6 +31,11 @@ import responsiveViewMainBodyTemplate from './templates/responsiveViewMainBodyTe
|
|
|
31
31
|
import apiRequestStyles from './styles/api-request-styles';
|
|
32
32
|
import { checkForAuthToken } from './templates/security-scheme-template';
|
|
33
33
|
|
|
34
|
+
if (typeof global === undefined) {
|
|
35
|
+
// eslint-disable-next-line no-global-assign
|
|
36
|
+
global = {};
|
|
37
|
+
}
|
|
38
|
+
|
|
34
39
|
export default class OpenApiExplorer extends LitElement {
|
|
35
40
|
constructor() {
|
|
36
41
|
super();
|
|
@@ -795,5 +800,7 @@ export default class OpenApiExplorer extends LitElement {
|
|
|
795
800
|
}
|
|
796
801
|
}
|
|
797
802
|
|
|
798
|
-
customElements.
|
|
803
|
+
if (!customElements.get('openapi-explorer')) {
|
|
804
|
+
customElements.define('openapi-explorer', OpenApiExplorer);
|
|
805
|
+
}
|
|
799
806
|
import './openapi-explorer-oauth-handler';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import cloneDeep from 'lodash.clonedeep';
|
|
2
2
|
import { expandN } from 'regex-to-strings';
|
|
3
|
-
|
|
4
|
-
const xmlFormatter = require('@kyleshockey/xml');
|
|
3
|
+
import xmlFormatter from './xml/xml';
|
|
5
4
|
|
|
6
5
|
/* Generates an schema object containing type and constraint info */
|
|
7
6
|
export function getTypeInfo(schema) {
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
/* eslint-disable no-underscore-dangle */
|
|
2
|
+
|
|
3
|
+
const XML_CHARACTER_MAP = {
|
|
4
|
+
'&': '&',
|
|
5
|
+
'"': '"',
|
|
6
|
+
"'": ''',
|
|
7
|
+
'<': '<',
|
|
8
|
+
'>': '>'
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
function escapeForXML(string) {
|
|
12
|
+
return string && string.replace
|
|
13
|
+
? string.replace(/([&"<>'])/g, function(str, item) {
|
|
14
|
+
return XML_CHARACTER_MAP[item];
|
|
15
|
+
})
|
|
16
|
+
: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const DEFAULT_INDENT = ' ';
|
|
20
|
+
|
|
21
|
+
function xml(input, rawOptions) {
|
|
22
|
+
let options = rawOptions;
|
|
23
|
+
if (typeof options !== 'object') {
|
|
24
|
+
options = {
|
|
25
|
+
indent: options
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
let output = '';
|
|
30
|
+
const indent = !options.indent ? ''
|
|
31
|
+
: options.indent === true ? DEFAULT_INDENT
|
|
32
|
+
: options.indent;
|
|
33
|
+
let instant = true;
|
|
34
|
+
|
|
35
|
+
function delay(func) {
|
|
36
|
+
if (!instant) {
|
|
37
|
+
func();
|
|
38
|
+
} else {
|
|
39
|
+
process.nextTick(func);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function append(_, out) {
|
|
44
|
+
if (out !== undefined) {
|
|
45
|
+
output += out;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function add(value, last) {
|
|
50
|
+
format(append, resolve(value, indent, indent ? 1 : 0), last);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function addXmlDeclaration(declaration) {
|
|
54
|
+
const encoding = declaration.encoding || 'UTF-8';
|
|
55
|
+
const attr = { version: '1.0', encoding: encoding };
|
|
56
|
+
|
|
57
|
+
if (declaration.standalone) {
|
|
58
|
+
attr.standalone = declaration.standalone;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
add({ '?xml': { _attr: attr } });
|
|
62
|
+
output = output.replace('/>', '?>');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// disable delay delayed
|
|
66
|
+
delay(function() { instant = false; });
|
|
67
|
+
|
|
68
|
+
if (options.declaration) {
|
|
69
|
+
addXmlDeclaration(options.declaration);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (input && input.forEach) {
|
|
73
|
+
input.forEach(function(value, i) {
|
|
74
|
+
add(value, i + 1 === input.length);
|
|
75
|
+
});
|
|
76
|
+
} else {
|
|
77
|
+
add(input, true);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return output;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function element(/* input, …*/) {
|
|
84
|
+
const input = Array.prototype.slice.call(arguments);
|
|
85
|
+
const self = {
|
|
86
|
+
_elem: resolve(input)
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
self.push = function(pushInput) {
|
|
90
|
+
if (!this.append) {
|
|
91
|
+
throw new Error('not assigned to a parent!');
|
|
92
|
+
}
|
|
93
|
+
const that = this;
|
|
94
|
+
const indent = this._elem.indent;
|
|
95
|
+
format(this.append, resolve(
|
|
96
|
+
pushInput, indent, this._elem.icount + (indent ? 1 : 0)),
|
|
97
|
+
function() { that.append(true); });
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
self.close = function(closeInput) {
|
|
101
|
+
if (closeInput !== undefined) {
|
|
102
|
+
this.push(closeInput);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
return self;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function create_indent(character, count) {
|
|
110
|
+
return (new Array(count || 0).join(character || ''));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function resolve(data, indent, indent_count_raw) {
|
|
114
|
+
const indent_count = indent_count_raw || 0;
|
|
115
|
+
const indent_spaces = create_indent(indent, indent_count);
|
|
116
|
+
let name;
|
|
117
|
+
let values = data;
|
|
118
|
+
const interrupt = false;
|
|
119
|
+
|
|
120
|
+
if (typeof data === 'object') {
|
|
121
|
+
const keys = Object.keys(data);
|
|
122
|
+
name = keys[0];
|
|
123
|
+
values = data[name];
|
|
124
|
+
|
|
125
|
+
if (values && values._elem) {
|
|
126
|
+
values._elem.name = name;
|
|
127
|
+
values._elem.icount = indent_count;
|
|
128
|
+
values._elem.indent = indent;
|
|
129
|
+
values._elem.indents = indent_spaces;
|
|
130
|
+
values._elem.interrupt = values;
|
|
131
|
+
return values._elem;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const attributes = [];
|
|
136
|
+
const content = [];
|
|
137
|
+
|
|
138
|
+
let isStringContent;
|
|
139
|
+
|
|
140
|
+
function get_attributes(obj) {
|
|
141
|
+
const keys = Object.keys(obj);
|
|
142
|
+
keys.forEach(function(key) {
|
|
143
|
+
attributes.push(attribute(key, obj[key]));
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
switch (typeof values) {
|
|
148
|
+
case 'object':
|
|
149
|
+
if (values === null) {break;}
|
|
150
|
+
|
|
151
|
+
if (values._attr) {
|
|
152
|
+
get_attributes(values._attr);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (values._cdata) {
|
|
156
|
+
content.push(
|
|
157
|
+
`${(`<![CDATA[${values._cdata}`).replace(/\]\]>/g, ']]]]><![CDATA[>')}]]>`
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (values.forEach) {
|
|
162
|
+
isStringContent = false;
|
|
163
|
+
content.push('');
|
|
164
|
+
values.forEach(function(value) {
|
|
165
|
+
if (typeof value === 'object') {
|
|
166
|
+
const _name = Object.keys(value)[0];
|
|
167
|
+
|
|
168
|
+
if (_name === '_attr') {
|
|
169
|
+
get_attributes(value._attr);
|
|
170
|
+
} else {
|
|
171
|
+
content.push(resolve(
|
|
172
|
+
value, indent, indent_count + 1));
|
|
173
|
+
}
|
|
174
|
+
} else {
|
|
175
|
+
// string
|
|
176
|
+
content.pop();
|
|
177
|
+
isStringContent = true;
|
|
178
|
+
content.push(escapeForXML(value));
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
if (!isStringContent) {
|
|
182
|
+
content.push('');
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
break;
|
|
186
|
+
|
|
187
|
+
default:
|
|
188
|
+
// string
|
|
189
|
+
content.push(escapeForXML(values));
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return {
|
|
193
|
+
name: name,
|
|
194
|
+
interrupt: interrupt,
|
|
195
|
+
attributes: attributes,
|
|
196
|
+
content: content,
|
|
197
|
+
icount: indent_count,
|
|
198
|
+
indents: indent_spaces,
|
|
199
|
+
indent: indent
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function format(append, elem, end) {
|
|
204
|
+
if (typeof elem !== 'object') {
|
|
205
|
+
append(false, elem);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const len = elem.interrupt ? 1 : elem.content.length;
|
|
210
|
+
|
|
211
|
+
function proceed() {
|
|
212
|
+
while (elem.content.length) {
|
|
213
|
+
const value = elem.content.shift();
|
|
214
|
+
|
|
215
|
+
if (value === undefined) {continue;}
|
|
216
|
+
if (interrupt(value)) {return;}
|
|
217
|
+
|
|
218
|
+
format(append, value);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
append(false, (len > 1 ? elem.indents : '')
|
|
222
|
+
+ (elem.name ? `</${elem.name}>` : '')
|
|
223
|
+
+ (elem.indent && !end ? '\n' : ''));
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function interrupt(value) {
|
|
227
|
+
if (value.interrupt) {
|
|
228
|
+
value.interrupt.append = append;
|
|
229
|
+
value.interrupt.end = proceed;
|
|
230
|
+
value.interrupt = false;
|
|
231
|
+
append(true);
|
|
232
|
+
return true;
|
|
233
|
+
}
|
|
234
|
+
return false;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
append(false, elem.indents
|
|
238
|
+
+ (elem.name ? `<${elem.name}` : '')
|
|
239
|
+
+ (elem.attributes.length ? ` ${elem.attributes.join(' ')}` : '')
|
|
240
|
+
+ (len ? (elem.name ? '>' : '') : (elem.name ? '/>' : ''))
|
|
241
|
+
+ (elem.indent && len > 1 ? '\n' : ''));
|
|
242
|
+
|
|
243
|
+
if (!len) {
|
|
244
|
+
append(false, elem.indent ? '\n' : '');
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if (!interrupt(elem)) {
|
|
249
|
+
proceed();
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function attribute(key, value) {
|
|
254
|
+
return `${key}=` + `"${escapeForXML(value)}"`;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
module.exports = xml;
|
|
258
|
+
module.exports.element = module.exports.Element = element;
|