openapi-explorer 1.0.557 → 1.0.561
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 +4 -4
- package/dist/browser/openapi-explorer.min.js.map +1 -1
- package/dist/es/components/api-request.js +2 -7
- package/dist/es/components/request-form-table.js +3 -3
- package/dist/es/components/schema-table.js +3 -8
- package/dist/es/components/schema-tree.js +3 -3
- package/dist/es/utils/common-utils.js +6 -2
- package/dist/es/utils/schema-utils.js +57 -38
- package/dist/lib/components/api-request.js +2 -7
- package/dist/lib/components/request-form-table.js +3 -3
- package/dist/lib/components/schema-table.js +3 -8
- package/dist/lib/components/schema-tree.js +3 -3
- package/dist/lib/utils/common-utils.js +6 -2
- package/dist/lib/utils/schema-utils.js +57 -38
- package/package.json +1 -1
|
@@ -63,7 +63,7 @@ function getTypeInfo(schema, options = {
|
|
|
63
63
|
default: schema.default || '',
|
|
64
64
|
title: schema.title || '',
|
|
65
65
|
description: schema.description || '',
|
|
66
|
-
|
|
66
|
+
constraints: [],
|
|
67
67
|
allowedValues: (_schema$const = schema.const) !== null && _schema$const !== void 0 ? _schema$const : Array.isArray(schema.enum) ? schema.enum.join('┃') : '',
|
|
68
68
|
arrayType: ''
|
|
69
69
|
};
|
|
@@ -78,6 +78,10 @@ function getTypeInfo(schema, options = {
|
|
|
78
78
|
info.allowedValues = (_schema$const2 = schema.const) !== null && _schema$const2 !== void 0 ? _schema$const2 : Array.isArray(schema.items.enum) ? schema.items.enum.join('┃') : '';
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
if (schema.uniqueItems) {
|
|
82
|
+
info.constraints.push('Requires unique items');
|
|
83
|
+
}
|
|
84
|
+
|
|
81
85
|
if (dataType.match(/integer|number/g)) {
|
|
82
86
|
var _schema$minimum, _schema$maximum;
|
|
83
87
|
|
|
@@ -87,21 +91,21 @@ function getTypeInfo(schema, options = {
|
|
|
87
91
|
const rightBound = schema.maximum !== undefined ? ']' : ')';
|
|
88
92
|
|
|
89
93
|
if (typeof minimum === 'number' || typeof maximum === 'number') {
|
|
90
|
-
info.
|
|
94
|
+
info.constraints.push(`Range: ${leftBound}${minimum !== null && minimum !== void 0 ? minimum : ''},${maximum !== null && maximum !== void 0 ? maximum : ''}${rightBound}`);
|
|
91
95
|
}
|
|
92
96
|
|
|
93
97
|
if (schema.multipleOf !== undefined) {
|
|
94
|
-
info.
|
|
98
|
+
info.constraints.push(`Multiples: ${schema.multipleOf}`);
|
|
95
99
|
}
|
|
96
100
|
}
|
|
97
101
|
|
|
98
102
|
if (dataType.match(/string/g)) {
|
|
99
103
|
if (schema.minLength !== undefined && schema.maxLength !== undefined) {
|
|
100
|
-
info.
|
|
104
|
+
info.constraints.push(`Min length: ${schema.minLength}, Max length: ${schema.maxLength}`);
|
|
101
105
|
} else if (schema.minLength !== undefined) {
|
|
102
|
-
info.
|
|
106
|
+
info.constraints.push(`Min length: ${schema.minLength}`);
|
|
103
107
|
} else if (schema.maxLength !== undefined) {
|
|
104
|
-
info.
|
|
108
|
+
info.constraints.push(`Max length: ${schema.maxLength}`);
|
|
105
109
|
}
|
|
106
110
|
}
|
|
107
111
|
|
|
@@ -110,7 +114,7 @@ function getTypeInfo(schema, options = {
|
|
|
110
114
|
format: info.format,
|
|
111
115
|
cssType: info.cssType,
|
|
112
116
|
readOrWriteOnly: info.readOrWriteOnly,
|
|
113
|
-
|
|
117
|
+
constraints: info.constraints,
|
|
114
118
|
defaultValue: info.default,
|
|
115
119
|
example: info.example,
|
|
116
120
|
allowedValues: info.allowedValues,
|
|
@@ -417,8 +421,23 @@ function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '') {
|
|
|
417
421
|
allOf,
|
|
418
422
|
oneOf,
|
|
419
423
|
anyOf,
|
|
424
|
+
items: arrayItemsSchema,
|
|
425
|
+
properties: schemaProperties,
|
|
426
|
+
patternProperties: schemaPatternProperties,
|
|
420
427
|
...schema
|
|
421
428
|
} = rawSchema;
|
|
429
|
+
const propertyType = schema.type;
|
|
430
|
+
const metadata = {
|
|
431
|
+
constraints: []
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
if (schema.uniqueItems) {
|
|
435
|
+
metadata.constraints.push('Requires unique items');
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
if (typeof schema.minItems === 'number' || typeof schema.maxItems === 'number') {
|
|
439
|
+
metadata.constraints.push(`Length: [${schema.minItems || 0}${schema.maxItems ? ', ' : '+'}${schema.maxItems || ''}]`);
|
|
440
|
+
}
|
|
422
441
|
|
|
423
442
|
if (allOf) {
|
|
424
443
|
// If allOf is an array of multiple elements, then all the keys makes a single object
|
|
@@ -491,8 +510,9 @@ function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '') {
|
|
|
491
510
|
};
|
|
492
511
|
resultObj['::title'] = schema.title || '';
|
|
493
512
|
resultObj['::description'] = schema.description || '';
|
|
513
|
+
resultObj['::metadata'] = metadata;
|
|
494
514
|
return resultObj;
|
|
495
|
-
} else if (Array.isArray(
|
|
515
|
+
} else if (Array.isArray(propertyType)) {
|
|
496
516
|
const obj = {
|
|
497
517
|
'::type': ''
|
|
498
518
|
}; // When a property has multiple types, then check further if any of the types are array or object, if yes then modify the schema using one-of
|
|
@@ -504,7 +524,7 @@ function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '') {
|
|
|
504
524
|
subSchema.type.forEach(v => {
|
|
505
525
|
if (v.match(/integer|number|string|null|boolean/g)) {
|
|
506
526
|
primitiveType.push(v);
|
|
507
|
-
} else if (v === 'array' && typeof (subSchema.items && subSchema.items.type) === 'string' &&
|
|
527
|
+
} else if (v === 'array' && typeof (subSchema.items && subSchema.items.type) === 'string' && arrayItemsSchema && subSchema.items.type.match(/integer|number|string|null|boolean/g)) {
|
|
508
528
|
// Array with primitive types should also be treated as primitive type
|
|
509
529
|
if (subSchema.items.type === 'string' && subSchema.items.format) {
|
|
510
530
|
primitiveType.push(`${subSchema.items.format}[]`);
|
|
@@ -551,16 +571,17 @@ function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '') {
|
|
|
551
571
|
'🆆': schema.writeOnly && '🆆'
|
|
552
572
|
},
|
|
553
573
|
'::type': 'object',
|
|
554
|
-
'::deprecated': schema.deprecated || false
|
|
574
|
+
'::deprecated': schema.deprecated || false,
|
|
575
|
+
'::metadata': metadata
|
|
555
576
|
};
|
|
556
577
|
|
|
557
|
-
for (const key in
|
|
578
|
+
for (const key in schemaProperties) {
|
|
558
579
|
var _schema$required;
|
|
559
580
|
|
|
560
|
-
if (!schema.deprecated && !
|
|
561
|
-
objTypeOption[`${key}*`] = schemaInObjectNotation(
|
|
581
|
+
if (!schema.deprecated && !schemaProperties[key].deprecated && (_schema$required = schema.required) !== null && _schema$required !== void 0 && _schema$required.includes(key)) {
|
|
582
|
+
objTypeOption[`${key}*`] = schemaInObjectNotation(schemaProperties[key], options, level + 1);
|
|
562
583
|
} else {
|
|
563
|
-
objTypeOption[key] = schemaInObjectNotation(
|
|
584
|
+
objTypeOption[key] = schemaInObjectNotation(schemaProperties[key], options, level + 1);
|
|
564
585
|
}
|
|
565
586
|
}
|
|
566
587
|
|
|
@@ -574,10 +595,11 @@ function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '') {
|
|
|
574
595
|
'🆆': schema.writeOnly && '🆆'
|
|
575
596
|
},
|
|
576
597
|
'::type': 'array',
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
598
|
+
// Array properties are read from the ::props object instead of reading from the keys of this object
|
|
599
|
+
// '::props': schemaInObjectNotation(Object.assign({ deprecated: schema.deprecated, readOnly: schema.readOnly, writeOnly: schema.writeOnly }, arrayItemsSchema), options, (level + 1)),
|
|
600
|
+
'::props': schemaInObjectNotation(Object.assign({}, schema, arrayItemsSchema), options, level + 1),
|
|
601
|
+
'::deprecated': schema.deprecated || false,
|
|
602
|
+
'::metadata': metadata
|
|
581
603
|
};
|
|
582
604
|
}
|
|
583
605
|
});
|
|
@@ -586,7 +608,7 @@ function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '') {
|
|
|
586
608
|
}
|
|
587
609
|
|
|
588
610
|
return obj;
|
|
589
|
-
} else if (
|
|
611
|
+
} else if (propertyType === 'object' || schemaProperties) {
|
|
590
612
|
const obj = {
|
|
591
613
|
'::type': ''
|
|
592
614
|
};
|
|
@@ -598,19 +620,20 @@ function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '') {
|
|
|
598
620
|
};
|
|
599
621
|
obj['::type'] = 'object';
|
|
600
622
|
obj['::deprecated'] = schema.deprecated || false;
|
|
623
|
+
obj['::metadata'] = metadata;
|
|
601
624
|
|
|
602
|
-
for (const key in
|
|
625
|
+
for (const key in schemaProperties) {
|
|
603
626
|
var _schema$required2;
|
|
604
627
|
|
|
605
|
-
if (!schema.deprecated && !
|
|
606
|
-
obj[`${key}*`] = schemaInObjectNotation(
|
|
628
|
+
if (!schema.deprecated && !schemaProperties[key].deprecated && (_schema$required2 = schema.required) !== null && _schema$required2 !== void 0 && _schema$required2.includes(key)) {
|
|
629
|
+
obj[`${key}*`] = schemaInObjectNotation(schemaProperties[key], options, level + 1);
|
|
607
630
|
} else {
|
|
608
|
-
obj[key] = schemaInObjectNotation(
|
|
631
|
+
obj[key] = schemaInObjectNotation(schemaProperties[key], options, level + 1);
|
|
609
632
|
}
|
|
610
633
|
}
|
|
611
634
|
|
|
612
|
-
for (const key in
|
|
613
|
-
obj[`<pattern: ${key}>`] = schemaInObjectNotation(
|
|
635
|
+
for (const key in schemaPatternProperties) {
|
|
636
|
+
obj[`<pattern: ${key}>`] = schemaInObjectNotation(schemaPatternProperties[key], options, level + 1);
|
|
614
637
|
}
|
|
615
638
|
|
|
616
639
|
if (schema.additionalProperties) {
|
|
@@ -618,29 +641,25 @@ function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '') {
|
|
|
618
641
|
}
|
|
619
642
|
|
|
620
643
|
return obj;
|
|
621
|
-
} else if (
|
|
622
|
-
var _schema$items2, _schema$items3;
|
|
623
|
-
|
|
644
|
+
} else if (propertyType === 'array' || arrayItemsSchema) {
|
|
624
645
|
// If Array
|
|
625
646
|
const obj = {
|
|
626
647
|
'::type': ''
|
|
627
648
|
};
|
|
628
649
|
obj['::title'] = schema.title || '';
|
|
629
|
-
obj['::description'] = schema.description || (
|
|
650
|
+
obj['::description'] = schema.description || (arrayItemsSchema !== null && arrayItemsSchema !== void 0 && arrayItemsSchema.description ? `array<${arrayItemsSchema.description}>` : '');
|
|
630
651
|
obj['::flags'] = {
|
|
631
652
|
'🆁': schema.readOnly && '🆁',
|
|
632
653
|
'🆆': schema.writeOnly && '🆆'
|
|
633
654
|
};
|
|
634
655
|
obj['::type'] = 'array';
|
|
635
656
|
obj['::deprecated'] = schema.deprecated || false;
|
|
636
|
-
obj['::
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
if ((_schema$items3 = schema.items) !== null && _schema$items3 !== void 0 && _schema$items3.items) {
|
|
643
|
-
obj['::array-type'] = schema.items.items.type;
|
|
657
|
+
obj['::metadata'] = metadata; // Array properties are read from the ::props object instead of reading from the keys of this object
|
|
658
|
+
|
|
659
|
+
obj['::props'] = schemaInObjectNotation(Object.assign({}, schema, arrayItemsSchema), options, level + 1); // obj['::props'] = schemaInObjectNotation(Object.assign({ deprecated: schema.deprecated, readOnly: schema.readOnly, writeOnly: schema.writeOnly }, arrayItemsSchema), options, (level + 1));
|
|
660
|
+
|
|
661
|
+
if (arrayItemsSchema !== null && arrayItemsSchema !== void 0 && arrayItemsSchema.items) {
|
|
662
|
+
obj['::array-type'] = arrayItemsSchema.items.type;
|
|
644
663
|
}
|
|
645
664
|
|
|
646
665
|
return obj;
|
|
@@ -686,7 +705,7 @@ function generateExample(examples, example, schema, rawMimeType, includeReadOnly
|
|
|
686
705
|
|
|
687
706
|
finalExamples.push({
|
|
688
707
|
exampleId: eg,
|
|
689
|
-
exampleSummary: examples[eg].summary ||
|
|
708
|
+
exampleSummary: examples[eg].summary || '',
|
|
690
709
|
exampleDescription: examples[eg].description || '',
|
|
691
710
|
exampleType: mimeType,
|
|
692
711
|
exampleValue: egContent,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openapi-explorer",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.561",
|
|
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
|
"type": "module",
|