openapi-explorer 0.9.359 → 0.9.364

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.
Files changed (32) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/dist/browser/openapi-explorer.min.js +5 -5
  3. package/dist/browser/openapi-explorer.min.js.map +1 -1
  4. package/dist/es/components/api-request.js +4 -8
  5. package/dist/es/components/api-response.js +4 -8
  6. package/dist/es/components/schema-table.js +3 -6
  7. package/dist/es/components/schema-tree.js +4 -7
  8. package/dist/es/openapi-explorer.js +0 -7
  9. package/dist/es/templates/callback-template.js +1 -1
  10. package/dist/es/templates/code-samples-template.js +1 -1
  11. package/dist/es/templates/components-template.js +2 -2
  12. package/dist/es/templates/endpoint-template.js +2 -2
  13. package/dist/es/templates/expanded-endpoint-template.js +2 -2
  14. package/dist/es/templates/overview-template.js +1 -1
  15. package/dist/es/templates/security-scheme-template.js +1 -1
  16. package/dist/es/templates/server-template.js +1 -1
  17. package/dist/es/utils/schema-utils.js +33 -50
  18. package/dist/lib/components/api-request.js +4 -8
  19. package/dist/lib/components/api-response.js +4 -8
  20. package/dist/lib/components/schema-table.js +3 -6
  21. package/dist/lib/components/schema-tree.js +4 -7
  22. package/dist/lib/openapi-explorer.js +0 -7
  23. package/dist/lib/templates/callback-template.js +1 -1
  24. package/dist/lib/templates/code-samples-template.js +1 -1
  25. package/dist/lib/templates/components-template.js +2 -2
  26. package/dist/lib/templates/endpoint-template.js +2 -2
  27. package/dist/lib/templates/expanded-endpoint-template.js +2 -2
  28. package/dist/lib/templates/overview-template.js +1 -1
  29. package/dist/lib/templates/security-scheme-template.js +1 -1
  30. package/dist/lib/templates/server-template.js +1 -1
  31. package/dist/lib/utils/schema-utils.js +33 -50
  32. package/package.json +3 -3
