openapi-explorer 0.11.475 → 0.11.483

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.
@@ -57,6 +57,8 @@ export default class SchemaTable extends LitElement {
57
57
  }
58
58
 
59
59
  generateTree(data, dataType = 'object', key = '', description = '', schemaLevel = 0, indentLevel = 0) {
60
+ var _keyLabel;
61
+
60
62
  const newSchemaLevel = data['::type'] && data['::type'].startsWith('xxx-of') ? schemaLevel : schemaLevel + 1;
61
63
  const newIndentLevel = dataType === 'xxx-of-option' || data['::type'] === 'xxx-of-option' || key.startsWith('::OPTION') ? indentLevel : indentLevel + 1;
62
64
  const leftPadding = tablePadding * newIndentLevel; // 2 space indentation at each level
@@ -141,7 +143,7 @@ export default class SchemaTable extends LitElement {
141
143
  return undefined;
142
144
  }
143
145
 
144
- return html` <div class="tr primitive"> <div class="td key ${deprecated ? 'deprecated' : ''}" style="padding-left:${leftPadding}px"> ${keyLabel && keyLabel.endsWith('*') ? html`<span class="key-label">${keyLabel.substring(0, keyLabel.length - 1)}</span><span style="color:var(--red)">*</span>` : key.startsWith('::OPTION') ? html`<span class="xxx-of-key">${keyLabel}</span><span class="xxx-of-descr">${keyDescr}</span>` : html`${keyLabel ? html`<span class="key-label"> ${keyLabel}</span>` : html`<span class="xxx-of-descr">${schemaTitle}</span>`}`} </div> <div class="td key-type"> <div>${dataType === 'array' ? '[' : ''}<span class="${cssType}">${format || type}</span>${dataType === 'array' ? ']' : ''}</div> <div class="attributes ${cssType}" style="font-family:var(--font-mono)" title="${readOrWriteOnly === '🆁' && 'Read only attribute' || readOrWriteOnly === '🆆' && 'Write only attribute' || ''}">${readOrWriteOnly}</div> </div> <div class="td key-descr"> ${dataType === 'array' ? html`<span class="m-markdown-small">${unsafeHTML(marked(description))}</span>` : ''} <span class="m-markdown-small" style="font-family:var(--font-mono);vertical-align:middle"> ${unsafeHTML(marked(`${dataType === 'array' && description || `${schemaTitle ? `**${schemaTitle}:**` : ''} ${schemaDescription}` || ''}`))} </span> ${this.schemaDescriptionExpanded ? html` ${constraint ? html`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Constraints: </span>${constraint}</div><br>` : ''} ${defaultValue ? html`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Default: </span>${defaultValue}</div><br>` : ''} ${allowedValues ? html`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Allowed: </span>${allowedValues}</div><br>` : ''} ${pattern ? html`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Pattern: </span>${pattern}</div><br>` : ''} ${example ? html`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Example: </span>${example}</div><br>` : ''}` : ''} </div> </div> `;
146
+ return html` <div class="tr primitive"> <div class="td key ${deprecated ? 'deprecated' : ''}" style="padding-left:${leftPadding}px"> ${(_keyLabel = keyLabel) !== null && _keyLabel !== void 0 && _keyLabel.endsWith('*') ? html`<span class="key-label">${keyLabel.substring(0, keyLabel.length - 1)}</span><span style="color:var(--red)">*</span>` : key.startsWith('::OPTION') ? html`<span class="xxx-of-key">${keyLabel}</span><span class="xxx-of-descr">${keyDescr}</span>` : html`${keyLabel ? html`<span class="key-label"> ${keyLabel}</span>` : html`<span class="xxx-of-descr">${schemaTitle}</span>`}`} </div> <div class="td key-type"> <div>${dataType === 'array' ? '[' : ''}<span class="${cssType}">${format || type}</span>${dataType === 'array' ? ']' : ''}</div> <div class="attributes ${cssType}" style="font-family:var(--font-mono)" title="${readOrWriteOnly === '🆁' && 'Read only attribute' || readOrWriteOnly === '🆆' && 'Write only attribute' || ''}">${readOrWriteOnly}</div> </div> <div class="td key-descr"> ${dataType === 'array' ? html`<span class="m-markdown-small">${unsafeHTML(marked(description))}</span>` : ''} <span class="m-markdown-small" style="font-family:var(--font-mono);vertical-align:middle"> ${unsafeHTML(marked(`${dataType === 'array' && description || `${schemaTitle ? `**${schemaTitle}:**` : ''} ${schemaDescription}` || ''}`))} </span> ${this.schemaDescriptionExpanded ? html` ${constraint ? html`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Constraints: </span>${constraint}</div><br>` : ''} ${defaultValue ? html`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Default: </span>${defaultValue}</div><br>` : ''} ${allowedValues ? html`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Allowed: </span>${allowedValues}</div><br>` : ''} ${pattern ? html`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Pattern: </span>${pattern}</div><br>` : ''} ${example ? html`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Example: </span>${example}</div><br>` : ''}` : ''} </div> </div> `;
145
147
  }
