openapi-explorer 2.4.834 → 2.4.836

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.
@@ -59,7 +59,7 @@ export function getTypeInfo(parameter, options = {
59
59
  info.default = arrayItemDefault;
60
60
  info.allowedValues = typeof schema.const !== 'undefined' && [schema.const] || schema.items.enum || null;
61
61
  }
62
- if (schema.uniqueItems) {
62
+ if (schema.uniqueItems && dataType.match(/array|\[\]/)) {
63
63
  info.constraints.push('Requires unique items');
64
64
  }
65
65
  if (dataType.match(/integer|number/g)) {
@@ -419,6 +419,7 @@ export function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '
419
419
  };
420
420
  resultObj['::title'] = schema.title || '';
421
421
  resultObj['::description'] = schema.description || '';
422
+ resultObj['::deprecated'] = schema.deprecated || false;
422
423
  resultObj['::metadata'] = metadata;
423
424
  return resultObj;
424
425
  }
@@ -445,19 +446,30 @@ export function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '
445
446
  complexTypes.push(v);
446
447
  }
447
448
  });
449
+ // Rendered as one option of several: title, description and deprecation belong to the property itself
450
+ const asPrimitiveOption = type => getTypeInfo({
451
+ ...subSchema,
452
+ type,
453
+ title: undefined,
454
+ description: undefined,
455
+ deprecated: undefined
456
+ }, options);
448
457
  let multiPrimitiveTypes;
449
458
  if (primitiveType.length > 0) {
450
459
  subSchema.type = primitiveType.join('┃');
451
- multiPrimitiveTypes = getTypeInfo(subSchema, options);
452
460
  if (complexTypes.length === 0) {
453
- var _multiPrimitiveTypes;
454
- return `${((_multiPrimitiveTypes = multiPrimitiveTypes) === null || _multiPrimitiveTypes === void 0 ? void 0 : _multiPrimitiveTypes.html) || ''}`;
461
+ var _getTypeInfo;
462
+ return `${((_getTypeInfo = getTypeInfo(subSchema, options)) === null || _getTypeInfo === void 0 ? void 0 : _getTypeInfo.html) || ''}`;
455
463
  }
464
+ multiPrimitiveTypes = asPrimitiveOption(subSchema.type);
456
465
  }
