openapi-explorer 2.2.717 → 2.2.720
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.
@@ -102,7 +102,8 @@ export function getTypeInfo(parameter, options = {
|
|
102
102
|
export function getSampleValueByType(schemaObj, fallbackPropertyName, skipExampleIds) {
|
103
103
|
var _Object$values$0$valu, _Object$values$, _schemaObj$type;
|
104
104
|
const example = Array.isArray(schemaObj.examples) ? schemaObj.examples[0] : (_Object$values$0$valu = (_Object$values$ = Object.values(schemaObj.examples || {})[0]) === null || _Object$values$ === void 0 ? void 0 : _Object$values$.value) !== null && _Object$values$0$valu !== void 0 ? _Object$values$0$valu : schemaObj.example;
|
105
|
-
|
105
|
+
const propertyName = fallbackPropertyName || 'string';
|
106
|
+
if (skipExampleIds && typeof example === 'string' && propertyName.match(/id$/i)) {
|
106
107
|
return '';
|
107
108
|
}
|
108
109
|
if (typeof example !== 'undefined') {
|
@@ -137,16 +138,16 @@ export function getSampleValueByType(schemaObj, fallbackPropertyName, skipExampl
|
|
137
138
|
if (typeValue.match(/^null/g)) {
|
138
139
|
return null;
|
139
140
|
}
|
140
|
-
if (skipExampleIds && typeValue.match(/^string/g) &&
|
141
|
+
if (skipExampleIds && typeValue.match(/^string/g) && propertyName.match(/id$/i)) {
|
141
142
|
return '';
|
142
143
|
}
|
143
144
|
if (typeValue.match(/^string/g)) {
|
144
145
|
if (schemaObj.pattern) {
|
145
146
|
const examplePattern = schemaObj.pattern.replace(/[+*](?![^\][]*[\]])/g, '{8}').replace(/\{\d*,(\d+)?\}/g, '{8}');
|
146
147
|
try {
|
147
|
-
return new RandExp(examplePattern).gen() ||
|
148
|
+
return new RandExp(examplePattern).gen() || propertyName;
|
148
149
|
} catch (error) {
|
149
|
-
return
|
150
|
+
return propertyName;
|
150
151
|
}
|
151
152
|
}
|
152
153
|
if (schemaObj.format) {
|
@@ -183,7 +184,7 @@ export function getSampleValueByType(schemaObj, fallbackPropertyName, skipExampl
|
|
183
184
|
return schemaObj.format;
|
184
185
|
}
|
185
186
|
} else {
|
186
|
-
return
|
187
|
+
return propertyName;
|
187
188
|
}
|
188
189
|
}
|
189
190
|
// If type cannot be determined
|
@@ -372,7 +373,11 @@ export function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '
|
|
372
373
|
}
|
373
374
|
});
|
374
375
|
const obj = schemaInObjectNotation(schema, options, 0);
|
375
|
-
|
376
|
+
const resultObj = typeof obj === 'object' && !Array.isArray(obj) ? obj : {};
|
377
|
+
// These are the only valuable properties from allOf, everything else isn't going to be available, otherwise fallback to whatever was there from the children objects
|
378
|
+
resultObj['::title'] = schema.title || resultObj['::title'];
|
379
|
+
resultObj['::description'] = schema.description || resultObj['::description'];
|
380
|
+
return Object.assign({}, objWithAllProps, resultObj);
|
376
381
|
}
|
377
382
|
if (anyOf || oneOf) {
|
378
383
|
const objWithAnyOfProps = {};
|
@@ -111,7 +111,8 @@ function getTypeInfo(parameter, options = {
|
|
111
111
|
function getSampleValueByType(schemaObj, fallbackPropertyName, skipExampleIds) {
|
112
112
|
var _Object$values$0$valu, _Object$values$, _schemaObj$type;
|
113
113
|
const example = Array.isArray(schemaObj.examples) ? schemaObj.examples[0] : (_Object$values$0$valu = (_Object$values$ = Object.values(schemaObj.examples || {})[0]) === null || _Object$values$ === void 0 ? void 0 : _Object$values$.value) !== null && _Object$values$0$valu !== void 0 ? _Object$values$0$valu : schemaObj.example;
|
114
|
-
|
114
|
+
const propertyName = fallbackPropertyName || 'string';
|
115
|
+
if (skipExampleIds && typeof example === 'string' && propertyName.match(/id$/i)) {
|
115
116
|
return '';
|
116
117
|
}
|
117
118
|
if (typeof example !== 'undefined') {
|
@@ -146,16 +147,16 @@ function getSampleValueByType(schemaObj, fallbackPropertyName, skipExampleIds) {
|
|
146
147
|
if (typeValue.match(/^null/g)) {
|
147
148
|
return null;
|
148
149
|
}
|
149
|
-
if (skipExampleIds && typeValue.match(/^string/g) &&
|
150
|
+
if (skipExampleIds && typeValue.match(/^string/g) && propertyName.match(/id$/i)) {
|
150
151
|
return '';
|
151
152
|
}
|
152
153
|
if (typeValue.match(/^string/g)) {
|
153
154
|
if (schemaObj.pattern) {
|
154
155
|
const examplePattern = schemaObj.pattern.replace(/[+*](?![^\][]*[\]])/g, '{8}').replace(/\{\d*,(\d+)?\}/g, '{8}');
|
155
156
|
try {
|
156
|
-
return new _randexp.default(examplePattern).gen() ||
|
157
|
+
return new _randexp.default(examplePattern).gen() || propertyName;
|
157
158
|
} catch (error) {
|
158
|
-
return
|
159
|
+
return propertyName;
|
159
160
|
}
|
160
161
|
}
|
161
162
|
if (schemaObj.format) {
|
@@ -192,7 +193,7 @@ function getSampleValueByType(schemaObj, fallbackPropertyName, skipExampleIds) {
|
|
192
193
|
return schemaObj.format;
|
193
194
|
}
|
194
195
|
} else {
|
195
|
-
return
|
196
|
+
return propertyName;
|
196
197
|
}
|
197
198
|
}
|
198
199
|
// If type cannot be determined
|
@@ -381,7 +382,11 @@ function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '') {
|
|
381
382
|
}
|
382
383
|
});
|
383
384
|
const obj = schemaInObjectNotation(schema, options, 0);
|
384
|
-
|
385
|
+
const resultObj = typeof obj === 'object' && !Array.isArray(obj) ? obj : {};
|
386
|
+
// These are the only valuable properties from allOf, everything else isn't going to be available, otherwise fallback to whatever was there from the children objects
|
387
|
+
resultObj['::title'] = schema.title || resultObj['::title'];
|
388
|
+
resultObj['::description'] = schema.description || resultObj['::description'];
|
389
|
+
return Object.assign({}, objWithAllProps, resultObj);
|
385
390
|
}
|
386
391
|
if (anyOf || oneOf) {
|
387
392
|
const objWithAnyOfProps = {};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "openapi-explorer",
|
3
|
-
"version": "2.2.
|
3
|
+
"version": "2.2.720",
|
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",
|