146
148
  /* eslint-enable indent */
147
149
 
@@ -23,7 +23,9 @@ export function getTypeInfo(schema, options = {
23
23
  } else if (schema.type) {
24
24
  const arraySchema = Array.isArray(schema.type) ? schema.type : typeof schema.type === 'string' ? schema.type.split('┃') : schema.type;
25
25
  dataType = Array.isArray(arraySchema) ? arraySchema.filter(s => s !== 'null' || options.includeNulls).join('┃') : schema.type;
26
- dataType = dataType.replace('string', typeof schema.const !== 'undefined' && 'const' || schema.enum && 'enum' || schema.format || 'string');
26
+ ['string', 'number'].forEach(type => {
27
+ dataType = dataType.replace(type, typeof schema.const !== 'undefined' && 'const' || schema.enum && `${type} enum` || schema.format || type);
28
+ });
27
29
 
28
30
  if (schema.nullable && options.includeNulls) {
29
31
  dataType += '┃null';
@@ -37,7 +39,7 @@ export function getTypeInfo(schema, options = {
37
39
  const info = {
38
40
  type: dataType,
39
41
  format: schema.format || ((_schema$items = schema.items) === null || _schema$items === void 0 ? void 0 : _schema$items.format) || '',
40
- cssType: dataType.replace(/┃.*/g, '').replace(/[^a-zA-Z0-9+]/g, '').toLowerCase(),
42
+ cssType: dataType.replace(/┃.*/g, '').replace(/[^a-zA-Z0-9+\s]/g, '').toLowerCase(),
41
43
  pattern: schema.pattern && !schema.enum ? schema.pattern : '',
42
44
  readOrWriteOnly: schema.readOnly && '🆁' || schema.writeOnly && '🆆' || '',
43
45
  deprecated: !!schema.deprecated,
@@ -135,6 +137,10 @@ export function getSampleValueByType(schemaObj, fallbackPropertyName, skipExampl
135
137
  return schemaObj.const;
136
138
  }
137
139
 
140
+ if (schemaObj.enum) {
141
+ return schemaObj.enum[0];
142
+ }
143
+
138
144
  if (typeValue.match(/^integer|^number/g)) {
139
145
  const multipleOf = Number.isNaN(Number(schemaObj.multipleOf)) ? undefined : Number(schemaObj.multipleOf);
140
146
  const maximum = Number.isNaN(Number(schemaObj.maximum)) ? undefined : Number(schemaObj.maximum);
@@ -156,10 +162,6 @@ export function getSampleValueByType(schemaObj, fallbackPropertyName, skipExampl
156
162
  }
157
163
 
158
164
  if (typeValue.match(/^string/g)) {
159
- if (schemaObj.enum) {
160
- return schemaObj.enum[0];
161
- }
162
-
163
165
  if (schemaObj.pattern) {
164
166
  const examplePattern = schemaObj.pattern.replace(/[+*](?![^\][]*[\]])/g, '{8}').replace(/\{\d*,(\d+)?\}/g, '{8}');
165
167
  return expandN(examplePattern, 1)[0] || fallbackPropertyName || 'string';
@@ -525,7 +527,9 @@ export function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '
525
527
  };
526
528
 
527
529
  for (const key in schema.properties) {
528
- if (schema.required && schema.required.includes(key)) {
530
+ var _schema$required;
531
+
532
+ if (!schema.deprecated && !schema.properties[key].deprecated && (_schema$required = schema.required) !== null && _schema$required !== void 0 && _schema$required.includes(key)) {
529
533
  objTypeOption[`${key}*`] = schemaInObjectNotation(schema.properties[key], options, level + 1);
530
534
  } else {
531
535
  objTypeOption[key] = schemaInObjectNotation(schema.properties[key], options, level + 1);
@@ -568,7 +572,9 @@ export function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '
568
572
  obj['::deprecated'] = schema.deprecated || false;
569
573
 
570
574
  for (const key in schema.properties) {
571
- if (schema.required && schema.required.includes(key)) {
575
+ var _schema$required2;
576
+
577
+ if (!schema.deprecated && !schema.properties[key].deprecated && (_schema$required2 = schema.required) !== null && _schema$required2 !== void 0 && _schema$required2.includes(key)) {
572
578
  obj[`${key}*`] = schemaInObjectNotation(schema.properties[key], options, level + 1);
573
579
  } else {
574
580
  obj[key] = schemaInObjectNotation(schema.properties[key], options, level + 1);
@@ -70,6 +70,8 @@ class SchemaTable extends _lit.LitElement {
70
70
  }
71
71
 
72
72
  generateTree(data, dataType = 'object', key = '', description = '', schemaLevel = 0, indentLevel = 0) {
73
+ var _keyLabel;
74
+
73
75
  const newSchemaLevel = data['::type'] && data['::type'].startsWith('xxx-of') ? schemaLevel : schemaLevel + 1;
74
76
  const newIndentLevel = dataType === 'xxx-of-option' || data['::type'] === 'xxx-of-option' || key.startsWith('::OPTION') ? indentLevel : indentLevel + 1;
75
77
  const leftPadding = tablePadding * newIndentLevel; // 2 space indentation at each level
@@ -154,7 +156,7 @@ class SchemaTable extends _lit.LitElement {
154
156
  return undefined;
155
157
  }
156
158
 
157
- return (0, _lit.html)` <div class="tr primitive"> <div class="td key ${deprecated ? 'deprecated' : ''}" style="padding-left:${leftPadding}px"> ${keyLabel && keyLabel.endsWith('*') ? (0, _lit.html)`<span class="key-label">${keyLabel.substring(0, keyLabel.length - 1)}</span><span style="color:var(--red)">*</span>` : key.startsWith('::OPTION') ? (0, _lit.html)`<span class="xxx-of-key">${keyLabel}</span><span class="xxx-of-descr">${keyDescr}</span>` : (0, _lit.html)`${keyLabel ? (0, _lit.html)`<span class="key-label"> ${keyLabel}</span>` : (0, _lit.html)`<span class="xxx-of-descr">${schemaTitle}</span>`}`} </div> <div class="td key-type"> <div>${dataType === 'array' ? '[' : ''}<span class="${cssType}">${format || type}</span>${dataType === 'array' ? ']' : ''}</div> <div class="attributes ${cssType}" style="font-family:var(--font-mono)" title="${readOrWriteOnly === '🆁' && 'Read only attribute' || readOrWriteOnly === '🆆' && 'Write only attribute' || ''}">${readOrWriteOnly}</div> </div> <div class="td key-descr"> ${dataType === 'array' ? (0, _lit.html)`<span class="m-markdown-small">${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(description))}</span>` : ''} <span class="m-markdown-small" style="font-family:var(--font-mono);vertical-align:middle"> ${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(`${dataType === 'array' && description || `${schemaTitle ? `**${schemaTitle}:**` : ''} ${schemaDescription}` || ''}`))} </span> ${this.schemaDescriptionExpanded ? (0, _lit.html)` ${constraint ? (0, _lit.html)`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Constraints: </span>${constraint}</div><br>` : ''} ${defaultValue ? (0, _lit.html)`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Default: </span>${defaultValue}</div><br>` : ''} ${allowedValues ? (0, _lit.html)`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Allowed: </span>${allowedValues}</div><br>` : ''} ${pattern ? (0, _lit.html)`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Pattern: </span>${pattern}</div><br>` : ''} ${example ? (0, _lit.html)`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Example: </span>${example}</div><br>` : ''}` : ''} </div> </div> `;
159
+ return (0, _lit.html)` <div class="tr primitive"> <div class="td key ${deprecated ? 'deprecated' : ''}" style="padding-left:${leftPadding}px"> ${(_keyLabel = keyLabel) !== null && _keyLabel !== void 0 && _keyLabel.endsWith('*') ? (0, _lit.html)`<span class="key-label">${keyLabel.substring(0, keyLabel.length - 1)}</span><span style="color:var(--red)">*</span>` : key.startsWith('::OPTION') ? (0, _lit.html)`<span class="xxx-of-key">${keyLabel}</span><span class="xxx-of-descr">${keyDescr}</span>` : (0, _lit.html)`${keyLabel ? (0, _lit.html)`<span class="key-label"> ${keyLabel}</span>` : (0, _lit.html)`<span class="xxx-of-descr">${schemaTitle}</span>`}`} </div> <div class="td key-type"> <div>${dataType === 'array' ? '[' : ''}<span class="${cssType}">${format || type}</span>${dataType === 'array' ? ']' : ''}</div> <div class="attributes ${cssType}" style="font-family:var(--font-mono)" title="${readOrWriteOnly === '🆁' && 'Read only attribute' || readOrWriteOnly === '🆆' && 'Write only attribute' || ''}">${readOrWriteOnly}</div> </div> <div class="td key-descr"> ${dataType === 'array' ? (0, _lit.html)`<span class="m-markdown-small">${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(description))}</span>` : ''} <span class="m-markdown-small" style="font-family:var(--font-mono);vertical-align:middle"> ${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(`${dataType === 'array' && description || `${schemaTitle ? `**${schemaTitle}:**` : ''} ${schemaDescription}` || ''}`))} </span> ${this.schemaDescriptionExpanded ? (0, _lit.html)` ${constraint ? (0, _lit.html)`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Constraints: </span>${constraint}</div><br>` : ''} ${defaultValue ? (0, _lit.html)`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Default: </span>${defaultValue}</div><br>` : ''} ${allowedValues ? (0, _lit.html)`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Allowed: </span>${allowedValues}</div><br>` : ''} ${pattern ? (0, _lit.html)`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Pattern: </span>${pattern}</div><br>` : ''} ${example ? (0, _lit.html)`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Example: </span>${example}</div><br>` : ''}` : ''} </div> </div> `;
158
160
  }
159
161
  /* eslint-enable indent */
160
162
 
@@ -38,7 +38,9 @@ function getTypeInfo(schema, options = {
38
38
  } else if (schema.type) {
39
39
  const arraySchema = Array.isArray(schema.type) ? schema.type : typeof schema.type === 'string' ? schema.type.split('┃') : schema.type;
40
40
  dataType = Array.isArray(arraySchema) ? arraySchema.filter(s => s !== 'null' || options.includeNulls).join('┃') : schema.type;
41
- dataType = dataType.replace('string', typeof schema.const !== 'undefined' && 'const' || schema.enum && 'enum' || schema.format || 'string');
41
+ ['string', 'number'].forEach(type => {
42
+ dataType = dataType.replace(type, typeof schema.const !== 'undefined' && 'const' || schema.enum && `${type} enum` || schema.format || type);
43
+ });
42
44
 
43
45
  if (schema.nullable && options.includeNulls) {
44
46
  dataType += '┃null';
@@ -52,7 +54,7 @@ function getTypeInfo(schema, options = {
52
54
  const info = {
53
55
  type: dataType,
54
56
  format: schema.format || ((_schema$items = schema.items) === null || _schema$items === void 0 ? void 0 : _schema$items.format) || '',
55
- cssType: dataType.replace(/┃.*/g, '').replace(/[^a-zA-Z0-9+]/g, '').toLowerCase(),
57
+ cssType: dataType.replace(/┃.*/g, '').replace(/[^a-zA-Z0-9+\s]/g, '').toLowerCase(),
56
58
  pattern: schema.pattern && !schema.enum ? schema.pattern : '',
57
59
  readOrWriteOnly: schema.readOnly && '🆁' || schema.writeOnly && '🆆' || '',
58
60
  deprecated: !!schema.deprecated,
@@ -151,6 +153,10 @@ function getSampleValueByType(schemaObj, fallbackPropertyName, skipExampleString
151
153
  return schemaObj.const;
152
154
  }
153
155
 
156
+ if (schemaObj.enum) {
157
+ return schemaObj.enum[0];
158
+ }
159
+
154
160
  if (typeValue.match(/^integer|^number/g)) {
155
161
  const multipleOf = Number.isNaN(Number(schemaObj.multipleOf)) ? undefined : Number(schemaObj.multipleOf);
156
162
  const maximum = Number.isNaN(Number(schemaObj.maximum)) ? undefined : Number(schemaObj.maximum);
@@ -172,10 +178,6 @@ function getSampleValueByType(schemaObj, fallbackPropertyName, skipExampleString
172
178
  }
173
179
 
174
180
  if (typeValue.match(/^string/g)) {
175
- if (schemaObj.enum) {
176
- return schemaObj.enum[0];
177
- }
178
-
179
181
  if (schemaObj.pattern) {
180
182
  const examplePattern = schemaObj.pattern.replace(/[+*](?![^\][]*[\]])/g, '{8}').replace(/\{\d*,(\d+)?\}/g, '{8}');
181
183
  return (0, _regexToStrings.expandN)(examplePattern, 1)[0] || fallbackPropertyName || 'string';
@@ -542,7 +544,9 @@ function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '') {
542
544
  };
543
545
 
544
546
  for (const key in schema.properties) {
545
- if (schema.required && schema.required.includes(key)) {
547
+ var _schema$required;
548
+
549
+ if (!schema.deprecated && !schema.properties[key].deprecated && (_schema$required = schema.required) !== null && _schema$required !== void 0 && _schema$required.includes(key)) {
546
550
  objTypeOption[`${key}*`] = schemaInObjectNotation(schema.properties[key], options, level + 1);
547
551
  } else {
548
552
  objTypeOption[key] = schemaInObjectNotation(schema.properties[key], options, level + 1);
@@ -585,7 +589,9 @@ function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '') {
585
589
  obj['::deprecated'] = schema.deprecated || false;
586
590
 
587
591
  for (const key in schema.properties) {
588
- if (schema.required && schema.required.includes(key)) {
592
+ var _schema$required2;
593
+
594
+ if (!schema.deprecated && !schema.properties[key].deprecated && (_schema$required2 = schema.required) !== null && _schema$required2 !== void 0 && _schema$required2.includes(key)) {
589
595
  obj[`${key}*`] = schemaInObjectNotation(schema.properties[key], options, level + 1);
590
596
  } else {
591
597
  obj[key] = schemaInObjectNotation(schema.properties[key], options, level + 1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openapi-explorer",
3
- "version": "0.11.475",
3
+ "version": "0.11.483",
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",