457
466
  if (complexTypes.length > 0) {
458
467
  obj['::link'] = schema.title || '';
459
468
  obj['::circular'] = !!schema.circularReference;
460
469
  obj['::type'] = 'object';
470
+ obj['::title'] = schema.title || '';
471
+ obj['::description'] = schema.description || '';
472
+ obj['::deprecated'] = schema.deprecated || false;
461
473
  const multiTypeOptions = {
462
474
  '::type': 'xxx-of-option'
463
475
  };
@@ -467,23 +479,18 @@ export function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '
467
479
  if (v === 'null') {
468
480
  multiTypeOptions[`::OPTION~${i + 1}`] = 'NULL~|~~|~~|~~|~~|~~|~~|~~|~';
469
481
  } else if ('integer, number, string, boolean,'.includes(`${v},`)) {
470
- subSchema.type = Array.isArray(v) ? v.join('┃') : v;
471
- const primitiveTypeInfo = getTypeInfo(subSchema, options);
482
+ const primitiveTypeInfo = asPrimitiveOption(Array.isArray(v) ? v.join('┃') : v);
472
483
  multiTypeOptions[`::OPTION~${i + 1}`] = primitiveTypeInfo.html;
473
484
  } else if (v === 'object') {
474
485
  // If object type iterate all the properties and create an object-type-option
475
486
  const objTypeOption = {
476
- '::title': schema.title || '',
477
- '::description': schema.description || '',
478
487
  '::flags': {
479
488
  '🆁': schema.readOnly && '🆁',
480
489
  '🆆': schema.writeOnly && '🆆'
481
490
  },
482
491
  '::link': schema.title || '',
483
492
  '::circular': !!schema.circularReference,
484
- '::type': 'object',
485
- '::deprecated': schema.deprecated || false,
486
- '::metadata': metadata
493
+ '::type': 'object'
487
494
  };
488
495
  for (const key in schemaProperties) {
489
496
  var _schema$required;
@@ -502,8 +509,7 @@ export function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '
502
509
  multiTypeOptions[`::OPTION~${i + 1}`] = objTypeOption;
503
510
  } else if (v === 'array') {
504
511
  multiTypeOptions[`::OPTION~${i + 1}`] = {
505
- '::title': schema.title || '',
506
- '::description': schema.description || (arrayItemsSchema === null || arrayItemsSchema === void 0 ? void 0 : arrayItemsSchema.description) || '',
512
+ '::description': (arrayItemsSchema === null || arrayItemsSchema === void 0 ? void 0 : arrayItemsSchema.description) || '',
507
513
  '::flags': {
508
514
  '🆁': schema.readOnly && '🆁',
509
515
  '🆆': schema.writeOnly && '🆆'
@@ -512,10 +518,11 @@ export function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '
512
518
  '::circular': !!schema.circularReference,
513
519
  '::type': 'array',
514
520
  // Array properties are read from the ::props object instead of reading from the keys of this object
515
- '::props': schemaInObjectNotation(Object.assign({}, schema, arrayItemsSchema, {
516
- description: schema.description || (arrayItemsSchema === null || arrayItemsSchema === void 0 ? void 0 : arrayItemsSchema.description)
521
+ '::props': schemaInObjectNotation(Object.assign({}, schema, {
522
+ deprecated: undefined
523
+ }, arrayItemsSchema, {
524
+ description: arrayItemsSchema === null || arrayItemsSchema === void 0 ? void 0 : arrayItemsSchema.description
517
525
  }), options, level + 1),
518
- '::deprecated': schema.deprecated || false,
519
526
  '::metadata': metadata
520
527
  };
521
528
  }
@@ -68,7 +68,7 @@ function getTypeInfo(parameter, options = {
68
68
  info.default = arrayItemDefault;
69
69
  info.allowedValues = typeof schema.const !== 'undefined' && [schema.const] || schema.items.enum || null;
70
70
  }
71
- if (schema.uniqueItems) {
71
+ if (schema.uniqueItems && dataType.match(/array|\[\]/)) {
72
72
  info.constraints.push('Requires unique items');
73
73
  }
74
74
  if (dataType.match(/integer|number/g)) {
@@ -428,6 +428,7 @@ function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '') {
428
428
  };
429
429
  resultObj['::title'] = schema.title || '';
430
430
  resultObj['::description'] = schema.description || '';
431
+ resultObj['::deprecated'] = schema.deprecated || false;
431
432
  resultObj['::metadata'] = metadata;
432
433
  return resultObj;
433
434
  }
@@ -454,19 +455,30 @@ function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '') {
454
455
  complexTypes.push(v);
455
456
  }
456
457
  });
458
+ // Rendered as one option of several: title, description and deprecation belong to the property itself
459
+ const asPrimitiveOption = type => getTypeInfo({
460
+ ...subSchema,
461
+ type,
462
+ title: undefined,
463
+ description: undefined,
464
+ deprecated: undefined
465
+ }, options);
457
466
  let multiPrimitiveTypes;
458
467
  if (primitiveType.length > 0) {
459
468
  subSchema.type = primitiveType.join('┃');
460
- multiPrimitiveTypes = getTypeInfo(subSchema, options);
461
469
  if (complexTypes.length === 0) {
462
- var _multiPrimitiveTypes;
463
- return `${((_multiPrimitiveTypes = multiPrimitiveTypes) === null || _multiPrimitiveTypes === void 0 ? void 0 : _multiPrimitiveTypes.html) || ''}`;
470
+ var _getTypeInfo;
471
+ return `${((_getTypeInfo = getTypeInfo(subSchema, options)) === null || _getTypeInfo === void 0 ? void 0 : _getTypeInfo.html) || ''}`;
464
472
  }
473
+ multiPrimitiveTypes = asPrimitiveOption(subSchema.type);
465
474
  }
466
475
  if (complexTypes.length > 0) {
467
476
  obj['::link'] = schema.title || '';
468
477
  obj['::circular'] = !!schema.circularReference;
469
478
  obj['::type'] = 'object';
479
+ obj['::title'] = schema.title || '';
480
+ obj['::description'] = schema.description || '';
481
+ obj['::deprecated'] = schema.deprecated || false;
470
482
  const multiTypeOptions = {
471
483
  '::type': 'xxx-of-option'
472
484
  };
@@ -476,23 +488,18 @@ function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '') {
476
488
  if (v === 'null') {
477
489
  multiTypeOptions[`::OPTION~${i + 1}`] = 'NULL~|~~|~~|~~|~~|~~|~~|~~|~';
478
490
  } else if ('integer, number, string, boolean,'.includes(`${v},`)) {
479
- subSchema.type = Array.isArray(v) ? v.join('┃') : v;
480
- const primitiveTypeInfo = getTypeInfo(subSchema, options);
491
+ const primitiveTypeInfo = asPrimitiveOption(Array.isArray(v) ? v.join('┃') : v);
481
492
  multiTypeOptions[`::OPTION~${i + 1}`] = primitiveTypeInfo.html;
482
493
  } else if (v === 'object') {
483
494
  // If object type iterate all the properties and create an object-type-option
484
495
  const objTypeOption = {
485
- '::title': schema.title || '',
486
- '::description': schema.description || '',
487
496
  '::flags': {
488
497
  '🆁': schema.readOnly && '🆁',
489
498
  '🆆': schema.writeOnly && '🆆'
490
499
  },
491
500
  '::link': schema.title || '',
492
501
  '::circular': !!schema.circularReference,
493
- '::type': 'object',
494
- '::deprecated': schema.deprecated || false,
495
- '::metadata': metadata
502
+ '::type': 'object'
496
503
  };
497
504
  for (const key in schemaProperties) {
498
505
  var _schema$required;
@@ -511,8 +518,7 @@ function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '') {
511
518
  multiTypeOptions[`::OPTION~${i + 1}`] = objTypeOption;
512
519
  } else if (v === 'array') {
513
520
  multiTypeOptions[`::OPTION~${i + 1}`] = {
514
- '::title': schema.title || '',
515
- '::description': schema.description || (arrayItemsSchema === null || arrayItemsSchema === void 0 ? void 0 : arrayItemsSchema.description) || '',
521
+ '::description': (arrayItemsSchema === null || arrayItemsSchema === void 0 ? void 0 : arrayItemsSchema.description) || '',
516
522
  '::flags': {
517
523
  '🆁': schema.readOnly && '🆁',
518
524
  '🆆': schema.writeOnly && '🆆'
@@ -521,10 +527,11 @@ function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '') {
521
527
  '::circular': !!schema.circularReference,
522
528
  '::type': 'array',
523
529
  // Array properties are read from the ::props object instead of reading from the keys of this object
524
- '::props': schemaInObjectNotation(Object.assign({}, schema, arrayItemsSchema, {
525
- description: schema.description || (arrayItemsSchema === null || arrayItemsSchema === void 0 ? void 0 : arrayItemsSchema.description)
530
+ '::props': schemaInObjectNotation(Object.assign({}, schema, {
531
+ deprecated: undefined
532
+ }, arrayItemsSchema, {
533
+ description: arrayItemsSchema === null || arrayItemsSchema === void 0 ? void 0 : arrayItemsSchema.description
526
534
  }), options, level + 1),
527
- '::deprecated': schema.deprecated || false,
528
535
  '::metadata': metadata
529
536
  };
530
537
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openapi-explorer",
3
- "version": "2.4.834",
3
+ "version": "2.4.836",
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",