openapi-explorer 0.9.361 → 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.
|
@@ -62,7 +62,7 @@ export default class ApiResponse extends LitElement {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
static get styles() {
|
|
65
|
-
return [FontStyles, FlexStyles, TabStyles, TableStyles, InputStyles, BorderStyles, css`.resp-head{vertical-align:middle;padding:16px 0 8px}.resp-head.divider{border-top:1px solid var(--border-color);margin-top:10px}.resp-status{font-weight:700;font-size:calc(var(--font-size-small) + 1px)}.resp-descr{font-size:calc(var(--font-size-small) + 1px)}.top-gap{margin-top:16px}.example-panel{font-size:var(--font-size-small);margin:0}.generic-tree{background:#333;color:#fff}.example-panel.generic-tree{margin-top:8px}pre.generic-tree{border:none;padding:8px 10px 10px}.example-panel select{margin-left:8px;padding-top:8px;min-width:100px;max-width:100%}.example-panel .example{padding
|
|
65
|
+
return [FontStyles, FlexStyles, TabStyles, TableStyles, InputStyles, BorderStyles, css`.resp-head{vertical-align:middle;padding:16px 0 8px}.resp-head.divider{border-top:1px solid var(--border-color);margin-top:10px}.resp-status{font-weight:700;font-size:calc(var(--font-size-small) + 1px)}.resp-descr{font-size:calc(var(--font-size-small) + 1px)}.top-gap{margin-top:16px}.example-panel{font-size:var(--font-size-small);margin:0}.generic-tree{background:#333;color:#fff}.example-panel.generic-tree{margin-top:8px}pre.generic-tree{border:none;padding:8px 10px 10px}.example-panel select{margin-left:8px;padding-top:8px;min-width:100px;max-width:100%}.example-panel .example{padding:0 12px}.focused-mode,.read-mode{padding-top:24px;margin-top:12px;border-top:1px dashed var(--border-color)}`];
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
render() {
|
|
@@ -160,7 +160,7 @@ export default class ApiResponse extends LitElement {
|
|
|
160
160
|
return html` <pre style="color:var(--red)" class="example-panel border-top"> No example provided </pre> `;
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
return html` ${mimeRespDetails.examples.length === 1 ? html` ${mimeRespDetails.examples[0].exampleSummary && mimeRespDetails.examples[0].exampleSummary.length > 80 ? html`<div style="padding:4px 0"> ${mimeRespDetails.examples[0].exampleSummary} </div>` : ''} ${mimeRespDetails.examples[0].exampleDescription ? html`<div class="m-markdown-small" style="padding:4px 0"> ${unsafeHTML(marked(mimeRespDetails.examples[0].exampleDescription || ''))} </div>` : ''} ${mimeRespDetails.examples[0].exampleFormat === 'json' ? html` <json-tree render-style="${this.renderStyle}" .data="${mimeRespDetails.examples[0].exampleValue}" class="example-panel pad-top-8"></json-tree>` : html` <pre class="example-panel generic-tree border-top pad-top-8">${mimeRespDetails.examples[0].exampleValue}</pre> `}` : html` <span class="example-panel generic-tree ${this.renderStyle === 'read' ? 'border pad-8-16' : 'border-top pad-top-8'}"> <select aria-label="response body example" @change="${e => this.onSelectExample(e)}"> ${mimeRespDetails.examples.map(v => html`<option value="${v.exampleId}" ?selected="${v.exampleId === mimeRespDetails.selectedExample}"> ${v.exampleSummary.length > 80 ? v.exampleId : v.exampleSummary} </option>`)} </select> ${mimeRespDetails.examples.map(v => html` <div class="example" data-example="${v.exampleId}" style="display:${v.exampleId === mimeRespDetails.selectedExample ? 'block' : 'none'}"> ${v.exampleSummary && v.exampleSummary.length > 80 ? html`<div style="padding:4px 0"> ${v.exampleSummary} </div>` : ''} ${v.exampleDescription ? html`<div class="m-markdown-small" style="padding:4px 0"> ${unsafeHTML(marked(v.exampleDescription || ''))} </div>` : ''} ${v.exampleFormat === 'json' ? html` <json-tree render-style="${this.renderStyle}" .data="${v.exampleValue}"></json-tree>` : html`<pre class="generic-tree">${v.exampleValue}</pre>`} </div> `)} </span> `} `;
|
|
163
|
+
return html` ${mimeRespDetails.examples.length === 1 ? html` ${mimeRespDetails.examples[0].exampleSummary && mimeRespDetails.examples[0].exampleSummary.length > 80 ? html`<div style="padding:4px 0"> ${mimeRespDetails.examples[0].exampleSummary} </div>` : ''} ${mimeRespDetails.examples[0].exampleDescription ? html`<div class="m-markdown-small" style="padding:4px 0"> ${unsafeHTML(marked(mimeRespDetails.examples[0].exampleDescription || ''))} </div>` : ''} ${mimeRespDetails.examples[0].exampleFormat === 'json' ? html` <json-tree render-style="${this.renderStyle}" .data="${mimeRespDetails.examples[0].exampleValue}" class="example-panel pad-top-8"></json-tree>` : html` <pre class="example-panel generic-tree border-top pad-top-8">${mimeRespDetails.examples[0].exampleValue}</pre> `}` : html` <span class="example-panel generic-tree ${this.renderStyle === 'read' ? 'border pad-8-16' : 'border-top pad-top-8'}"> <select aria-label="response body example" @change="${e => this.onSelectExample(e)}"> ${mimeRespDetails.examples.map(v => html`<option value="${v.exampleId}" ?selected="${v.exampleId === mimeRespDetails.selectedExample}"> ${v.exampleSummary.length > 80 ? v.exampleId : v.exampleSummary} </option>`)} </select> ${mimeRespDetails.examples.map(v => html` <div class="example" data-example="${v.exampleId}" style="display:${v.exampleId === mimeRespDetails.selectedExample ? 'block' : 'none'}"> ${v.exampleSummary && v.exampleSummary.length > 80 ? html`<div style="padding:4px 0"> ${v.exampleSummary} </div>` : ''} ${v.exampleDescription && v.exampleDescription !== v.exampleSummary ? html`<div class="m-markdown-small" style="padding:4px 0"> ${unsafeHTML(marked(v.exampleDescription || ''))} </div>` : ''} ${v.exampleFormat === 'json' ? html` <json-tree render-style="${this.renderStyle}" .data="${v.exampleValue}"></json-tree>` : html`<pre class="generic-tree">${v.exampleValue}</pre>`} </div> `)} </span> `} `;
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
mimeSchemaTemplate(mimeRespDetails) {
|
|
@@ -359,22 +359,22 @@ function getExampleValuesFromSchemaRecursive(schema, config = {}) {
|
|
|
359
359
|
*/
|
|
360
360
|
|
|
361
361
|
|
|
362
|
-
export function schemaInObjectNotation(
|
|
363
|
-
if (!
|
|
362
|
+
export function schemaInObjectNotation(rawSchema, _, level = 0, suffix = '') {
|
|
363
|
+
if (!rawSchema) {
|
|
364
364
|
return undefined;
|
|
365
365
|
}
|
|
366
366
|
|
|
367
|
-
|
|
367
|
+
const {
|
|
368
|
+
allOf,
|
|
369
|
+
oneOf,
|
|
370
|
+
anyOf,
|
|
371
|
+
...schema
|
|
372
|
+
} = rawSchema;
|
|
373
|
+
|
|
374
|
+
if (allOf) {
|
|
375
|
+
// If allOf is an array of multiple elements, then all the keys makes a single object
|
|
368
376
|
const objWithAllProps = {};
|
|
369
|
-
|
|
370
|
-
if (schema.allOf.length === 1 && !schema.allOf[0].properties && !schema.allOf[0].items) {
|
|
371
|
-
// If allOf has single item and the type is not an object or array, then its a primitive
|
|
372
|
-
const tempSchema = schema.allOf[0];
|
|
373
|
-
return `${getTypeInfo(tempSchema).html}`;
|
|
374
|
-
} // If allOf is an array of multiple elements, then all the keys makes a single object
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
schema.allOf.map((v, i) => {
|
|
377
|
+
allOf.map((v, i) => {
|
|
378
378
|
if (v.type === 'object' || v.properties || v.allOf || v.anyOf || v.oneOf) {
|
|
379
379
|
const propSuffix = (v.anyOf || v.oneOf) && i > 0 ? i : '';
|
|
380
380
|
const partialObj = schemaInObjectNotation(v, {}, level + 1, propSuffix);
|
|
@@ -387,33 +387,12 @@ export function schemaInObjectNotation(schema, obj, level = 0, suffix = '') {
|
|
|
387
387
|
const typeObj = getTypeInfo(v);
|
|
388
388
|
objWithAllProps[prop] = `${typeObj.html}`;
|
|
389
389
|
}
|
|
390
|
-
});
|
|
391
|
-
|
|
392
|
-
obj
|
|
393
|
-
} else if (
|
|
394
|
-
obj['::description'] = schema.description || ''; // 1. First iterate the regular properties
|
|
395
|
-
|
|
396
|
-
if (schema.type === 'object' || schema.properties) {
|
|
397
|
-
obj['::description'] = schema.description || '';
|
|
398
|
-
obj['::flags'] = {
|
|
399
|
-
'🆁': schema.readOnly && '🆁',
|
|
400
|
-
'🆆': schema.writeOnly && '🆆'
|
|
401
|
-
};
|
|
402
|
-
obj['::type'] = 'object'; // obj['::deprecated'] = schema.deprecated || false;
|
|
403
|
-
|
|
404
|
-
for (const key in schema.properties) {
|
|
405
|
-
if (schema.required && schema.required.includes(key)) {
|
|
406
|
-
obj[`${key}*`] = schemaInObjectNotation(schema.properties[key], {}, level + 1);
|
|
407
|
-
} else {
|
|
408
|
-
obj[key] = schemaInObjectNotation(schema.properties[key], {}, level + 1);
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
} // 2. Then show allof/anyof objects
|
|
412
|
-
|
|
413
|
-
|
|
390
|
+
});
|
|
391
|
+
const obj = schemaInObjectNotation(schema, {}, 0);
|
|
392
|
+
return Object.assign({}, objWithAllProps, typeof obj === 'object' && !Array.isArray(obj) ? obj : {});
|
|
393
|
+
} else if (anyOf || oneOf) {
|
|
414
394
|
const objWithAnyOfProps = {};
|
|
415
|
-
|
|
416
|
-
schema[xxxOf].forEach((v, index) => {
|
|
395
|
+
(anyOf || oneOf || []).forEach((v, index) => {
|
|
417
396
|
if (v.type === 'object' || v.properties || v.allOf || v.anyOf || v.oneOf) {
|
|
418
397
|
const partialObj = schemaInObjectNotation(v, {});
|
|
419
398
|
objWithAnyOfProps[`::OPTION~${index + 1}${v.title ? `~${v.title}` : ''}`] = partialObj;
|
|
@@ -429,11 +408,15 @@ export function schemaInObjectNotation(schema, obj, level = 0, suffix = '') {
|
|
|
429
408
|
objWithAnyOfProps['::type'] = 'xxx-of-option';
|
|
430
409
|
}
|
|
431
410
|
});
|
|
432
|
-
obj
|
|
433
|
-
obj
|
|
411
|
+
const obj = schemaInObjectNotation(schema, {}, 0);
|
|
412
|
+
const resultObj = typeof obj === 'object' && !Array.isArray(obj) ? obj : {};
|
|
413
|
+
resultObj[anyOf ? `::ANY~OF ${suffix}` : `::ONE~OF ${suffix}`] = objWithAnyOfProps;
|
|
414
|
+
resultObj['::type'] = 'xxx-of';
|
|
415
|
+
return resultObj;
|
|
434
416
|
} else if (Array.isArray(schema.type)) {
|
|
435
|
-
// 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
|
|
417
|
+
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
|
|
436
418
|
// Clone the schema - as it will be modified to replace multi-data-types with one-of;
|
|
419
|
+
|
|
437
420
|
const subSchema = JSON.parse(JSON.stringify(schema));
|
|
438
421
|
const primitiveType = [];
|
|
439
422
|
const complexTypes = [];
|
|
@@ -516,7 +499,10 @@ export function schemaInObjectNotation(schema, obj, level = 0, suffix = '') {
|
|
|
516
499
|
multiTypeOptions[`::OPTION~${complexTypes.length + 1}`] = multiPrimitiveTypes && multiPrimitiveTypes.html || '';
|
|
517
500
|
obj['::ONE~OF'] = multiTypeOptions;
|
|
518
501
|
}
|
|
502
|
+
|
|
503
|
+
return obj;
|
|
519
504
|
} else if (schema.type === 'object' || schema.properties) {
|
|
505
|
+
const obj = {};
|
|
520
506
|
obj['::title'] = schema.title || '';
|
|
521
507
|
obj['::description'] = schema.description || '';
|
|
522
508
|
obj['::flags'] = {
|
|
@@ -537,8 +523,11 @@ export function schemaInObjectNotation(schema, obj, level = 0, suffix = '') {
|
|
|
537
523
|
if (schema.additionalProperties) {
|
|
538
524
|
obj['<any-key>'] = schemaInObjectNotation(schema.additionalProperties, {});
|
|
539
525
|
}
|
|
526
|
+
|
|
527
|
+
return obj;
|
|
540
528
|
} else if (schema.type === 'array' || schema.items) {
|
|
541
529
|
// If Array
|
|
530
|
+
const obj = {};
|
|
542
531
|
obj['::title'] = schema.title || '';
|
|
543
532
|
obj['::description'] = schema.description ? schema.description : schema.items && schema.items.description ? `array<${schema.items.description}>` : '';
|
|
544
533
|
obj['::flags'] = {
|
|
@@ -552,17 +541,11 @@ export function schemaInObjectNotation(schema, obj, level = 0, suffix = '') {
|
|
|
552
541
|
readOnly: schema.readOnly,
|
|
553
542
|
writeOnly: schema.writeOnly
|
|
554
543
|
}, schema.items), {}, level + 1);
|
|
555
|
-
|
|
556
|
-
const typeObj = getTypeInfo(schema);
|
|
557
|
-
|
|
558
|
-
if (typeObj && typeObj.html) {
|
|
559
|
-
return `${typeObj.html}`;
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
return '';
|
|
544
|
+
return obj;
|
|
563
545
|
}
|
|
564
546
|
|
|
565
|
-
|
|
547
|
+
const typeObj = getTypeInfo(schema);
|
|
548
|
+
return `${(typeObj === null || typeObj === void 0 ? void 0 : typeObj.html) || ''}`;
|
|
566
549
|
}
|
|
567
550
|
/* Create Example object */
|
|
568
551
|
|
|
@@ -81,7 +81,7 @@ class ApiResponse extends _litElement.LitElement {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
static get styles() {
|
|
84
|
-
return [_fontStyles.default, _flexStyles.default, _tabStyles.default, _tableStyles.default, _inputStyles.default, _borderStyles.default, (0, _litElement.css)`.resp-head{vertical-align:middle;padding:16px 0 8px}.resp-head.divider{border-top:1px solid var(--border-color);margin-top:10px}.resp-status{font-weight:700;font-size:calc(var(--font-size-small) + 1px)}.resp-descr{font-size:calc(var(--font-size-small) + 1px)}.top-gap{margin-top:16px}.example-panel{font-size:var(--font-size-small);margin:0}.generic-tree{background:#333;color:#fff}.example-panel.generic-tree{margin-top:8px}pre.generic-tree{border:none;padding:8px 10px 10px}.example-panel select{margin-left:8px;padding-top:8px;min-width:100px;max-width:100%}.example-panel .example{padding
|
|
84
|
+
return [_fontStyles.default, _flexStyles.default, _tabStyles.default, _tableStyles.default, _inputStyles.default, _borderStyles.default, (0, _litElement.css)`.resp-head{vertical-align:middle;padding:16px 0 8px}.resp-head.divider{border-top:1px solid var(--border-color);margin-top:10px}.resp-status{font-weight:700;font-size:calc(var(--font-size-small) + 1px)}.resp-descr{font-size:calc(var(--font-size-small) + 1px)}.top-gap{margin-top:16px}.example-panel{font-size:var(--font-size-small);margin:0}.generic-tree{background:#333;color:#fff}.example-panel.generic-tree{margin-top:8px}pre.generic-tree{border:none;padding:8px 10px 10px}.example-panel select{margin-left:8px;padding-top:8px;min-width:100px;max-width:100%}.example-panel .example{padding:0 12px}.focused-mode,.read-mode{padding-top:24px;margin-top:12px;border-top:1px dashed var(--border-color)}`];
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
render() {
|
|
@@ -179,7 +179,7 @@ class ApiResponse extends _litElement.LitElement {
|
|
|
179
179
|
return (0, _litElement.html)` <pre style="color:var(--red)" class="example-panel border-top"> No example provided </pre> `;
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
-
return (0, _litElement.html)` ${mimeRespDetails.examples.length === 1 ? (0, _litElement.html)` ${mimeRespDetails.examples[0].exampleSummary && mimeRespDetails.examples[0].exampleSummary.length > 80 ? (0, _litElement.html)`<div style="padding:4px 0"> ${mimeRespDetails.examples[0].exampleSummary} </div>` : ''} ${mimeRespDetails.examples[0].exampleDescription ? (0, _litElement.html)`<div class="m-markdown-small" style="padding:4px 0"> ${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(mimeRespDetails.examples[0].exampleDescription || ''))} </div>` : ''} ${mimeRespDetails.examples[0].exampleFormat === 'json' ? (0, _litElement.html)` <json-tree render-style="${this.renderStyle}" .data="${mimeRespDetails.examples[0].exampleValue}" class="example-panel pad-top-8"></json-tree>` : (0, _litElement.html)` <pre class="example-panel generic-tree border-top pad-top-8">${mimeRespDetails.examples[0].exampleValue}</pre> `}` : (0, _litElement.html)` <span class="example-panel generic-tree ${this.renderStyle === 'read' ? 'border pad-8-16' : 'border-top pad-top-8'}"> <select aria-label="response body example" @change="${e => this.onSelectExample(e)}"> ${mimeRespDetails.examples.map(v => (0, _litElement.html)`<option value="${v.exampleId}" ?selected="${v.exampleId === mimeRespDetails.selectedExample}"> ${v.exampleSummary.length > 80 ? v.exampleId : v.exampleSummary} </option>`)} </select> ${mimeRespDetails.examples.map(v => (0, _litElement.html)` <div class="example" data-example="${v.exampleId}" style="display:${v.exampleId === mimeRespDetails.selectedExample ? 'block' : 'none'}"> ${v.exampleSummary && v.exampleSummary.length > 80 ? (0, _litElement.html)`<div style="padding:4px 0"> ${v.exampleSummary} </div>` : ''} ${v.exampleDescription ? (0, _litElement.html)`<div class="m-markdown-small" style="padding:4px 0"> ${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(v.exampleDescription || ''))} </div>` : ''} ${v.exampleFormat === 'json' ? (0, _litElement.html)` <json-tree render-style="${this.renderStyle}" .data="${v.exampleValue}"></json-tree>` : (0, _litElement.html)`<pre class="generic-tree">${v.exampleValue}</pre>`} </div> `)} </span> `} `;
|
|
182
|
+
return (0, _litElement.html)` ${mimeRespDetails.examples.length === 1 ? (0, _litElement.html)` ${mimeRespDetails.examples[0].exampleSummary && mimeRespDetails.examples[0].exampleSummary.length > 80 ? (0, _litElement.html)`<div style="padding:4px 0"> ${mimeRespDetails.examples[0].exampleSummary} </div>` : ''} ${mimeRespDetails.examples[0].exampleDescription ? (0, _litElement.html)`<div class="m-markdown-small" style="padding:4px 0"> ${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(mimeRespDetails.examples[0].exampleDescription || ''))} </div>` : ''} ${mimeRespDetails.examples[0].exampleFormat === 'json' ? (0, _litElement.html)` <json-tree render-style="${this.renderStyle}" .data="${mimeRespDetails.examples[0].exampleValue}" class="example-panel pad-top-8"></json-tree>` : (0, _litElement.html)` <pre class="example-panel generic-tree border-top pad-top-8">${mimeRespDetails.examples[0].exampleValue}</pre> `}` : (0, _litElement.html)` <span class="example-panel generic-tree ${this.renderStyle === 'read' ? 'border pad-8-16' : 'border-top pad-top-8'}"> <select aria-label="response body example" @change="${e => this.onSelectExample(e)}"> ${mimeRespDetails.examples.map(v => (0, _litElement.html)`<option value="${v.exampleId}" ?selected="${v.exampleId === mimeRespDetails.selectedExample}"> ${v.exampleSummary.length > 80 ? v.exampleId : v.exampleSummary} </option>`)} </select> ${mimeRespDetails.examples.map(v => (0, _litElement.html)` <div class="example" data-example="${v.exampleId}" style="display:${v.exampleId === mimeRespDetails.selectedExample ? 'block' : 'none'}"> ${v.exampleSummary && v.exampleSummary.length > 80 ? (0, _litElement.html)`<div style="padding:4px 0"> ${v.exampleSummary} </div>` : ''} ${v.exampleDescription && v.exampleDescription !== v.exampleSummary ? (0, _litElement.html)`<div class="m-markdown-small" style="padding:4px 0"> ${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(v.exampleDescription || ''))} </div>` : ''} ${v.exampleFormat === 'json' ? (0, _litElement.html)` <json-tree render-style="${this.renderStyle}" .data="${v.exampleValue}"></json-tree>` : (0, _litElement.html)`<pre class="generic-tree">${v.exampleValue}</pre>`} </div> `)} </span> `} `;
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
mimeSchemaTemplate(mimeRespDetails) {
|
|
@@ -375,22 +375,22 @@ function getExampleValuesFromSchemaRecursive(schema, config = {}) {
|
|
|
375
375
|
*/
|
|
376
376
|
|
|
377
377
|
|
|
378
|
-
function schemaInObjectNotation(
|
|
379
|
-
if (!
|
|
378
|
+
function schemaInObjectNotation(rawSchema, _, level = 0, suffix = '') {
|
|
379
|
+
if (!rawSchema) {
|
|
380
380
|
return undefined;
|
|
381
381
|
}
|
|
382
382
|
|
|
383
|
-
|
|
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
|
-
});
|
|
407
|
-
|
|
408
|
-
obj
|
|
409
|
-
} else if (
|
|
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
|
-
|
|
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
|
|
449
|
-
obj
|
|
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<${schema.items.description}>` : '';
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
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": {
|