openapi-explorer 2.1.658 → 2.1.660
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 +2 -2
- package/dist/es/components/api-request.js +5 -4
- package/dist/es/components/api-response.js +5 -3
- package/dist/es/components/schema-table.js +2 -2
- package/dist/es/utils/schema-utils.js +13 -10
- package/dist/lib/components/api-request.js +5 -4
- package/dist/lib/components/api-response.js +5 -3
- package/dist/lib/components/schema-table.js +2 -2
- package/dist/lib/utils/schema-utils.js +13 -10
- package/package.json +1 -1
@@ -198,8 +198,9 @@ export default class ApiRequest extends LitElement {
|
|
198
198
|
if (!param.schema) {
|
199
199
|
continue;
|
200
200
|
}
|
201
|
-
const paramSchema = getTypeInfo(param
|
202
|
-
includeNulls: this.includeNulls
|
201
|
+
const paramSchema = getTypeInfo(param, {
|
202
|
+
includeNulls: this.includeNulls,
|
203
|
+
enableExampleGeneration: true
|
203
204
|
});
|
204
205
|
if (!paramSchema) {
|
205
206
|
continue;
|
@@ -254,7 +255,7 @@ export default class ApiRequest extends LitElement {
|
|
254
255
|
|
255
256
|
exampleListTemplate(param, paramType) {
|
256
257
|
const paramName = param.name;
|
257
|
-
const paramSchema = getTypeInfo(param
|
258
|
+
const paramSchema = getTypeInfo(param, {
|
258
259
|
includeNulls: this.includeNulls
|
259
260
|
});
|
260
261
|
const examples = generateExample(param.examples || param.example && {
|
@@ -355,7 +356,7 @@ export default class ApiRequest extends LitElement {
|
|
355
356
|
this.selectedRequestBodyExample = reqBodyExamples.length > 0 ? reqBodyExamples[0].exampleId : '';
|
356
357
|
}
|
357
358
|
const displayedBodyExample = reqBodyExamples.find(v => v.exampleId === this.selectedRequestBodyExample) || reqBodyExamples[0];
|
358
|
-
reqBodyDefaultHtml = html` <div class="example-panel
|
359
|
+
reqBodyDefaultHtml = html` <div class="example-panel pad-top-8"> ${reqBodyExamples.length === 1 ? '' : html` <select aria-label="request body example" style="min-width:100px;max-width:100%;margin-bottom:-1px" @change="${e => this.onSelectExample(e)}"> ${reqBodyExamples.map(v => html`<option value="${v.exampleId}" ?selected="${v.exampleId === this.selectedRequestBodyExample}"> ${v.exampleSummary.length > 80 ? v.exampleId : v.exampleSummary ? v.exampleSummary : v.exampleId} </option>`)} </select>`} ${displayedBodyExample ? html` <div class="example" data-default="${displayedBodyExample.exampleId}"> ${displayedBodyExample.exampleSummary && displayedBodyExample.exampleSummary.length > 80 ? html`<div style="padding:4px 0"> ${displayedBodyExample.exampleSummary} </div>` : ''} ${displayedBodyExample.exampleDescription ? html`<div class="m-markdown-small" style="padding:4px 0"> ${unsafeHTML(marked(displayedBodyExample.exampleDescription || ''))} </div>` : ''} <slot name="${this.elementId}--request-body"> <textarea @input="${() => {
|
359
360
|
this.computeCurlSyntax();
|
360
361
|
}}" class="textarea request-body-param-user-input" part="textarea textarea-param" spellcheck="false" data-ptype="${reqBody.mimeType}" data-default="${displayedBodyExample.exampleFormat === 'text' ? displayedBodyExample.exampleValue : JSON.stringify(displayedBodyExample.exampleValue, null, 8)}" data-default-format="${displayedBodyExample.exampleFormat}" style="width:100%;resize:vertical" .value="${this.fillRequestWithDefault === 'true' ? displayedBodyExample.exampleFormat === 'text' ? displayedBodyExample.exampleValue : JSON.stringify(displayedBodyExample.exampleValue, null, 8) : ''}"></textarea> </slot> <textarea class="textarea is-hidden request-body-param ${reqBody.mimeType.substring(reqBody.mimeType.indexOf('/') + 1)}" spellcheck="false" data-ptype="${reqBody.mimeType}" style="width:100%;resize:vertical;display:none" .value="${displayedBodyExample.exampleFormat === 'text' ? displayedBodyExample.exampleValue : JSON.stringify(displayedBodyExample.exampleValue, null, 8)}"></textarea> </div>` : ''} </div> `;
|
361
362
|
} else if (this.selectedRequestBodyType.includes('form-urlencoded') || this.selectedRequestBodyType.includes('form-data')) {
|
@@ -136,8 +136,10 @@ export default class ApiResponse extends LitElement {
|
|
136
136
|
}
|
137
137
|
responseHeaderListTemplate(respHeaders) {
|
138
138
|
return html` <div style="padding:16px 0 8px 0" class="resp-headers small-font-size bold-text">${getI18nText('operations.response-headers')}</div> <table role="presentation" style="border-collapse:collapse;margin-bottom:16px;border:1px solid var(--border-color);border-radius:var(--border-radius)" class="small-font-size mono-font"> ${respHeaders.map(v => {
|
139
|
-
const typeData = getTypeInfo(v
|
140
|
-
|
139
|
+
const typeData = getTypeInfo(v, {
|
140
|
+
enableExampleGeneration: true
|
141
|
+
});
|
142
|
+
return html` <tr> <td style="padding:8px;vertical-align:baseline;min-width:160px;border-top:1px solid var(--light-border-color);text-overflow:ellipsis"> ${v.name || ''} </td> <td class="${(typeData === null || typeData === void 0 ? void 0 : typeData.cssType) || ''}" style="padding:4px;vertical-align:baseline;min-width:100px;padding:0 5px;border-top:1px solid var(--light-border-color);text-overflow:ellipsis"> ${(typeData === null || typeData === void 0 ? void 0 : typeData.format) || (typeData === null || typeData === void 0 ? void 0 : typeData.type) || ''} </td> <td style="padding:8px;vertical-align:baseline;border-top:1px solid var(--light-border-color);text-overflow:ellipsis"> <div class="m-markdown-small regular-font">${unsafeHTML(marked(v.description || ''))}</div> </td> <td style="padding:8px;vertical-align:baseline;border-top:1px solid var(--light-border-color);text-overflow:ellipsis"> ${(typeData === null || typeData === void 0 ? void 0 : typeData.example) || (typeData === null || typeData === void 0 ? void 0 : typeData.default) || ''} </td> </tr> `;
|
141
143
|
})} </table>`;
|
142
144
|
}
|
143
145
|
mimeTypeDropdownTemplate(mimeTypes) {
|
@@ -156,7 +158,7 @@ export default class ApiResponse extends LitElement {
|
|
156
158
|
if (!mimeRespDetails) {
|
157
159
|
return html` <pre style="color:var(--red)" class="example-panel border-top"> No example provided </pre> `;
|
158
160
|
}
|
159
|
-
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>` : ''} <syntax-highlighter class="example-panel generic-tree
|
161
|
+
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>` : ''} <syntax-highlighter class="example-panel generic-tree pad-top-8" mime-type="${mimeRespDetails.examples[0].exampleType}" .content="${mimeRespDetails.examples[0].exampleValue}">` : 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 || 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>` : ''} <syntax-highlighter mime-type="${v.exampleType}" .content="${v.exampleValue}"> </div> `)} </span> `} `;
|
160
162
|
}
|
161
163
|
mimeSchemaTemplate(mimeRespDetails) {
|
162
164
|
if (!mimeRespDetails) {
|
@@ -106,7 +106,7 @@ export default class SchemaTable extends LitElement {
|
|
106
106
|
} else if (data['::type']) {
|
107
107
|
displaySchemaLink = data['::link'];
|
108
108
|
if (dataType === 'array') {
|
109
|
-
detailObjType =
|
109
|
+
detailObjType = data['::link'] || keyLabel.replace(/(s|Collection|List)[*]?$/i, ''); // Array of Object
|
110
110
|
} else {
|
111
111
|
detailObjType = data['::link'] || data['::type'];
|
112
112
|
}
|
@@ -121,7 +121,7 @@ export default class SchemaTable extends LitElement {
|
|
121
121
|
return undefined;
|
122
122
|
}
|
123
123
|
const displayLine = [title && `**${title}${description ? ':' : ''}**`, description].filter(v => v).join(' ');
|
124
|
-
return html` ${newSchemaLevel >= 0 && key ? html` <div class="tr ${newSchemaLevel <= this.schemaExpandLevel ? '' : 'collapsed'} ${data['::type']}" data-obj="${keyLabel}"> <div class="td no-select key ${data['::deprecated'] ? 'deprecated' : ''}" style="padding-left:${leftPadding}px;cursor:pointer" @click="${e => this.toggleObjectExpand(e, keyLabel)}"> <div style="display:flex;align-items:center"> ${keyLabel || keyDescr ? html`<div class="obj-toggle" data-obj="${keyLabel}">▾</div>` : ''} ${data['::type'] === 'xxx-of-option' || data['::type'] === 'xxx-of-array' || key.startsWith('::OPTION') ? html`<span class="xxx-of-key" style="margin-left:-6px">${keyLabel}</span><span class="${isOneOfLabel ? 'xxx-of-key' : 'xxx-of-descr'}">${keyDescr}</span>` : keyLabel.endsWith('*') ? html`<span class="key-label requiredStar" style="display:inline-block;margin-left:-6px" title="Required"> ${keyLabel.substring(0, keyLabel.length - 1)}</span>` : html`<span class="key-label" style="display:inline-block;margin-left:-6px">${keyLabel === '::props' ? '' : keyLabel}</span>`} </div> </div> <div class="td key-type"> ${displaySchemaLink ? html`<div class="schema-link" style="overflow:hidden;text-overflow:ellipsis" @click="${() => this.scrollToSchemaComponentByName(displaySchemaLink)}">${detailObjType}</div>` : html`<div>${(data['::type'] || '').includes('xxx-of') ? '' : detailObjType}</div>`} <div class="attributes" title="${flags['🆁'] && 'Read only attribute' || flags['🆆'] && 'Write only attribute' || ''}">${flags['🆁'] || flags['🆆'] || ''}</div> </div> <div class="td key-descr"> <span class="m-markdown-small">${unsafeHTML(marked(displayLine))}</span> ${(_data$Metadata = data['::metadata']) !== null && _data$Metadata !== void 0 && (_data$Metadata$constr = _data$Metadata.constraints) !== null && _data$Metadata$constr !== void 0 && _data$Metadata$constr.length ? html`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Constraints: </span>${data['::metadata'].constraints.join(', ')}</div><br>` : ''} </div> </div>` : html` ${data['::type'] === 'array' && dataType === 'array' ? html`<div class="tr"> <div class="td"> ${dataType} </div> </div>` : ''} `} <div class="object-body"> ${Array.isArray(data) && data[0] ? html`${this.generateTree(data[0], 'xxx-of-option', '::ARRAY~OF', data[0]['::title'], data[0]['::description'], newSchemaLevel, newIndentLevel)}` : html` ${Object.keys(data).map(dataKey => {
|
124
|
+
return html` ${newSchemaLevel >= 0 && key ? html` <div class="tr ${newSchemaLevel <= this.schemaExpandLevel ? '' : 'collapsed'} ${data['::type']}" data-obj="${keyLabel}"> <div class="td no-select key ${data['::deprecated'] ? 'deprecated' : ''}" style="padding-left:${leftPadding}px;cursor:pointer" @click="${e => this.toggleObjectExpand(e, keyLabel)}"> <div style="display:flex;align-items:center"> ${keyLabel || keyDescr ? html`<div class="obj-toggle" data-obj="${keyLabel}">▾</div>` : ''} ${data['::type'] === 'xxx-of-option' || data['::type'] === 'xxx-of-array' || key.startsWith('::OPTION') ? html`<span class="xxx-of-key" style="margin-left:-6px">${keyLabel}</span><span class="${isOneOfLabel ? 'xxx-of-key' : 'xxx-of-descr'}">${keyDescr}</span>` : keyLabel.endsWith('*') ? html`<span class="key-label requiredStar" style="display:inline-block;margin-left:-6px" title="Required"> ${keyLabel.substring(0, keyLabel.length - 1)}</span>` : html`<span class="key-label" style="display:inline-block;margin-left:-6px">${keyLabel === '::props' ? '' : keyLabel}</span>`} </div> </div> <div class="td key-type"> ${displaySchemaLink ? html`<div class="schema-link" style="overflow:hidden;text-overflow:ellipsis" @click="${() => this.scrollToSchemaComponentByName(displaySchemaLink)}"> ${dataType === 'array' ? '[' : ''}<span style="color:var(--primary)">${detailObjType}</span>${dataType === 'array' ? ']' : ''} </div>` : html`<div>${(data['::type'] || '').includes('xxx-of') ? '' : detailObjType}</div>`} <div class="attributes" title="${flags['🆁'] && 'Read only attribute' || flags['🆆'] && 'Write only attribute' || ''}">${flags['🆁'] || flags['🆆'] || ''}</div> </div> <div class="td key-descr"> <span class="m-markdown-small">${unsafeHTML(marked(displayLine))}</span> ${(_data$Metadata = data['::metadata']) !== null && _data$Metadata !== void 0 && (_data$Metadata$constr = _data$Metadata.constraints) !== null && _data$Metadata$constr !== void 0 && _data$Metadata$constr.length ? html`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Constraints: </span>${data['::metadata'].constraints.join(', ')}</div><br>` : ''} </div> </div>` : html` ${data['::type'] === 'array' && dataType === 'array' ? html`<div class="tr"> <div class="td"> ${dataType} </div> </div>` : ''} `} <div class="object-body"> ${Array.isArray(data) && data[0] ? html`${this.generateTree(data[0], 'xxx-of-option', '::ARRAY~OF', data[0]['::title'], data[0]['::description'], newSchemaLevel, newIndentLevel)}` : html` ${Object.keys(data).map(dataKey => {
|
125
125
|
var _data$dataKey;
|
126
126
|
return !['::metadata', '::title', '::description', '::type', '::link', '::props', '::deprecated', '::array-type', '::dataTypeLabel', '::flags'].includes(dataKey) || (_data$dataKey = data[dataKey]) !== null && _data$dataKey !== void 0 && _data$dataKey['::type'] && !data[dataKey]['::type'].includes('xxx-of') ? html`${this.generateTree(data[dataKey]['::type'] === 'array' ? data[dataKey]['::props'] : data[dataKey], data[dataKey]['::type'], dataKey, data[dataKey]['::title'], data[dataKey]['::description'], newSchemaLevel, newIndentLevel)}` : '';
|
127
127
|
})}`} <div> </div></div>`;
|
@@ -8,13 +8,15 @@ const IS_MISSING_TYPE_INFO_TYPE = '';
|
|
8
8
|
const EXAMPLE_VALUE_FOR_MISSING_TYPE = '';
|
9
9
|
|
10
10
|
/* Generates an schema object containing type and constraint info */
|
11
|
-
export function getTypeInfo(
|
12
|
-
includeNulls: false
|
11
|
+
export function getTypeInfo(parameter, options = {
|
12
|
+
includeNulls: false,
|
13
|
+
enableExampleGeneration: false
|
13
14
|
}) {
|
14
15
|
var _schema$items, _schema$const;
|
15
|
-
if (!
|
16
|
+
if (!parameter) {
|
16
17
|
return undefined;
|
17
18
|
}
|
19
|
+
const schema = Object.assign({}, parameter, parameter.schema);
|
18
20
|
let dataType = IS_MISSING_TYPE_INFO_TYPE;
|
19
21
|
let format = schema.format || ((_schema$items = schema.items) === null || _schema$items === void 0 ? void 0 : _schema$items.format) || '';
|
20
22
|
if (schema.circularReference) {
|
@@ -32,6 +34,7 @@ export function getTypeInfo(schema, options = {
|
|
32
34
|
format += '┃null';
|
33
35
|
}
|
34
36
|
}
|
37
|
+
const examples = schema.examples || schema.example || (options === null || options === void 0 ? void 0 : options.enableExampleGeneration) && getSampleValueByType(schema, null) || '';
|
35
38
|
const info = {
|
36
39
|
type: dataType,
|
37
40
|
format,
|
@@ -39,7 +42,7 @@ export function getTypeInfo(schema, options = {
|
|
39
42
|
pattern: schema.pattern && !schema.enum ? schema.pattern.replace(/(^\^)|(\$$)/g, '') : '',
|
40
43
|
readOrWriteOnly: schema.readOnly && '🆁' || schema.writeOnly && '🆆' || '',
|
41
44
|
deprecated: !!schema.deprecated,
|
42
|
-
example:
|
45
|
+
example: examples || '',
|
43
46
|
default: schema.default || '',
|
44
47
|
title: schema.title || '',
|
45
48
|
description: schema.description || '',
|
@@ -411,7 +414,7 @@ export function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '
|
|
411
414
|
if (Object.keys(objWithAnyOfProps).length) {
|
412
415
|
resultObj[anyOf ? `::ANY~OF ${suffix}` : `::ONE~OF ${suffix}`] = objWithAnyOfProps;
|
413
416
|
}
|
414
|
-
resultObj['::link'] = schema.title;
|
417
|
+
resultObj['::link'] = schema.title || '';
|
415
418
|
resultObj['::type'] = schema.title || 'object';
|
416
419
|
resultObj['::flags'] = {
|
417
420
|
'🆁': readOnly && '🆁',
|
@@ -454,7 +457,7 @@ export function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '
|
|
454
457
|
}
|
455
458
|
}
|
456
459
|
if (complexTypes.length > 0) {
|
457
|
-
obj['::link'] = schema.title;
|
460
|
+
obj['::link'] = schema.title || '';
|
458
461
|
obj['::type'] = 'object';
|
459
462
|
const multiTypeOptions = {
|
460
463
|
'::type': 'xxx-of-option'
|
@@ -477,7 +480,7 @@ export function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '
|
|
477
480
|
'🆁': schema.readOnly && '🆁',
|
478
481
|
'🆆': schema.writeOnly && '🆆'
|
479
482
|
},
|
480
|
-
'::link': schema.title,
|
483
|
+
'::link': schema.title || '',
|
481
484
|
'::type': schema.title || 'object',
|
482
485
|
'::deprecated': schema.deprecated || false,
|
483
486
|
'::metadata': metadata
|
@@ -499,7 +502,7 @@ export function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '
|
|
499
502
|
'🆁': schema.readOnly && '🆁',
|
500
503
|
'🆆': schema.writeOnly && '🆆'
|
501
504
|
},
|
502
|
-
'::link': arrayItemsSchema.title || schema.title,
|
505
|
+
'::link': arrayItemsSchema.title || schema.title || '',
|
503
506
|
'::type': 'array',
|
504
507
|
// Array properties are read from the ::props object instead of reading from the keys of this object
|
505
508
|
// '::props': schemaInObjectNotation(Object.assign({ deprecated: schema.deprecated, readOnly: schema.readOnly, writeOnly: schema.writeOnly }, arrayItemsSchema), options, (level + 1)),
|
@@ -523,7 +526,7 @@ export function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '
|
|
523
526
|
'🆁': schema.readOnly && '🆁',
|
524
527
|
'🆆': schema.writeOnly && '🆆'
|
525
528
|
};
|
526
|
-
obj['::link'] = schema.title;
|
529
|
+
obj['::link'] = schema.title || '';
|
527
530
|
obj['::type'] = schema.title || 'object';
|
528
531
|
obj['::deprecated'] = schema.deprecated || false;
|
529
532
|
obj['::metadata'] = metadata;
|
@@ -553,7 +556,7 @@ export function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '
|
|
553
556
|
'🆁': schema.readOnly && '🆁',
|
554
557
|
'🆆': schema.writeOnly && '🆆'
|
555
558
|
};
|
556
|
-
obj['::link'] = arrayItemsSchema.title || schema.title;
|
559
|
+
obj['::link'] = arrayItemsSchema.title || schema.title || '';
|
557
560
|
obj['::type'] = 'array';
|
558
561
|
obj['::deprecated'] = schema.deprecated || false;
|
559
562
|
obj['::metadata'] = metadata;
|
@@ -203,8 +203,9 @@ class ApiRequest extends _lit.LitElement {
|
|
203
203
|
if (!param.schema) {
|
204
204
|
continue;
|
205
205
|
}
|
206
|
-
const paramSchema = (0, _schemaUtils.getTypeInfo)(param
|
207
|
-
includeNulls: this.includeNulls
|
206
|
+
const paramSchema = (0, _schemaUtils.getTypeInfo)(param, {
|
207
|
+
includeNulls: this.includeNulls,
|
208
|
+
enableExampleGeneration: true
|
208
209
|
});
|
209
210
|
if (!paramSchema) {
|
210
211
|
continue;
|
@@ -259,7 +260,7 @@ class ApiRequest extends _lit.LitElement {
|
|
259
260
|
|
260
261
|
exampleListTemplate(param, paramType) {
|
261
262
|
const paramName = param.name;
|
262
|
-
const paramSchema = (0, _schemaUtils.getTypeInfo)(param
|
263
|
+
const paramSchema = (0, _schemaUtils.getTypeInfo)(param, {
|
263
264
|
includeNulls: this.includeNulls
|
264
265
|
});
|
265
266
|
const examples = (0, _schemaUtils.generateExample)(param.examples || param.example && {
|
@@ -360,7 +361,7 @@ class ApiRequest extends _lit.LitElement {
|
|
360
361
|
this.selectedRequestBodyExample = reqBodyExamples.length > 0 ? reqBodyExamples[0].exampleId : '';
|
361
362
|
}
|
362
363
|
const displayedBodyExample = reqBodyExamples.find(v => v.exampleId === this.selectedRequestBodyExample) || reqBodyExamples[0];
|
363
|
-
reqBodyDefaultHtml = (0, _lit.html)` <div class="example-panel
|
364
|
+
reqBodyDefaultHtml = (0, _lit.html)` <div class="example-panel pad-top-8"> ${reqBodyExamples.length === 1 ? '' : (0, _lit.html)` <select aria-label="request body example" style="min-width:100px;max-width:100%;margin-bottom:-1px" @change="${e => this.onSelectExample(e)}"> ${reqBodyExamples.map(v => (0, _lit.html)`<option value="${v.exampleId}" ?selected="${v.exampleId === this.selectedRequestBodyExample}"> ${v.exampleSummary.length > 80 ? v.exampleId : v.exampleSummary ? v.exampleSummary : v.exampleId} </option>`)} </select>`} ${displayedBodyExample ? (0, _lit.html)` <div class="example" data-default="${displayedBodyExample.exampleId}"> ${displayedBodyExample.exampleSummary && displayedBodyExample.exampleSummary.length > 80 ? (0, _lit.html)`<div style="padding:4px 0"> ${displayedBodyExample.exampleSummary} </div>` : ''} ${displayedBodyExample.exampleDescription ? (0, _lit.html)`<div class="m-markdown-small" style="padding:4px 0"> ${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(displayedBodyExample.exampleDescription || ''))} </div>` : ''} <slot name="${this.elementId}--request-body"> <textarea @input="${() => {
|
364
365
|
this.computeCurlSyntax();
|
365
366
|
}}" class="textarea request-body-param-user-input" part="textarea textarea-param" spellcheck="false" data-ptype="${reqBody.mimeType}" data-default="${displayedBodyExample.exampleFormat === 'text' ? displayedBodyExample.exampleValue : JSON.stringify(displayedBodyExample.exampleValue, null, 8)}" data-default-format="${displayedBodyExample.exampleFormat}" style="width:100%;resize:vertical" .value="${this.fillRequestWithDefault === 'true' ? displayedBodyExample.exampleFormat === 'text' ? displayedBodyExample.exampleValue : JSON.stringify(displayedBodyExample.exampleValue, null, 8) : ''}"></textarea> </slot> <textarea class="textarea is-hidden request-body-param ${reqBody.mimeType.substring(reqBody.mimeType.indexOf('/') + 1)}" spellcheck="false" data-ptype="${reqBody.mimeType}" style="width:100%;resize:vertical;display:none" .value="${displayedBodyExample.exampleFormat === 'text' ? displayedBodyExample.exampleValue : JSON.stringify(displayedBodyExample.exampleValue, null, 8)}"></textarea> </div>` : ''} </div> `;
|
366
367
|
} else if (this.selectedRequestBodyType.includes('form-urlencoded') || this.selectedRequestBodyType.includes('form-data')) {
|
@@ -141,8 +141,10 @@ class ApiResponse extends _lit.LitElement {
|
|
141
141
|
}
|
142
142
|
responseHeaderListTemplate(respHeaders) {
|
143
143
|
return (0, _lit.html)` <div style="padding:16px 0 8px 0" class="resp-headers small-font-size bold-text">${(0, _index.getI18nText)('operations.response-headers')}</div> <table role="presentation" style="border-collapse:collapse;margin-bottom:16px;border:1px solid var(--border-color);border-radius:var(--border-radius)" class="small-font-size mono-font"> ${respHeaders.map(v => {
|
144
|
-
const typeData = (0, _schemaUtils.getTypeInfo)(v
|
145
|
-
|
144
|
+
const typeData = (0, _schemaUtils.getTypeInfo)(v, {
|
145
|
+
enableExampleGeneration: true
|
146
|
+
});
|
147
|
+
return (0, _lit.html)` <tr> <td style="padding:8px;vertical-align:baseline;min-width:160px;border-top:1px solid var(--light-border-color);text-overflow:ellipsis"> ${v.name || ''} </td> <td class="${(typeData === null || typeData === void 0 ? void 0 : typeData.cssType) || ''}" style="padding:4px;vertical-align:baseline;min-width:100px;padding:0 5px;border-top:1px solid var(--light-border-color);text-overflow:ellipsis"> ${(typeData === null || typeData === void 0 ? void 0 : typeData.format) || (typeData === null || typeData === void 0 ? void 0 : typeData.type) || ''} </td> <td style="padding:8px;vertical-align:baseline;border-top:1px solid var(--light-border-color);text-overflow:ellipsis"> <div class="m-markdown-small regular-font">${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(v.description || ''))}</div> </td> <td style="padding:8px;vertical-align:baseline;border-top:1px solid var(--light-border-color);text-overflow:ellipsis"> ${(typeData === null || typeData === void 0 ? void 0 : typeData.example) || (typeData === null || typeData === void 0 ? void 0 : typeData.default) || ''} </td> </tr> `;
|
146
148
|
})} </table>`;
|
147
149
|
}
|
148
150
|
mimeTypeDropdownTemplate(mimeTypes) {
|
@@ -161,7 +163,7 @@ class ApiResponse extends _lit.LitElement {
|
|
161
163
|
if (!mimeRespDetails) {
|
162
164
|
return (0, _lit.html)` <pre style="color:var(--red)" class="example-panel border-top"> No example provided </pre> `;
|
163
165
|
}
|
164
|
-
return (0, _lit.html)` ${mimeRespDetails.examples.length === 1 ? (0, _lit.html)` ${mimeRespDetails.examples[0].exampleSummary && mimeRespDetails.examples[0].exampleSummary.length > 80 ? (0, _lit.html)`<div style="padding:4px 0"> ${mimeRespDetails.examples[0].exampleSummary} </div>` : ''} ${mimeRespDetails.examples[0].exampleDescription ? (0, _lit.html)`<div class="m-markdown-small" style="padding:4px 0"> ${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(mimeRespDetails.examples[0].exampleDescription || ''))} </div>` : ''} <syntax-highlighter class="example-panel generic-tree
|
166
|
+
return (0, _lit.html)` ${mimeRespDetails.examples.length === 1 ? (0, _lit.html)` ${mimeRespDetails.examples[0].exampleSummary && mimeRespDetails.examples[0].exampleSummary.length > 80 ? (0, _lit.html)`<div style="padding:4px 0"> ${mimeRespDetails.examples[0].exampleSummary} </div>` : ''} ${mimeRespDetails.examples[0].exampleDescription ? (0, _lit.html)`<div class="m-markdown-small" style="padding:4px 0"> ${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(mimeRespDetails.examples[0].exampleDescription || ''))} </div>` : ''} <syntax-highlighter class="example-panel generic-tree pad-top-8" mime-type="${mimeRespDetails.examples[0].exampleType}" .content="${mimeRespDetails.examples[0].exampleValue}">` : (0, _lit.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, _lit.html)`<option value="${v.exampleId}" ?selected="${v.exampleId === mimeRespDetails.selectedExample}"> ${!v.exampleSummary || v.exampleSummary.length > 80 ? v.exampleId : v.exampleSummary} </option>`)} </select> ${mimeRespDetails.examples.map(v => (0, _lit.html)` <div class="example" data-example="${v.exampleId}" style="display:${v.exampleId === mimeRespDetails.selectedExample ? 'block' : 'none'}"> ${v.exampleSummary && v.exampleSummary.length > 80 ? (0, _lit.html)`<div style="padding:4px 0"> ${v.exampleSummary} </div>` : ''} ${v.exampleDescription && v.exampleDescription !== v.exampleSummary ? (0, _lit.html)`<div class="m-markdown-small" style="padding:4px 0"> ${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(v.exampleDescription || ''))} </div>` : ''} <syntax-highlighter mime-type="${v.exampleType}" .content="${v.exampleValue}"> </div> `)} </span> `} `;
|
165
167
|
}
|
166
168
|
mimeSchemaTemplate(mimeRespDetails) {
|
167
169
|
if (!mimeRespDetails) {
|
@@ -111,7 +111,7 @@ class SchemaTable extends _lit.LitElement {
|
|
111
111
|
} else if (data['::type']) {
|
112
112
|
displaySchemaLink = data['::link'];
|
113
113
|
if (dataType === 'array') {
|
114
|
-
detailObjType =
|
114
|
+
detailObjType = data['::link'] || keyLabel.replace(/(s|Collection|List)[*]?$/i, ''); // Array of Object
|
115
115
|
} else {
|
116
116
|
detailObjType = data['::link'] || data['::type'];
|
117
117
|
}
|
@@ -126,7 +126,7 @@ class SchemaTable extends _lit.LitElement {
|
|
126
126
|
return undefined;
|
127
127
|
}
|
128
128
|
const displayLine = [title && `**${title}${description ? ':' : ''}**`, description].filter(v => v).join(' ');
|
129
|
-
return (0, _lit.html)` ${newSchemaLevel >= 0 && key ? (0, _lit.html)` <div class="tr ${newSchemaLevel <= this.schemaExpandLevel ? '' : 'collapsed'} ${data['::type']}" data-obj="${keyLabel}"> <div class="td no-select key ${data['::deprecated'] ? 'deprecated' : ''}" style="padding-left:${leftPadding}px;cursor:pointer" @click="${e => this.toggleObjectExpand(e, keyLabel)}"> <div style="display:flex;align-items:center"> ${keyLabel || keyDescr ? (0, _lit.html)`<div class="obj-toggle" data-obj="${keyLabel}">▾</div>` : ''} ${data['::type'] === 'xxx-of-option' || data['::type'] === 'xxx-of-array' || key.startsWith('::OPTION') ? (0, _lit.html)`<span class="xxx-of-key" style="margin-left:-6px">${keyLabel}</span><span class="${isOneOfLabel ? 'xxx-of-key' : 'xxx-of-descr'}">${keyDescr}</span>` : keyLabel.endsWith('*') ? (0, _lit.html)`<span class="key-label requiredStar" style="display:inline-block;margin-left:-6px" title="Required"> ${keyLabel.substring(0, keyLabel.length - 1)}</span>` : (0, _lit.html)`<span class="key-label" style="display:inline-block;margin-left:-6px">${keyLabel === '::props' ? '' : keyLabel}</span>`} </div> </div> <div class="td key-type"> ${displaySchemaLink ? (0, _lit.html)`<div class="schema-link" style="overflow:hidden;text-overflow:ellipsis" @click="${() => this.scrollToSchemaComponentByName(displaySchemaLink)}">${detailObjType}</div>` : (0, _lit.html)`<div>${(data['::type'] || '').includes('xxx-of') ? '' : detailObjType}</div>`} <div class="attributes" title="${flags['🆁'] && 'Read only attribute' || flags['🆆'] && 'Write only attribute' || ''}">${flags['🆁'] || flags['🆆'] || ''}</div> </div> <div class="td key-descr"> <span class="m-markdown-small">${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(displayLine))}</span> ${(_data$Metadata = data['::metadata']) !== null && _data$Metadata !== void 0 && (_data$Metadata$constr = _data$Metadata.constraints) !== null && _data$Metadata$constr !== void 0 && _data$Metadata$constr.length ? (0, _lit.html)`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Constraints: </span>${data['::metadata'].constraints.join(', ')}</div><br>` : ''} </div> </div>` : (0, _lit.html)` ${data['::type'] === 'array' && dataType === 'array' ? (0, _lit.html)`<div class="tr"> <div class="td"> ${dataType} </div> </div>` : ''} `} <div class="object-body"> ${Array.isArray(data) && data[0] ? (0, _lit.html)`${this.generateTree(data[0], 'xxx-of-option', '::ARRAY~OF', data[0]['::title'], data[0]['::description'], newSchemaLevel, newIndentLevel)}` : (0, _lit.html)` ${Object.keys(data).map(dataKey => {
|
129
|
+
return (0, _lit.html)` ${newSchemaLevel >= 0 && key ? (0, _lit.html)` <div class="tr ${newSchemaLevel <= this.schemaExpandLevel ? '' : 'collapsed'} ${data['::type']}" data-obj="${keyLabel}"> <div class="td no-select key ${data['::deprecated'] ? 'deprecated' : ''}" style="padding-left:${leftPadding}px;cursor:pointer" @click="${e => this.toggleObjectExpand(e, keyLabel)}"> <div style="display:flex;align-items:center"> ${keyLabel || keyDescr ? (0, _lit.html)`<div class="obj-toggle" data-obj="${keyLabel}">▾</div>` : ''} ${data['::type'] === 'xxx-of-option' || data['::type'] === 'xxx-of-array' || key.startsWith('::OPTION') ? (0, _lit.html)`<span class="xxx-of-key" style="margin-left:-6px">${keyLabel}</span><span class="${isOneOfLabel ? 'xxx-of-key' : 'xxx-of-descr'}">${keyDescr}</span>` : keyLabel.endsWith('*') ? (0, _lit.html)`<span class="key-label requiredStar" style="display:inline-block;margin-left:-6px" title="Required"> ${keyLabel.substring(0, keyLabel.length - 1)}</span>` : (0, _lit.html)`<span class="key-label" style="display:inline-block;margin-left:-6px">${keyLabel === '::props' ? '' : keyLabel}</span>`} </div> </div> <div class="td key-type"> ${displaySchemaLink ? (0, _lit.html)`<div class="schema-link" style="overflow:hidden;text-overflow:ellipsis" @click="${() => this.scrollToSchemaComponentByName(displaySchemaLink)}"> ${dataType === 'array' ? '[' : ''}<span style="color:var(--primary)">${detailObjType}</span>${dataType === 'array' ? ']' : ''} </div>` : (0, _lit.html)`<div>${(data['::type'] || '').includes('xxx-of') ? '' : detailObjType}</div>`} <div class="attributes" title="${flags['🆁'] && 'Read only attribute' || flags['🆆'] && 'Write only attribute' || ''}">${flags['🆁'] || flags['🆆'] || ''}</div> </div> <div class="td key-descr"> <span class="m-markdown-small">${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(displayLine))}</span> ${(_data$Metadata = data['::metadata']) !== null && _data$Metadata !== void 0 && (_data$Metadata$constr = _data$Metadata.constraints) !== null && _data$Metadata$constr !== void 0 && _data$Metadata$constr.length ? (0, _lit.html)`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Constraints: </span>${data['::metadata'].constraints.join(', ')}</div><br>` : ''} </div> </div>` : (0, _lit.html)` ${data['::type'] === 'array' && dataType === 'array' ? (0, _lit.html)`<div class="tr"> <div class="td"> ${dataType} </div> </div>` : ''} `} <div class="object-body"> ${Array.isArray(data) && data[0] ? (0, _lit.html)`${this.generateTree(data[0], 'xxx-of-option', '::ARRAY~OF', data[0]['::title'], data[0]['::description'], newSchemaLevel, newIndentLevel)}` : (0, _lit.html)` ${Object.keys(data).map(dataKey => {
|
130
130
|
var _data$dataKey;
|
131
131
|
return !['::metadata', '::title', '::description', '::type', '::link', '::props', '::deprecated', '::array-type', '::dataTypeLabel', '::flags'].includes(dataKey) || (_data$dataKey = data[dataKey]) !== null && _data$dataKey !== void 0 && _data$dataKey['::type'] && !data[dataKey]['::type'].includes('xxx-of') ? (0, _lit.html)`${this.generateTree(data[dataKey]['::type'] === 'array' ? data[dataKey]['::props'] : data[dataKey], data[dataKey]['::type'], dataKey, data[dataKey]['::title'], data[dataKey]['::description'], newSchemaLevel, newIndentLevel)}` : '';
|
132
132
|
})}`} <div> </div></div>`;
|
@@ -17,13 +17,15 @@ const IS_MISSING_TYPE_INFO_TYPE = '';
|
|
17
17
|
const EXAMPLE_VALUE_FOR_MISSING_TYPE = '';
|
18
18
|
|
19
19
|
/* Generates an schema object containing type and constraint info */
|
20
|
-
function getTypeInfo(
|
21
|
-
includeNulls: false
|
20
|
+
function getTypeInfo(parameter, options = {
|
21
|
+
includeNulls: false,
|
22
|
+
enableExampleGeneration: false
|
22
23
|
}) {
|
23
24
|
var _schema$items, _schema$const;
|
24
|
-
if (!
|
25
|
+
if (!parameter) {
|
25
26
|
return undefined;
|
26
27
|
}
|
28
|
+
const schema = Object.assign({}, parameter, parameter.schema);
|
27
29
|
let dataType = IS_MISSING_TYPE_INFO_TYPE;
|
28
30
|
let format = schema.format || ((_schema$items = schema.items) === null || _schema$items === void 0 ? void 0 : _schema$items.format) || '';
|
29
31
|
if (schema.circularReference) {
|
@@ -41,6 +43,7 @@ function getTypeInfo(schema, options = {
|
|
41
43
|
format += '┃null';
|
42
44
|
}
|
43
45
|
}
|
46
|
+
const examples = schema.examples || schema.example || (options === null || options === void 0 ? void 0 : options.enableExampleGeneration) && getSampleValueByType(schema, null) || '';
|
44
47
|
const info = {
|
45
48
|
type: dataType,
|
46
49
|
format,
|
@@ -48,7 +51,7 @@ function getTypeInfo(schema, options = {
|
|
48
51
|
pattern: schema.pattern && !schema.enum ? schema.pattern.replace(/(^\^)|(\$$)/g, '') : '',
|
49
52
|
readOrWriteOnly: schema.readOnly && '🆁' || schema.writeOnly && '🆆' || '',
|
50
53
|
deprecated: !!schema.deprecated,
|
51
|
-
example:
|
54
|
+
example: examples || '',
|
52
55
|
default: schema.default || '',
|
53
56
|
title: schema.title || '',
|
54
57
|
description: schema.description || '',
|
@@ -420,7 +423,7 @@ function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '') {
|
|
420
423
|
if (Object.keys(objWithAnyOfProps).length) {
|
421
424
|
resultObj[anyOf ? `::ANY~OF ${suffix}` : `::ONE~OF ${suffix}`] = objWithAnyOfProps;
|
422
425
|
}
|
423
|
-
resultObj['::link'] = schema.title;
|
426
|
+
resultObj['::link'] = schema.title || '';
|
424
427
|
resultObj['::type'] = schema.title || 'object';
|
425
428
|
resultObj['::flags'] = {
|
426
429
|
'🆁': readOnly && '🆁',
|
@@ -463,7 +466,7 @@ function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '') {
|
|
463
466
|
}
|
464
467
|
}
|
465
468
|
if (complexTypes.length > 0) {
|
466
|
-
obj['::link'] = schema.title;
|
469
|
+
obj['::link'] = schema.title || '';
|
467
470
|
obj['::type'] = 'object';
|
468
471
|
const multiTypeOptions = {
|
469
472
|
'::type': 'xxx-of-option'
|
@@ -486,7 +489,7 @@ function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '') {
|
|
486
489
|
'🆁': schema.readOnly && '🆁',
|
487
490
|
'🆆': schema.writeOnly && '🆆'
|
488
491
|
},
|
489
|
-
'::link': schema.title,
|
492
|
+
'::link': schema.title || '',
|
490
493
|
'::type': schema.title || 'object',
|
491
494
|
'::deprecated': schema.deprecated || false,
|
492
495
|
'::metadata': metadata
|
@@ -508,7 +511,7 @@ function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '') {
|
|
508
511
|
'🆁': schema.readOnly && '🆁',
|
509
512
|
'🆆': schema.writeOnly && '🆆'
|
510
513
|
},
|
511
|
-
'::link': arrayItemsSchema.title || schema.title,
|
514
|
+
'::link': arrayItemsSchema.title || schema.title || '',
|
512
515
|
'::type': 'array',
|
513
516
|
// Array properties are read from the ::props object instead of reading from the keys of this object
|
514
517
|
// '::props': schemaInObjectNotation(Object.assign({ deprecated: schema.deprecated, readOnly: schema.readOnly, writeOnly: schema.writeOnly }, arrayItemsSchema), options, (level + 1)),
|
@@ -532,7 +535,7 @@ function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '') {
|
|
532
535
|
'🆁': schema.readOnly && '🆁',
|
533
536
|
'🆆': schema.writeOnly && '🆆'
|
534
537
|
};
|
535
|
-
obj['::link'] = schema.title;
|
538
|
+
obj['::link'] = schema.title || '';
|
536
539
|
obj['::type'] = schema.title || 'object';
|
537
540
|
obj['::deprecated'] = schema.deprecated || false;
|
538
541
|
obj['::metadata'] = metadata;
|
@@ -562,7 +565,7 @@ function schemaInObjectNotation(rawSchema, options, level = 0, suffix = '') {
|
|
562
565
|
'🆁': schema.readOnly && '🆁',
|
563
566
|
'🆆': schema.writeOnly && '🆆'
|
564
567
|
};
|
565
|
-
obj['::link'] = arrayItemsSchema.title || schema.title;
|
568
|
+
obj['::link'] = arrayItemsSchema.title || schema.title || '';
|
566
569
|
obj['::type'] = 'array';
|
567
570
|
obj['::deprecated'] = schema.deprecated || false;
|
568
571
|
obj['::metadata'] = metadata;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "openapi-explorer",
|
3
|
-
"version": "2.1.
|
3
|
+
"version": "2.1.660",
|
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",
|