openapi-explorer 2.1.659 → 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/utils/schema-utils.js +7 -4
- package/dist/lib/components/api-request.js +5 -4
- package/dist/lib/components/api-response.js +5 -3
- package/dist/lib/utils/schema-utils.js +7 -4
- 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) {
|
@@ -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 || '',
|
@@ -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) {
|
@@ -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 || '',
|
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",
|