@@ -375,22 +375,22 @@ function getExampleValuesFromSchemaRecursive(schema, config = {}) {
375
375
  */
376
376
 
377
377
 
378
- function schemaInObjectNotation(schema, obj, level = 0, suffix = '') {
379
- if (!schema) {
378
+ function schemaInObjectNotation(rawSchema, _, level = 0, suffix = '') {
379
+ if (!rawSchema) {
380
380
  return undefined;
381
381
  }
382
382
 
383
- if (schema.allOf) {
383
+ const {
384
+ allOf,
385
+ oneOf,
386
+ anyOf,
387
+ ...schema
388
+ } = rawSchema;
389
+
390
+ if (allOf) {
391
+ // If allOf is an array of multiple elements, then all the keys makes a single object
384
392
  const objWithAllProps = {};
385
-
386
- if (schema.allOf.length === 1 && !schema.allOf[0].properties && !schema.allOf[0].items) {
387
- // If allOf has single item and the type is not an object or array, then its a primitive
388
- const tempSchema = schema.allOf[0];
389
- return `${getTypeInfo(tempSchema).html}`;
390
- } // If allOf is an array of multiple elements, then all the keys makes a single object
391
-
392
-
393
- schema.allOf.map((v, i) => {
393
+ allOf.map((v, i) => {
394
394
  if (v.type === 'object' || v.properties || v.allOf || v.anyOf || v.oneOf) {
395
395
  const propSuffix = (v.anyOf || v.oneOf) && i > 0 ? i : '';
396
396
  const partialObj = schemaInObjectNotation(v, {}, level + 1, propSuffix);
@@ -403,33 +403,12 @@ function schemaInObjectNotation(schema, obj, level = 0, suffix = '') {
403
403
  const typeObj = getTypeInfo(v);
404
404
  objWithAllProps[prop] = `${typeObj.html}`;
405
405
  }
406
- }); // eslint-disable-next-line no-param-reassign
407
-
408
- obj = objWithAllProps;
409
- } else if (schema.anyOf || schema.oneOf) {
410
- obj['::description'] = schema.description || ''; // 1. First iterate the regular properties
411
-
412
- if (schema.type === 'object' || schema.properties) {
413
- obj['::description'] = schema.description || '';
414
- obj['::flags'] = {
415
- '🆁': schema.readOnly && '🆁',
416
- '🆆': schema.writeOnly && '🆆'
417
- };
418
- obj['::type'] = 'object'; // obj['::deprecated'] = schema.deprecated || false;
419
-
420
- for (const key in schema.properties) {
421
- if (schema.required && schema.required.includes(key)) {
422
- obj[`${key}*`] = schemaInObjectNotation(schema.properties[key], {}, level + 1);
423
- } else {
424
- obj[key] = schemaInObjectNotation(schema.properties[key], {}, level + 1);
425
- }
426
- }
427
- } // 2. Then show allof/anyof objects
428
-
429
-
406
+ });
407
+ const obj = schemaInObjectNotation(schema, {}, 0);
408
+ return Object.assign({}, objWithAllProps, typeof obj === 'object' && !Array.isArray(obj) ? obj : {});
409
+ } else if (anyOf || oneOf) {
430
410
  const objWithAnyOfProps = {};
431
- const xxxOf = schema.anyOf ? 'anyOf' : 'oneOf';
432
- schema[xxxOf].forEach((v, index) => {
411
+ (anyOf || oneOf || []).forEach((v, index) => {
433
412
  if (v.type === 'object' || v.properties || v.allOf || v.anyOf || v.oneOf) {
434
413
  const partialObj = schemaInObjectNotation(v, {});
435
414
  objWithAnyOfProps[`::OPTION~${index + 1}${v.title ? `~${v.title}` : ''}`] = partialObj;
@@ -445,11 +424,15 @@ function schemaInObjectNotation(schema, obj, level = 0, suffix = '') {
445
424
  objWithAnyOfProps['::type'] = 'xxx-of-option';
446
425
  }
447
426
  });
448
- obj[schema.anyOf ? `::ANY~OF ${suffix}` : `::ONE~OF ${suffix}`] = objWithAnyOfProps;
449
- obj['::type'] = 'xxx-of';
427
+ const obj = schemaInObjectNotation(schema, {}, 0);
428
+ const resultObj = typeof obj === 'object' && !Array.isArray(obj) ? obj : {};
429
+ resultObj[anyOf ? `::ANY~OF ${suffix}` : `::ONE~OF ${suffix}`] = objWithAnyOfProps;
430
+ resultObj['::type'] = 'xxx-of';
431
+ return resultObj;
450
432
  } else if (Array.isArray(schema.type)) {
451
- // 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
433
+ const obj = {}; // 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
452
434
  // Clone the schema - as it will be modified to replace multi-data-types with one-of;
435
+
453
436
  const subSchema = JSON.parse(JSON.stringify(schema));
454
437
  const primitiveType = [];
455
438
  const complexTypes = [];
@@ -532,7 +515,10 @@ function schemaInObjectNotation(schema, obj, level = 0, suffix = '') {
532
515
  multiTypeOptions[`::OPTION~${complexTypes.length + 1}`] = multiPrimitiveTypes && multiPrimitiveTypes.html || '';
533
516
  obj['::ONE~OF'] = multiTypeOptions;
534
517
  }
518
+
519
+ return obj;
535
520
  } else if (schema.type === 'object' || schema.properties) {
521
+ const obj = {};
536
522
  obj['::title'] = schema.title || '';
537
523
  obj['::description'] = schema.description || '';
538
524
  obj['::flags'] = {
@@ -553,8 +539,11 @@ function schemaInObjectNotation(schema, obj, level = 0, suffix = '') {
553
539
  if (schema.additionalProperties) {
554
540
  obj['<any-key>'] = schemaInObjectNotation(schema.additionalProperties, {});
555
541
  }
542
+
543
+ return obj;
556
544
  } else if (schema.type === 'array' || schema.items) {
557
545
  // If Array
546
+ const obj = {};
558
547
  obj['::title'] = schema.title || '';
559
548
  obj['::description'] = schema.description ? schema.description : schema.items && schema.items.description ? `array&lt;${schema.items.description}&gt;` : '';
560
549
  obj['::flags'] = {
@@ -568,17 +557,11 @@ function schemaInObjectNotation(schema, obj, level = 0, suffix = '') {
568
557
  readOnly: schema.readOnly,
569
558
  writeOnly: schema.writeOnly
570
559
  }, schema.items), {}, level + 1);
571
- } else {
572
- const typeObj = getTypeInfo(schema);
573
-
574
- if (typeObj && typeObj.html) {
575
- return `${typeObj.html}`;
576
- }
577
-
578
- return '';
560
+ return obj;
579
561
  }
580
562
 
581
- return obj;
563
+ const typeObj = getTypeInfo(schema);
564
+ return `${(typeObj === null || typeObj === void 0 ? void 0 : typeObj.html) || ''}`;
582
565
  }
583
566
  /* Create Example object */
584
567
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openapi-explorer",
3
- "version": "0.9.359",
3
+ "version": "0.9.364",
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": {
@@ -50,8 +50,8 @@
50
50
  "buffer": "^6.0.3",
51
51
  "color": "^4.2.3",
52
52
  "create-hash": "^1.2.0",
53
- "lit-element": "2.4.0",
54
- "lit-html": "^1.1.1",
53
+ "lit-element": "^3.2.2",
54
+ "lit-html": "^2.3.1",
55
55
  "lodash.clonedeep": "^4.5.0",
56
56
  "marked": "^4.0.16",
57
57
  "mime-db": "^1.52.0",