openapi-explorer 0.9.331 → 0.9.337
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/CHANGELOG.md +1 -0
- package/dist/browser/openapi-explorer.min.js +3 -3
- package/dist/browser/openapi-explorer.min.js.map +1 -1
- package/dist/es/components/api-request.js +1 -1
- package/dist/es/components/api-response.js +1 -1
- package/dist/es/components/json-tree.js +3 -3
- package/dist/es/components/schema-table.js +5 -6
- package/dist/es/components/schema-tree.js +9 -5
- package/dist/es/openapi-explorer.js +7 -16
- package/dist/es/styles/schema-styles.js +1 -1
- package/dist/es/templates/callback-template.js +1 -1
- package/dist/es/templates/components-template.js +1 -1
- package/dist/es/templates/endpoint-template.js +1 -1
- package/dist/es/templates/expanded-endpoint-template.js +1 -1
- package/dist/es/templates/focused-endpoint-template.js +1 -1
- package/dist/es/templates/navbar-template.js +1 -1
- package/dist/es/utils/schema-utils.js +3 -18
- package/dist/lib/components/api-request.js +1 -1
- package/dist/lib/components/api-response.js +1 -1
- package/dist/lib/components/json-tree.js +3 -3
- package/dist/lib/components/schema-table.js +5 -6
- package/dist/lib/components/schema-tree.js +9 -5
- package/dist/lib/openapi-explorer.js +7 -16
- package/dist/lib/styles/schema-styles.js +1 -1
- package/dist/lib/templates/callback-template.js +1 -1
- package/dist/lib/templates/components-template.js +1 -1
- package/dist/lib/templates/endpoint-template.js +1 -1
- package/dist/lib/templates/expanded-endpoint-template.js +1 -1
- package/dist/lib/templates/focused-endpoint-template.js +1 -1
- package/dist/lib/templates/navbar-template.js +1 -1
- package/dist/lib/utils/schema-utils.js +3 -18
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { css } from 'lit-element';
|
|
2
|
-
export default css`*,:after,:before{box-sizing:border-box}.tr{display:flex;flex:none;width:100%;box-sizing:content-box;border-bottom:1px dotted transparent}.td{display:block;flex:0 0 auto}.key{font-family:var(--font-mono);white-space:normal;word-break:break-all}.
|
|
2
|
+
export default css`*,:after,:before{box-sizing:border-box}.tr{display:flex;flex:none;width:100%;box-sizing:content-box;border-bottom:1px dotted transparent}.td{display:block;flex:0 0 auto}.key{font-family:var(--font-mono);white-space:normal;word-break:break-all}.key-descr{font-family:var(--font-regular);flex-shrink:1;text-overflow:ellipsis;overflow:hidden;display:none;max-height:auto}.toolbar{display:none}.tr.xxx-of{border-top:1px dotted var(--primary-color)}.xxx-of-key{font-size:calc(var(--font-size-small) - 2px);font-weight:700;background-color:var(--primary-color);color:var(--primary-btn-text-color);border-radius:2px;line-height:calc(var(--font-size-small) + 6px);padding:0 5px;margin-bottom:1px;display:inline-block}.xxx-of-descr{font-family:var(--font-regular);color:var(--primary-color);font-size:calc(var(--font-size-small) - 1px);margin-left:2px}.bina,.byte,.date,.emai,.host,.ipv4,.pass,.stri,.string,.uri,.url,.uuid{color:var(--green)}.deci .blue,.doub,.floa,.int3,.int6,.inte,.numb,.number{color:var(--blue)}.null{color:var(--red)}.bool,.boolean{color:var(--orange)}.enum{color:var(--yellow)}.tree .toolbar{display:flex;justify-content:space-between}.toolbar{width:100%}.toolbar-item{cursor:pointer;padding:5px 0 5px 1rem;margin:0 1rem!important;color:#38b3f9;flex-shrink:0}.tree .toolbar .toolbar-item{display:none}.schema-root-type{cursor:auto;color:var(--fg2);font-weight:700;text-transform:uppercase}.schema-root-type.xxx-of{display:none}.toolbar-item:first-of-type{margin:0 2px 0 0}@media only screen and (min-width:576px){.key-descr{display:block}.tree .toolbar .toolbar-item{display:block}.toolbar{display:flex}}`;
|
|
@@ -2,6 +2,6 @@ import { html } from 'lit-element';
|
|
|
2
2
|
/* eslint-disable indent */
|
|
3
3
|
|
|
4
4
|
export default function callbackTemplate(callbacks) {
|
|
5
|
-
return html` <div class="api-request col regular-font request-panel ${this.renderStyle}-mode"> ${Object.entries(callbacks).map(kv => html` <div class="${this.renderStyle}-request"> <div class="req-res-title">CALLBACKS</div> <div class="table-title">${kv[0]}</div> ${Object.entries(kv[1]).map(pathObj => html` <div class="mono-font small-font-size" style="display:flex"> <div style="width:100%"> ${Object.entries(pathObj[1]).map(method => html` <div> <div style="margin-top:12px"> <div class="method method-fg ${method[0]}" style="width:70px;border:none;margin:0;padding:0;line-height:20px;vertical-align:baseline;text-align:left"> <span style="font-size:20px"> ⥄ </span> ${method[0]} </div> <span style="line-height:20px;vertical-align:baseline">${pathObj[0]} </span> </div> <div class="expanded-req-resp-container"> <api-request class="request-panel" callback="true" method="${method[0] || ''}" , path="${pathObj[0] || ''}" .parameters="${method[1] && method[1].parameters || ''}" .request_body="${method[1] && method[1].requestBody || ''}" fill-defaults="${this.fillRequestWithDefault}" enable-console="false" render-style="${this.renderStyle}" schema-style="${this.
|
|
5
|
+
return html` <div class="api-request col regular-font request-panel ${this.renderStyle}-mode"> ${Object.entries(callbacks).map(kv => html` <div class="${this.renderStyle}-request"> <div class="req-res-title">CALLBACKS</div> <div class="table-title">${kv[0]}</div> ${Object.entries(kv[1]).map(pathObj => html` <div class="mono-font small-font-size" style="display:flex"> <div style="width:100%"> ${Object.entries(pathObj[1]).map(method => html` <div> <div style="margin-top:12px"> <div class="method method-fg ${method[0]}" style="width:70px;border:none;margin:0;padding:0;line-height:20px;vertical-align:baseline;text-align:left"> <span style="font-size:20px"> ⥄ </span> ${method[0]} </div> <span style="line-height:20px;vertical-align:baseline">${pathObj[0]} </span> </div> <div class="expanded-req-resp-container"> <api-request class="request-panel" callback="true" method="${method[0] || ''}" , path="${pathObj[0] || ''}" .parameters="${method[1] && method[1].parameters || ''}" .request_body="${method[1] && method[1].requestBody || ''}" fill-defaults="${this.fillRequestWithDefault}" enable-console="false" render-style="${this.renderStyle}" schema-style="${this.displaySchemaAsTable ? 'table' : 'tree'}" active-schema-tab="${this.defaultSchemaTab}" schema-expand-level="${this.schemaExpandLevel}" schema-description-expanded="${this.schemaDescriptionExpanded}" schema-hide-read-only="${this.schemaHideReadOnly}" fetch-credentials="${this.fetchCredentials}" exportparts="btn btn-fill btn-outline btn-try"> </api-request> <api-response callback="true" .responses="${method[1] && method[1].responses}" render-style="${this.renderStyle}" schema-style="${this.displaySchemaAsTable ? 'table' : 'tree'}" active-schema-tab="${this.defaultSchemaTab}" schema-expand-level="${this.schemaExpandLevel}" schema-description-expanded="${this.schemaDescriptionExpanded}" exportparts="btn--resp btn-fill--resp btn-outline--resp"> </api-response> </div> </div> `)} </div> </div> `)} </div> `)} </div> `;
|
|
6
6
|
}
|
|
7
7
|
/* eslint-enable indent */
|
|
@@ -8,7 +8,7 @@ import '../components/schema-tree';
|
|
|
8
8
|
|
|
9
9
|
function componentBodyTemplate(sComponent) {
|
|
10
10
|
const formdataPartSchema = schemaInObjectNotation(sComponent.component, {});
|
|
11
|
-
return html` <div class="expanded-endpoint-body observe-me ${sComponent.name}" id="cmp--${sComponent.id}"> <h2>${sComponent.name}</h2> <div class="mono-font regular-font-size" style="padding:8px 0;color:var(--fg2)">
|
|
11
|
+
return html` <div class="expanded-endpoint-body observe-me ${sComponent.name}" id="cmp--${sComponent.id}"> <h2>${sComponent.name}</h2> <div class="mono-font regular-font-size" style="padding:8px 0;color:var(--fg2)"> ${this.displaySchemaAsTable ? html`<schema-table .data="${formdataPartSchema}" schema-expand-level="${this.schemaExpandLevel}" schema-description-expanded="${this.schemaDescriptionExpanded}" schema-hide-read-only="false" schema-hide-write-only="false"> </schema-table>` : html`<schema-tree .data="${formdataPartSchema}" schema-expand-level="${this.schemaExpandLevel}" schema-description-expanded="${this.schemaDescriptionExpanded}" schema-hide-read-only="false" schema-hide-write-only="false"> </schema-tree>`} </div> </div> `;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export default function componentsTemplate() {
|
|
@@ -76,7 +76,7 @@ function endpointBodyTemplate(path) {
|
|
|
76
76
|
|
|
77
77
|
const nonEmptyApiKeys = this.resolvedSpec.securitySchemes.filter(v => v.finalKeyValue && path.security && path.security.some(ps => ps[v.apiKeyId])) || [];
|
|
78
78
|
const codeSampleTabPanel = path.xCodeSamples ? codeSamplesTemplate(path.xCodeSamples) : '';
|
|
79
|
-
return html` <div class="endpoint-body ${path.method}"> <div class="summary"> ${path.summary ? html`<div class="title">${path.summary}<div></div></div>` : path.shortSummary !== path.description ? html`<div class="title">${path.shortSummary}</div>` : ''} ${path.description ? html`<div class="m-markdown"> ${unsafeHTML(marked(path.description))}</div>` : ''} <slot name="${path.elementId}"></slot> ${pathSecurityTemplate.call(this, path.security)} ${codeSampleTabPanel} </div> <div class="req-resp-container"> <div style="display:flex;flex-direction:column" class="request"> <api-request class="request-panel" style="width:100%" method="${path.method}" , path="${path.path}" .parameters="${path.parameters}" .request_body="${path.requestBody}" .api_keys="${nonEmptyApiKeys}" .servers="${path.servers}" server-url="${path.servers && path.servers.length > 0 ? path.servers[0].url : this.selectedServer.computedUrl}" active-schema-tab="${this.defaultSchemaTab}" fill-defaults="${this.fillRequestWithDefault}" enable-console="${this.allowTry}" accept="${accept}" render-style="${this.renderStyle}" schema-style="${this.
|
|
79
|
+
return html` <div class="endpoint-body ${path.method}"> <div class="summary"> ${path.summary ? html`<div class="title">${path.summary}<div></div></div>` : path.shortSummary !== path.description ? html`<div class="title">${path.shortSummary}</div>` : ''} ${path.description ? html`<div class="m-markdown"> ${unsafeHTML(marked(path.description))}</div>` : ''} <slot name="${path.elementId}"></slot> ${pathSecurityTemplate.call(this, path.security)} ${codeSampleTabPanel} </div> <div class="req-resp-container"> <div style="display:flex;flex-direction:column" class="request"> <api-request class="request-panel" style="width:100%" method="${path.method}" , path="${path.path}" .parameters="${path.parameters}" .request_body="${path.requestBody}" .api_keys="${nonEmptyApiKeys}" .servers="${path.servers}" server-url="${path.servers && path.servers.length > 0 ? path.servers[0].url : this.selectedServer.computedUrl}" active-schema-tab="${this.defaultSchemaTab}" fill-defaults="${this.fillRequestWithDefault}" enable-console="${this.allowTry}" accept="${accept}" render-style="${this.renderStyle}" schema-style="${this.displaySchemaAsTable ? 'table' : 'tree'}" schema-expand-level="${this.schemaExpandLevel}" schema-description-expanded="${this.schemaDescriptionExpanded}" schema-hide-read-only="${this.schemaHideReadOnly}" fetch-credentials="${this.fetchCredentials}" exportparts="btn btn-fill btn-outline btn-try"> </api-request> </div> ${path.callbacks ? callbackTemplate.call(this, path.callbacks) : ''} <api-response class="request response" .responses="${path.responses}" active-schema-tab="${this.defaultSchemaTab}" render-style="${this.renderStyle}" schema-style="${this.displaySchemaAsTable ? 'table' : 'tree'}" schema-expand-level="${this.schemaExpandLevel}" schema-description-expanded="${this.schemaDescriptionExpanded}" schema-hide-write-only="${this.schemaHideWriteOnly}" selected-status="${Object.keys(path.responses || {})[0] || ''}" exportparts="btn--resp btn-fill--resp btn-outline--resp"> </api-response> </div> </div>`;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
export default function endpointTemplate() {
|
|
@@ -21,7 +21,7 @@ export function expandedEndpointBodyTemplate(path, tagName = '') {
|
|
|
21
21
|
|
|
22
22
|
const nonEmptyApiKeys = this.resolvedSpec.securitySchemes.filter(v => v.finalKeyValue && path.security && path.security.some(ps => ps[v.apiKeyId])) || [];
|
|
23
23
|
const codeSampleTabPanel = path.xCodeSamples ? codeSamplesTemplate.call(this, path.xCodeSamples) : '';
|
|
24
|
-
return html` ${this.renderStyle === 'read' ? html`<div class="divider" part="operation-divider"></div>` : ''} <div class="expanded-endpoint-body observe-me ${path.method}" part="section-operation ${path.elementId}" id="${path.elementId}"> ${this.renderStyle === 'focused' && tagName !== 'General ⦂' ? html`<h3 class="upper" style="font-weight:700"> ${tagName} </h3>` : ''} ${path.deprecated ? html`<div class="bold-text red-text"> DEPRECATED </div>` : ''} ${html` <h2> ${path.shortSummary || `${path.method.toUpperCase()} ${path.path}`}</h2> <div class='mono-font part="section-operation-url" regular-font-size' style="padding:8px 0;color:var(--fg3)"> ${path.isWebhook ? html`<span style="color:var(--primary-color)"> WEBHOOK </span>` : ''} <span part="label-operation-method" class="regular-font upper method-fg bold-text ${path.method}">${path.method}</span> <span part="label-operation-path">${path.path}</span> </div>`} ${path.description ? html`<div class="m-markdown"> ${unsafeHTML(marked(path.description))}</div>` : ''} <slot name="${path.elementId}"></slot> ${pathSecurityTemplate.call(this, path.security)} ${codeSampleTabPanel} <div class="expanded-req-resp-container"> <api-request class="request-panel" method="${path.method}" path="${path.path}" .parameters="${path.parameters}" .request_body="${path.requestBody}" .api_keys="${nonEmptyApiKeys}" .servers="${path.servers}" server-url="${path.servers && path.servers[0] && path.servers[0].url || this.selectedServer.computedUrl}" fill-defaults="${this.fillRequestWithDefault}" enable-console="${this.allowTry}" accept="${accept}" render-style="${this.renderStyle}" schema-style="${this.
|
|
24
|
+
return html` ${this.renderStyle === 'read' ? html`<div class="divider" part="operation-divider"></div>` : ''} <div class="expanded-endpoint-body observe-me ${path.method}" part="section-operation ${path.elementId}" id="${path.elementId}"> ${this.renderStyle === 'focused' && tagName !== 'General ⦂' ? html`<h3 class="upper" style="font-weight:700"> ${tagName} </h3>` : ''} ${path.deprecated ? html`<div class="bold-text red-text"> DEPRECATED </div>` : ''} ${html` <h2> ${path.shortSummary || `${path.method.toUpperCase()} ${path.path}`}</h2> <div class='mono-font part="section-operation-url" regular-font-size' style="padding:8px 0;color:var(--fg3)"> ${path.isWebhook ? html`<span style="color:var(--primary-color)"> WEBHOOK </span>` : ''} <span part="label-operation-method" class="regular-font upper method-fg bold-text ${path.method}">${path.method}</span> <span part="label-operation-path">${path.path}</span> </div>`} ${path.description ? html`<div class="m-markdown"> ${unsafeHTML(marked(path.description))}</div>` : ''} <slot name="${path.elementId}"></slot> ${pathSecurityTemplate.call(this, path.security)} ${codeSampleTabPanel} <div class="expanded-req-resp-container"> <api-request class="request-panel" method="${path.method}" path="${path.path}" .parameters="${path.parameters}" .request_body="${path.requestBody}" .api_keys="${nonEmptyApiKeys}" .servers="${path.servers}" server-url="${path.servers && path.servers[0] && path.servers[0].url || this.selectedServer.computedUrl}" fill-defaults="${this.fillRequestWithDefault}" enable-console="${this.allowTry}" accept="${accept}" render-style="${this.renderStyle}" schema-style="${this.displaySchemaAsTable ? 'table' : 'tree'}" active-schema-tab="${this.defaultSchemaTab}" schema-expand-level="${this.schemaExpandLevel}" schema-description-expanded="${this.schemaDescriptionExpanded}" schema-hide-read-only="${this.schemaHideReadOnly}" fetch-credentials="${this.fetchCredentials}" exportparts="btn btn-fill btn-outline btn-try"> </api-request> ${path.callbacks ? callbackTemplate.call(this, path.callbacks) : ''} <api-response class="response-panel" .responses="${path.responses}" render-style="${this.renderStyle}" schema-style="${this.displaySchemaAsTable ? 'table' : 'tree'}" active-schema-tab="${this.defaultSchemaTab}" schema-expand-level="${this.schemaExpandLevel}" schema-description-expanded="${this.schemaDescriptionExpanded}" schema-hide-write-only="${this.schemaHideWriteOnly}" selected-status="${Object.keys(path.responses || {})[0] || ''}" exportparts="btn--resp btn-fill--resp btn-outline--resp"> </api-response> </div> </div> `;
|
|
25
25
|
}
|
|
26
26
|
export default function expandedEndpointTemplate() {
|
|
27
27
|
return html` ${(this.resolvedSpec && this.resolvedSpec.tags || []).map(tag => html` <section id="${tag.elementId}" part="section-tag" class="regular-font section-gap--read-mode observe-me" style="border-top:1px solid var(--primary-color)"> <div class="title tag" part="label-tag-title">${tag.name}</div> <slot name="${tag.elementId}"></slot> <div class="regular-font-size"> ${unsafeHTML(`
|
|
@@ -47,7 +47,7 @@ export default function focusedEndpointTemplate() {
|
|
|
47
47
|
focusedTemplate = serverTemplate.call(this);
|
|
48
48
|
} else if (focusElId === 'section') {
|
|
49
49
|
focusedTemplate = html` <section id="section" class="observe-me"> <slot name="custom-section"></slot> </section>`;
|
|
50
|
-
} else if (focusElId.startsWith('cmp--') && this.
|
|
50
|
+
} else if (focusElId.startsWith('cmp--') && !this.hideComponents) {
|
|
51
51
|
focusedTemplate = componentsTemplate.call(this);
|
|
52
52
|
} else if (focusElId.startsWith('tag--')) {
|
|
53
53
|
const idToFocus = focusElId.indexOf('--', 4) > 0 ? focusElId.substring(0, focusElId.indexOf('--', 5)) : focusElId;
|
|
@@ -41,6 +41,6 @@ export default function navbarTemplate() {
|
|
|
41
41
|
return true;
|
|
42
42
|
}).map(p => html` <div class="nav-bar-path ${this.usePathInNavBar === 'true' ? 'small-font' : ''}" data-content-id="${p.elementId}" id="link-${p.elementId}" @click="${e => {
|
|
43
43
|
this.scrollToEventTarget(e, false);
|
|
44
|
-
}}"> <span style="line-break:anywhere;${p.deprecated ? 'filter:opacity(0.5)' : ''}"> ${this.usePathInNavBar === 'true' ? html`<span class="mono-font">${p.method.toUpperCase()} ${p.path}</span>` : p.summary || p.shortSummary} ${p.isWebhook ? '(Webhook)' : ''} </span> </div>`)} </div> </div> </slot> `)} ${this.resolvedSpec.components && this.
|
|
44
|
+
}}"> <span style="line-break:anywhere;${p.deprecated ? 'filter:opacity(0.5)' : ''}"> ${this.usePathInNavBar === 'true' ? html`<span class="mono-font">${p.method.toUpperCase()} ${p.path}</span>` : p.summary || p.shortSummary} ${p.isWebhook ? '(Webhook)' : ''} </span> </div>`)} </div> </div> </slot> `)} ${this.resolvedSpec.components && !this.hideComponents ? html` <div class="sticky-scroll-element"> <div id="link-components" class="nav-bar-section"> <div class="nav-bar-section-title">COMPONENTS</div> </div> </div> ${this.resolvedSpec.components.map(component => component.subComponents.filter(s => s.expanded).length ? html` <div class="nav-bar-tag" data-content-id="cmp--${component.name.toLowerCase()}" id="link-cmp--${component.name.toLowerCase()}" @click="${e => this.scrollToEventTarget(e, false)}"> ${component.name} </div> ${component.subComponents.filter(s => s.expanded).map(p => html` <div class="nav-bar-path" data-content-id="cmp--${p.id}" id="link-cmp--${p.id}" @click="${e => this.scrollToEventTarget(e, false)}"> <span> ${p.name} </span> </div>`)}` : '')}` : ''} </nav>`} </nav> `;
|
|
45
45
|
}
|
|
46
46
|
/* eslint-enable indent */
|
|
@@ -87,6 +87,7 @@ export function getTypeInfo(schema) {
|
|
|
87
87
|
readOrWriteOnly: info.readOrWriteOnly,
|
|
88
88
|
constraint: info.constraint,
|
|
89
89
|
defaultValue: info.default,
|
|
90
|
+
example: info.example,
|
|
90
91
|
allowedValues: info.allowedValues,
|
|
91
92
|
pattern: info.pattern,
|
|
92
93
|
schemaDescription: info.description,
|
|
@@ -348,19 +349,6 @@ function getExampleValuesFromSchemaRecursive(schema, config = {}) {
|
|
|
348
349
|
const value = getSampleValueByType(schema, config.propertyName, config.skipExampleStrings);
|
|
349
350
|
return [value];
|
|
350
351
|
}
|
|
351
|
-
|
|
352
|
-
function removeTitlesAndDescriptions(obj) {
|
|
353
|
-
if (typeof obj !== 'object' || obj === null) {
|
|
354
|
-
return;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
delete obj['::TITLE'];
|
|
358
|
-
delete obj['::DESCRIPTION'];
|
|
359
|
-
|
|
360
|
-
for (const k in obj) {
|
|
361
|
-
removeTitlesAndDescriptions(obj[k]);
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
352
|
/**
|
|
365
353
|
* For changing OpenAPI-Schema to an Object Notation,
|
|
366
354
|
* This Object would further be an input to UI Components to generate an Object-Tree
|
|
@@ -691,9 +679,6 @@ export function generateExample(examples, example, schema, rawMimeType, includeR
|
|
|
691
679
|
}
|
|
692
680
|
|
|
693
681
|
return samples.map((sample, sampleCounter) => {
|
|
694
|
-
const summary = sample['::TITLE'] || `Example ${sampleCounter + 1}`;
|
|
695
|
-
const description = sample['::DESCRIPTION'] || '';
|
|
696
|
-
removeTitlesAndDescriptions(sample);
|
|
697
682
|
let exampleValue = '';
|
|
698
683
|
|
|
699
684
|
if (mimeType.toLowerCase().includes('xml')) {
|
|
@@ -707,8 +692,8 @@ export function generateExample(examples, example, schema, rawMimeType, includeR
|
|
|
707
692
|
|
|
708
693
|
return {
|
|
709
694
|
exampleId: `Example-${sampleCounter}`,
|
|
710
|
-
exampleSummary:
|
|
711
|
-
exampleDescription:
|
|
695
|
+
exampleSummary: `Example ${sampleCounter + 1}`,
|
|
696
|
+
exampleDescription: '',
|
|
712
697
|
exampleType: mimeType,
|
|
713
698
|
exampleFormat: mimeType.toLowerCase().includes('xml') ? 'text' : outputType,
|
|
714
699
|
exampleValue
|
|
@@ -352,7 +352,7 @@ class ApiRequest extends _litElement.LitElement {
|
|
|
352
352
|
|
|
353
353
|
if (this.schemaStyle === 'table') {
|
|
354
354
|
reqBodySchemaHtml = (0, _litElement.html)` ${reqBodySchemaHtml} <schema-table class="${reqBody.mimeType.substring(reqBody.mimeType.indexOf('/') + 1)} pad-top-8" style="display:${this.selectedRequestBodyType === reqBody.mimeType ? 'block' : 'none'}" .data="${schemaAsObj}" schema-expand-level="${this.schemaExpandLevel}" schema-description-expanded="${this.schemaDescriptionExpanded}" schema-hide-read-only="${this.schemaHideReadOnly.includes(this.method)}" schema-hide-write-only="false"> </schema-table> `;
|
|
355
|
-
} else
|
|
355
|
+
} else {
|
|
356
356
|
reqBodySchemaHtml = (0, _litElement.html)` ${reqBodySchemaHtml} <schema-tree class="${reqBody.mimeType.substring(reqBody.mimeType.indexOf('/') + 1)} pad-top-8" style="display:${this.selectedRequestBodyType === reqBody.mimeType ? 'block' : 'none'}" .data="${schemaAsObj}" schema-expand-level="${this.schemaExpandLevel}" schema-description-expanded="${this.schemaDescriptionExpanded}" schema-hide-read-only="${this.schemaHideReadOnly.includes(this.method)}" schema-hide-write-only="false"> </schema-tree> `;
|
|
357
357
|
}
|
|
358
358
|
}
|
|
@@ -191,7 +191,7 @@ class ApiResponse extends _litElement.LitElement {
|
|
|
191
191
|
return (0, _litElement.html)` <pre style="color:var(--red)" class="${this.renderStyle === 'read' ? 'border pad-8-16' : 'border-top'}"> Schema not found</pre> `;
|
|
192
192
|
}
|
|
193
193
|
|
|
194
|
-
return (0, _litElement.html)` ${this.schemaStyle === 'table' ? (0, _litElement.html)` <schema-table render-style="${this.renderStyle}" .data="${mimeRespDetails.schemaTree}" class="example-panel ${this.renderStyle === 'read' ? 'border pad-8-16' : 'border-top pad-top-8'}" schema-expand-level="${this.schemaExpandLevel}" schema-description-expanded="${this.schemaDescriptionExpanded}" schema-hide-read-only="false" schema-hide-write-only="${this.schemaHideWriteOnly}">
|
|
194
|
+
return (0, _litElement.html)` ${this.schemaStyle === 'table' ? (0, _litElement.html)` <schema-table render-style="${this.renderStyle}" .data="${mimeRespDetails.schemaTree}" class="example-panel ${this.renderStyle === 'read' ? 'border pad-8-16' : 'border-top pad-top-8'}" schema-expand-level="${this.schemaExpandLevel}" schema-description-expanded="${this.schemaDescriptionExpanded}" schema-hide-read-only="false" schema-hide-write-only="${this.schemaHideWriteOnly}"> </schema-table> ` : (0, _litElement.html)` <schema-tree render-style="${this.renderStyle}" .data="${mimeRespDetails.schemaTree}" class="example-panel ${this.renderStyle === 'read' ? 'border pad-8-16' : 'pad-top-8'}" schema-expand-level="${this.schemaExpandLevel}" schema-description-expanded="${this.schemaDescriptionExpanded}" schema-hide-read-only="false" schema-hide-write-only="${this.schemaHideWriteOnly}"> </schema-tree>`}`;
|
|
195
195
|
}
|
|
196
196
|
/* eslint-enable indent */
|
|
197
197
|
|
|
@@ -29,15 +29,15 @@ class JsonTree extends _litElement.LitElement {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
static get styles() {
|
|
32
|
-
return [_fontStyles.default, _borderStyles.default, _inputStyles.default, (0, _litElement.css)`:host{display:flex}.json-tree{background:#333;color:#fff;padding:
|
|
32
|
+
return [_fontStyles.default, _borderStyles.default, _inputStyles.default, (0, _litElement.css)`:host{display:flex}.json-tree{background:#333;color:#fff;padding:12px;min-height:30px;font-family:var(--font-mono);font-size:var(--font-size-small);overflow:hidden;word-break:break-all;flex:1;line-height:calc(var(--font-size-small) + 6px)}.open-bracket{display:inline-block;padding:0 20px 0 0;cursor:pointer;border:1px solid transparent;border-radius:3px}.collapsed.open-bracket{padding-right:0}.tree>.open-bracket{margin-left:-2px}.open-bracket:hover{color:var(--primary-color);background-color:var(--hover-color);border:1px solid var(--border-color)}.inside-bracket{padding-left:16px;border-left:1px dotted var(--border-color)}.open-bracket.collapsed+.inside-bracket,.open-bracket.collapsed+.inside-bracket+.close-bracket{display:none}.close-bracket{margin-left:-2px}.string{color:var(--green)}.number{color:var(--blue)}.null{color:var(--red)}.boolean{color:var(--orange)}.object{color:#fff}.toolbar{display:none}.tree .toolbar{display:flex;justify-content:space-between;width:100%}.tree .item{border-bottom:1px dotted transparent}.toolbar-item{cursor:pointer;padding:5px 0 5px 1rem;margin:0 1rem!important;color:#38b3f9;flex-shrink:0}.tree .toolbar .toolbar-item{display:none}.inside-bracket.xxx-of{padding:5px 0;border-style:dotted;border-width:0 0 1px 0;border-color:var(--primary-color)}.schema-root-type.xxx-of{display:none}.toolbar-item:first-of-type{margin:0 2px 0 0}@media only screen and (min-width:576px){.key-descr{display:block}.tree .toolbar .toolbar-item{display:block}.toolbar{display:flex}}.toolbar-backup{position:absolute;right:6px;display:flex;align-items:center}`];
|
|
33
33
|
}
|
|
34
34
|
/* eslint-disable indent */
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
render() {
|
|
38
|
-
return (0, _litElement.html)` <div class="json-tree"> <div class="toolbar"> <button class="toolbar-copy-btn" part="btn btn-fill" @click="${e => {
|
|
38
|
+
return (0, _litElement.html)` <div class="json-tree tree"> <div class="toolbar"> <div> </div> <div class="toolbar-item"> <button class="toolbar-copy-btn" part="btn btn-fill" @click="${e => {
|
|
39
39
|
(0, _commonUtils.copyToClipboard)(JSON.stringify(this.data, null, 2), e);
|
|
40
|
-
}}">Copy</button> </div> ${this.generateTree(this.data, true)} </div> `;
|
|
40
|
+
}}">Copy</button> </div> </div> ${this.generateTree(this.data, true)} </div> `;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
generateTree(data, isLast = false) {
|
|
@@ -61,15 +61,13 @@ class SchemaTable extends _litElement.LitElement {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
static get styles() {
|
|
64
|
-
return [_fontStyles.default, _schemaStyles.default, (0, _litElement.css)`.table{font-size:var(--font-size-small);text-align:left;line-height:calc(var(--font-size-small) + 6px)}.table .tr{width:calc(100% - 5px);padding:0 0 0 5px;border-bottom:1px dotted var(--light-border-color)}.table .td{padding:4px 0}.table .key{width:240px}.key.deprecated .key-label{text-decoration:line-through}.table .key-type{white-space:normal;width:150px}.
|
|
64
|
+
return [_fontStyles.default, _schemaStyles.default, (0, _litElement.css)`.table{font-size:var(--font-size-small);text-align:left;line-height:calc(var(--font-size-small) + 6px)}.table .tr{width:calc(100% - 5px);padding:0 0 0 5px;border-bottom:1px dotted var(--light-border-color)}.table .td{padding:4px 0}.table .key{width:240px}.key.deprecated .key-label{text-decoration:line-through}.table .key-type{white-space:normal;width:150px}.obj-toggle{padding:0 2px;border-radius:2px;border:1px solid transparent;display:inline-block;margin-left:-16px;color:var(--primary-color);cursor:pointer;font-size:calc(var(--font-size-small) + 4px);font-family:var(--font-mono);background-clip:border-box}.obj-toggle:hover{border-color:var(--primary-color)}.tr.expanded+.object-body{display:block}.tr.collapsed+.object-body{display:none}`];
|
|
65
65
|
}
|
|
66
66
|
/* eslint-disable indent */
|
|
67
67
|
|
|
68
68
|
|
|
69
69
|
render() {
|
|
70
|
-
return (0, _litElement.html)` <div class="table ${this.
|
|
71
|
-
this.schemaDescriptionExpanded = this.schemaDescriptionExpanded === 'true' ? 'false' : 'true';
|
|
72
|
-
}}"> ${this.schemaDescriptionExpanded === 'true' ? 'Collapse descriptions' : 'Expand descriptions'} </div> </div> ${this.data && this.data['::description'] ? (0, _litElement.html)`<span class="m-markdown"> ${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(this.data['::description'] || ''))}</span>` : ''} <div style="border:1px solid var(--light-border-color)"> <div style="display:flex;background-color:var(--bg2);padding:8px 4px;border-bottom:1px solid var(--light-border-color)"> <div class="key" style="font-family:var(--font-regular);font-weight:700;color:var(--fg)"> Field </div> <div class="key-type" style="font-family:var(--font-regular);font-weight:700;color:var(--fg)"> Type </div> <div class="key-descr" style="font-family:var(--font-regular);font-weight:700;color:var(--fg)"> Description </div> </div> ${this.data ? (0, _litElement.html)`${this.generateTree(this.data['::type'] === 'array' ? this.data['::props'] : this.data, this.data['::type'])}` : ''} </div> </div> `;
|
|
70
|
+
return (0, _litElement.html)` <div class="table"> ${this.data && this.data['::description'] ? (0, _litElement.html)`<span class="m-markdown"> ${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(this.data['::description'] || ''))}</span>` : ''} <div style="border:1px solid var(--light-border-color)"> <div style="display:flex;background-color:var(--bg2);padding:8px 4px;border-bottom:1px solid var(--light-border-color)"> <div class="key" style="font-family:var(--font-regular);font-weight:700;color:var(--fg)"> Field </div> <div class="key-type" style="font-family:var(--font-regular);font-weight:700;color:var(--fg)"> Type </div> <div class="key-descr" style="font-family:var(--font-regular);font-weight:700;color:var(--fg)"> Description </div> </div> ${this.data ? (0, _litElement.html)`${this.generateTree(this.data['::type'] === 'array' ? this.data['::props'] : this.data, this.data['::type'])}` : ''} </div> </div> `;
|
|
73
71
|
}
|
|
74
72
|
|
|
75
73
|
generateTree(data, dataType = 'object', key = '', description = '', schemaLevel = 0, indentLevel = 0) {
|
|
@@ -117,7 +115,7 @@ class SchemaTable extends _litElement.LitElement {
|
|
|
117
115
|
}
|
|
118
116
|
|
|
119
117
|
if (typeof data === 'object') {
|
|
120
|
-
return (0, _litElement.html)` ${newSchemaLevel >= 0 && key ? (0, _litElement.html)` <div class="tr ${newSchemaLevel <= this.schemaExpandLevel ? 'expanded' : 'collapsed'} ${data['::type']}" data-obj="${keyLabel}"> <div class="td key ${data['::deprecated'] ? 'deprecated' : ''}" style="padding-left:${leftPadding}px"> ${keyLabel || keyDescr ? (0, _litElement.html)` <span class="obj-toggle ${newSchemaLevel < this.schemaExpandLevel ? 'expanded' : 'collapsed'}" data-obj="${keyLabel}" @click="${e => this.toggleObjectExpand(e, keyLabel)}"> ${schemaLevel < this.schemaExpandLevel ? '-' : '+'} </span>` : ''} ${data['::type'] === 'xxx-of-option' || data['::type'] === 'xxx-of-array' || key.startsWith('::OPTION') ? (0, _litElement.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, _litElement.html)`<span class="key-label" style="display:inline-block;margin-left:-6px"> ${keyLabel.substring(0, keyLabel.length - 1)}</span><span style="color:var(--red)">*</span>` : (0, _litElement.html)`<span class="key-label" style="display:inline-block;margin-left:-6px">${keyLabel === '::props' ? '' : keyLabel}</span>`} ${data['::type'] === 'xxx-of' && dataType === 'array' ? (0, _litElement.html)`<span style="color:var(--primary-color)">ARRAY</span>` : ''} </div> <div class="td key-type">${(data['::type'] || '').includes('xxx-of') ? '' : detailObjType}</div> <div class="td key-descr m-markdown-small" style="line-height:1.7">${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(description || ''))}</div> </div>` : (0, _litElement.html)` ${data['::type'] === 'array' && dataType === 'array' ? (0, _litElement.html)`<div class="tr"> <div class="td"> ${dataType} </div> </div>` : ''} `} <div class="object-body"> ${Array.isArray(data) && data[0] ? (0, _litElement.html)`${this.generateTree(data[0], 'xxx-of-option', '::ARRAY~OF', '', newSchemaLevel, newIndentLevel)}` : (0, _litElement.html)
|
|
118
|
+
return (0, _litElement.html)` ${newSchemaLevel >= 0 && key ? (0, _litElement.html)` <div class="tr ${newSchemaLevel <= this.schemaExpandLevel ? 'expanded' : 'collapsed'} ${data['::type']}" data-obj="${keyLabel}"> <div class="td key ${data['::deprecated'] ? 'deprecated' : ''}" style="padding-left:${leftPadding}px"> ${keyLabel || keyDescr ? (0, _litElement.html)` <span class="obj-toggle ${newSchemaLevel < this.schemaExpandLevel ? 'expanded' : 'collapsed'}" data-obj="${keyLabel}" @click="${e => this.toggleObjectExpand(e, keyLabel)}"> ${schemaLevel < this.schemaExpandLevel ? '-' : '+'} </span>` : ''} ${data['::type'] === 'xxx-of-option' || data['::type'] === 'xxx-of-array' || key.startsWith('::OPTION') ? (0, _litElement.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, _litElement.html)`<span class="key-label" style="display:inline-block;margin-left:-6px"> ${keyLabel.substring(0, keyLabel.length - 1)}</span><span style="color:var(--red)">*</span>` : (0, _litElement.html)`<span class="key-label" style="display:inline-block;margin-left:-6px">${keyLabel === '::props' ? '' : keyLabel}</span>`} ${data['::type'] === 'xxx-of' && dataType === 'array' ? (0, _litElement.html)`<span style="color:var(--primary-color)">ARRAY</span>` : ''} </div> <div class="td key-type">${(data['::type'] || '').includes('xxx-of') ? '' : detailObjType}</div> <div class="td key-descr m-markdown-small" style="line-height:1.7">${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(description || ''))}</div> </div>` : (0, _litElement.html)` ${data['::type'] === 'array' && dataType === 'array' ? (0, _litElement.html)`<div class="tr"> <div class="td"> ${dataType} </div> </div>` : ''} `} <div class="object-body"> ${Array.isArray(data) && data[0] ? (0, _litElement.html)`${this.generateTree(data[0], 'xxx-of-option', '::ARRAY~OF', '', newSchemaLevel, newIndentLevel)}` : (0, _litElement.html)` ${Object.keys(data).map(dataKey => dataKey.startsWith('::') && data[dataKey]['::type'] !== 'array' && data[dataKey]['::type'] !== 'object' ? '' : (0, _litElement.html)`${this.generateTree(data[dataKey]['::type'] === 'array' ? data[dataKey]['::props'] : data[dataKey], data[dataKey]['::type'], dataKey, data[dataKey]['::description'], newSchemaLevel, newIndentLevel)}`)}`} <div> </div></div>`;
|
|
121
119
|
} // For Primitive Data types
|
|
122
120
|
|
|
123
121
|
|
|
@@ -126,6 +124,7 @@ class SchemaTable extends _litElement.LitElement {
|
|
|
126
124
|
readOrWriteOnly,
|
|
127
125
|
constraint,
|
|
128
126
|
defaultValue,
|
|
127
|
+
example,
|
|
129
128
|
allowedValues,
|
|
130
129
|
pattern,
|
|
131
130
|
schemaDescription,
|
|
@@ -142,7 +141,7 @@ class SchemaTable extends _litElement.LitElement {
|
|
|
142
141
|
}
|
|
143
142
|
|
|
144
143
|
const dataTypeCss = type.replace(/┃.*/g, '').replace(/[^a-zA-Z0-9+]/g, '').substring(0, 4).toLowerCase();
|
|
145
|
-
return (0, _litElement.html)` <div class="tr primitive"> <div class="td key ${deprecated ? 'deprecated' : ''}" style="padding-left:${leftPadding}px"> ${keyLabel && keyLabel.endsWith('*') ? (0, _litElement.html)`<span class="key-label">${keyLabel.substring(0, keyLabel.length - 1)}</span><span style="color:var(--red)">*</span>` : key.startsWith('::OPTION') ? (0, _litElement.html)`<span class="xxx-of-key">${keyLabel}</span><span class="xxx-of-descr">${keyDescr}</span>` : (0, _litElement.html)`${keyLabel ? (0, _litElement.html)`<span class="key-label"> ${keyLabel}</span>` : (0, _litElement.html)`<span class="xxx-of-descr">${schemaTitle}</span>`}`} </div> <div class="td key-type ${dataTypeCss}"> ${dataType === 'array' ? `${type}[]` : type} <span style="font-family:var(--font-mono)" title="${readOrWriteOnly === '🆁' && 'Read only attribute' || readOrWriteOnly === '🆆' && 'Write only attribute' || ''}"> ${readOrWriteOnly} </span> </div> <div class="td key-descr"> ${dataType === 'array' ? (0, _litElement.html)`<span class="m-markdown-small">${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(description))}</span>` : ''}
|
|
144
|
+
return (0, _litElement.html)` <div class="tr primitive"> <div class="td key ${deprecated ? 'deprecated' : ''}" style="padding-left:${leftPadding}px"> ${keyLabel && keyLabel.endsWith('*') ? (0, _litElement.html)`<span class="key-label">${keyLabel.substring(0, keyLabel.length - 1)}</span><span style="color:var(--red)">*</span>` : key.startsWith('::OPTION') ? (0, _litElement.html)`<span class="xxx-of-key">${keyLabel}</span><span class="xxx-of-descr">${keyDescr}</span>` : (0, _litElement.html)`${keyLabel ? (0, _litElement.html)`<span class="key-label"> ${keyLabel}</span>` : (0, _litElement.html)`<span class="xxx-of-descr">${schemaTitle}</span>`}`} </div> <div class="td key-type ${dataTypeCss}"> ${dataType === 'array' ? `${type}[]` : type} <span style="font-family:var(--font-mono)" title="${readOrWriteOnly === '🆁' && 'Read only attribute' || readOrWriteOnly === '🆆' && 'Write only attribute' || ''}"> ${readOrWriteOnly} </span> </div> <div class="td key-descr"> ${dataType === 'array' ? (0, _litElement.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" title="${readOrWriteOnly === '🆁' && 'Read only attribute' || readOrWriteOnly === '🆆' && 'Write only attribute' || ''}"> ${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(`${readOrWriteOnly && `${readOrWriteOnly} ` || ''}${dataType === 'array' && description || `${schemaTitle ? `**${schemaTitle}:**` : ''} ${schemaDescription}` || ''}`))} </span> ${this.schemaDescriptionExpanded ? (0, _litElement.html)` ${constraint ? (0, _litElement.html)`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Constraints: </span>${constraint}</div><br>` : ''} ${defaultValue ? (0, _litElement.html)`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Default: </span>${defaultValue}</div><br>` : ''} ${allowedValues ? (0, _litElement.html)`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Allowed: </span>${allowedValues}</div><br>` : ''} ${pattern ? (0, _litElement.html)`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Pattern: </span>${pattern}</div><br>` : ''} ${example ? (0, _litElement.html)`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Example: </span>${example}</div><br>` : ''}` : ''} </div> </div> `;
|
|
146
145
|
}
|
|
147
146
|
/* eslint-enable indent */
|
|
148
147
|
|
|
@@ -63,15 +63,18 @@ class SchemaTree extends _litElement.LitElement {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
static get styles() {
|
|
66
|
-
return [_fontStyles.default, _schemaStyles.default, _borderStyles.default, (0, _litElement.css)`.tree{min-height:30px;background:#333;padding:
|
|
66
|
+
return [_fontStyles.default, _schemaStyles.default, _borderStyles.default, (0, _litElement.css)`.tree{min-height:30px;background:#333;padding:12px;color:#fff;font-size:var(--font-size-small);text-align:left;line-height:calc(var(--font-size-small) + 6px)}.tree .key{max-width:300px}.key.deprecated .key-label{text-decoration:line-through}.open-bracket{display:inline-block;padding:0 20px 0 0;cursor:pointer;border:1px solid transparent;border-radius:3px}.collapsed .open-bracket{padding-right:0}.td.key>.open-bracket:first-child{margin-left:-2px}.open-bracket:hover{color:var(--primary-color);background-color:var(--hover-color);border:1px solid var(--border-color)}.close-bracket{display:inline-block;font-family:var(--font-mono);margin-left:-2px}.tr.collapsed .close-bracket{margin-left:0}.tr.collapsed+.inside-bracket,.tr.collapsed+.inside-bracket+.close-bracket{display:none}.inside-bracket.array,.inside-bracket.object{border-left:1px dotted var(--border-color)}.inside-bracket.xxx-of{padding:5px 0;border-style:dotted;border-width:0 0 1px 0;border-color:var(--primary-color)}`];
|
|
67
67
|
}
|
|
68
68
|
/* eslint-disable indent */
|
|
69
69
|
|
|
70
70
|
|
|
71
71
|
render() {
|
|
72
|
-
return (0, _litElement.html)` <div class="tree
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
return (0, _litElement.html)` <div class="tree"> <div class="toolbar"> ${this.data && this.data['::description'] ? (0, _litElement.html)`<span class="m-markdown" style="margin-block-start:0"> ${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(this.data['::description'] || ''))}</span>` : (0, _litElement.html)`<div> </div>`} <div class="toolbar-item" @click="${() => this.toggleSchemaDescription()}"> ${this.schemaDescriptionExpanded === 'true' ? 'Collapse descriptions' : 'Expand descriptions'} </div> </div> ${this.data ? (0, _litElement.html)`${this.generateTree(this.data['::type'] === 'array' ? this.data['::props'] : this.data, this.data['::type'])}` : (0, _litElement.html)`<span class="mono-font" style="color:var(--red)"> Schema not found </span>`} </div> `;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
toggleSchemaDescription() {
|
|
76
|
+
this.schemaDescriptionExpanded = !this.schemaDescriptionExpanded;
|
|
77
|
+
this.requestUpdate();
|
|
75
78
|
}
|
|
76
79
|
|
|
77
80
|
generateTree(data, dataType = 'object', key = '', description = '', schemaLevel = 0, indentLevel = 0) {
|
|
@@ -164,6 +167,7 @@ class SchemaTree extends _litElement.LitElement {
|
|
|
164
167
|
readOrWriteOnly,
|
|
165
168
|
constraint,
|
|
166
169
|
defaultValue,
|
|
170
|
+
example,
|
|
167
171
|
allowedValues,
|
|
168
172
|
pattern,
|
|
169
173
|
schemaDescription,
|
|
@@ -180,7 +184,7 @@ class SchemaTree extends _litElement.LitElement {
|
|
|
180
184
|
}
|
|
181
185
|
|
|
182
186
|
const dataTypeCss = type.replace(/┃.*/g, '').replace(/[^a-zA-Z0-9+]/g, '').substring(0, 4).toLowerCase();
|
|
183
|
-
return (0, _litElement.html)` <div class="tr primitive"> <div class="td key ${deprecated ? 'deprecated' : ''}" style="min-width:${minFieldColWidth}px"> ${keyLabel.endsWith('*') ? (0, _litElement.html)`<span class="key-label">${keyLabel.substring(0, keyLabel.length - 1)}</span><span style="color:var(--red)">*</span>:` : key.startsWith('::OPTION') ? (0, _litElement.html)`<span class="key-label xxx-of-key">${keyLabel}</span><span class="xxx-of-descr">${keyDescr}</span>` : schemaLevel > 0 ? (0, _litElement.html)`<span class="key-label">${keyLabel}:</span>` : ''} <span class="${dataTypeCss}"> ${dataType === 'array' ? `${type}[]` : `${type}`} </span> </div> <div class="td key-descr"> <span class="m-markdown-small" style="font-family:var(--font-mono);vertical-align:middle" title="${readOrWriteOnly === '🆁' && 'Read only attribute' || readOrWriteOnly === '🆆' && 'Write only attribute' || ''}"> ${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(`${readOrWriteOnly && `${readOrWriteOnly} ` || ''}${dataType === 'array' && description || `${schemaTitle ? `**${schemaTitle}:**` : ''} ${schemaDescription}` || ''}`))} </span> ${constraint ? (0, _litElement.html)`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Constraints: </span>${constraint}</div>` : ''} ${defaultValue ? (0, _litElement.html)`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Default: </span>${defaultValue}</div>` : ''} ${allowedValues ? (0, _litElement.html)`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Allowed: </span>${allowedValues}</div>` : ''} ${pattern ? (0, _litElement.html)`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Pattern: </span>${pattern}</div>` : ''} </div> </div> `;
|
|
187
|
+
return (0, _litElement.html)` <div class="tr primitive"> <div class="td key ${deprecated ? 'deprecated' : ''}" style="min-width:${minFieldColWidth}px"> ${keyLabel.endsWith('*') ? (0, _litElement.html)`<span class="key-label">${keyLabel.substring(0, keyLabel.length - 1)}</span><span style="color:var(--red)">*</span>:` : key.startsWith('::OPTION') ? (0, _litElement.html)`<span class="key-label xxx-of-key">${keyLabel}</span><span class="xxx-of-descr">${keyDescr}</span>` : schemaLevel > 0 ? (0, _litElement.html)`<span class="key-label">${keyLabel}:</span>` : ''} <span class="${dataTypeCss}"> ${dataType === 'array' ? `${type}[]` : `${type}`} </span> </div> <div class="td key-descr"> <span class="m-markdown-small" style="font-family:var(--font-mono);vertical-align:middle" title="${readOrWriteOnly === '🆁' && 'Read only attribute' || readOrWriteOnly === '🆆' && 'Write only attribute' || ''}"> ${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(`${readOrWriteOnly && `${readOrWriteOnly} ` || ''}${dataType === 'array' && description || `${schemaTitle ? `**${schemaTitle}:**` : ''} ${schemaDescription}` || ''}`))} </span> ${this.schemaDescriptionExpanded ? (0, _litElement.html)` ${constraint ? (0, _litElement.html)`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Constraints: </span>${constraint}</div><br>` : ''} ${defaultValue ? (0, _litElement.html)`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Default: </span>${defaultValue}</div><br>` : ''} ${allowedValues ? (0, _litElement.html)`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Allowed: </span>${allowedValues}</div><br>` : ''} ${pattern ? (0, _litElement.html)`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Pattern: </span>${pattern}</div><br>` : ''} ${example ? (0, _litElement.html)`<div style="display:inline-block;line-break:anywhere;margin-right:8px"><span class="bold-text">Example: </span>${example}</div><br>` : ''}` : ''} </div> </div> `;
|
|
184
188
|
}
|
|
185
189
|
/* eslint-enable indent */
|
|
186
190
|
|
|
@@ -127,17 +127,16 @@ class OpenApiExplorer extends _litElement.LitElement {
|
|
|
127
127
|
attribute: 'fill-defaults'
|
|
128
128
|
},
|
|
129
129
|
// Schema Styles
|
|
130
|
-
|
|
131
|
-
type:
|
|
132
|
-
attribute: '
|
|
130
|
+
displaySchemaAsTable: {
|
|
131
|
+
type: Boolean,
|
|
132
|
+
attribute: 'table'
|
|
133
133
|
},
|
|
134
134
|
schemaExpandLevel: {
|
|
135
135
|
type: Number,
|
|
136
136
|
attribute: 'schema-expand-level'
|
|
137
137
|
},
|
|
138
138
|
schemaDescriptionExpanded: {
|
|
139
|
-
type: String
|
|
140
|
-
attribute: 'schema-description-expanded'
|
|
139
|
+
type: String
|
|
141
140
|
},
|
|
142
141
|
// API Server
|
|
143
142
|
serverUrl: {
|
|
@@ -169,9 +168,9 @@ class OpenApiExplorer extends _litElement.LitElement {
|
|
|
169
168
|
type: String,
|
|
170
169
|
attribute: 'show-server-selection'
|
|
171
170
|
},
|
|
172
|
-
|
|
173
|
-
type:
|
|
174
|
-
attribute: '
|
|
171
|
+
hideComponents: {
|
|
172
|
+
type: Boolean,
|
|
173
|
+
attribute: 'hide-components'
|
|
175
174
|
},
|
|
176
175
|
// Main Colors and Font
|
|
177
176
|
primaryColor: {
|
|
@@ -290,10 +289,6 @@ class OpenApiExplorer extends _litElement.LitElement {
|
|
|
290
289
|
this.renderStyle = 'focused';
|
|
291
290
|
this.explorerLocation = this.explorerLocation || (0, _commonUtils.getCurrentElement)();
|
|
292
291
|
|
|
293
|
-
if (!this.schemaStyle || !'tree, table,'.includes(`${this.schemaStyle},`)) {
|
|
294
|
-
this.schemaStyle = 'tree';
|
|
295
|
-
}
|
|
296
|
-
|
|
297
292
|
if (!this.defaultSchemaTab || !'body, model,'.includes(`${this.defaultSchemaTab},`)) {
|
|
298
293
|
this.defaultSchemaTab = 'model';
|
|
299
294
|
}
|
|
@@ -353,10 +348,6 @@ class OpenApiExplorer extends _litElement.LitElement {
|
|
|
353
348
|
this.allowAuthentication = 'true';
|
|
354
349
|
}
|
|
355
350
|
|
|
356
|
-
if (!this.showComponents || !'true false'.includes(this.showComponents)) {
|
|
357
|
-
this.showComponents = 'true';
|
|
358
|
-
}
|
|
359
|
-
|
|
360
351
|
if (!this.fetchCredentials || !'omit, same-origin, include,'.includes(`${this.fetchCredentials},`)) {
|
|
361
352
|
this.fetchCredentials = '';
|
|
362
353
|
}
|
|
@@ -5,6 +5,6 @@ exports.default = void 0;
|
|
|
5
5
|
|
|
6
6
|
var _litElement = require("lit-element");
|
|
7
7
|
|
|
8
|
-
var _default = (0, _litElement.css)`*,:after,:before{box-sizing:border-box}.tr{display:flex;flex:none;width:100%;box-sizing:content-box;border-bottom:1px dotted transparent}.td{display:block;flex:0 0 auto}.key{font-family:var(--font-mono);white-space:normal;word-break:break-all}.
|
|
8
|
+
var _default = (0, _litElement.css)`*,:after,:before{box-sizing:border-box}.tr{display:flex;flex:none;width:100%;box-sizing:content-box;border-bottom:1px dotted transparent}.td{display:block;flex:0 0 auto}.key{font-family:var(--font-mono);white-space:normal;word-break:break-all}.key-descr{font-family:var(--font-regular);flex-shrink:1;text-overflow:ellipsis;overflow:hidden;display:none;max-height:auto}.toolbar{display:none}.tr.xxx-of{border-top:1px dotted var(--primary-color)}.xxx-of-key{font-size:calc(var(--font-size-small) - 2px);font-weight:700;background-color:var(--primary-color);color:var(--primary-btn-text-color);border-radius:2px;line-height:calc(var(--font-size-small) + 6px);padding:0 5px;margin-bottom:1px;display:inline-block}.xxx-of-descr{font-family:var(--font-regular);color:var(--primary-color);font-size:calc(var(--font-size-small) - 1px);margin-left:2px}.bina,.byte,.date,.emai,.host,.ipv4,.pass,.stri,.string,.uri,.url,.uuid{color:var(--green)}.deci .blue,.doub,.floa,.int3,.int6,.inte,.numb,.number{color:var(--blue)}.null{color:var(--red)}.bool,.boolean{color:var(--orange)}.enum{color:var(--yellow)}.tree .toolbar{display:flex;justify-content:space-between}.toolbar{width:100%}.toolbar-item{cursor:pointer;padding:5px 0 5px 1rem;margin:0 1rem!important;color:#38b3f9;flex-shrink:0}.tree .toolbar .toolbar-item{display:none}.schema-root-type{cursor:auto;color:var(--fg2);font-weight:700;text-transform:uppercase}.schema-root-type.xxx-of{display:none}.toolbar-item:first-of-type{margin:0 2px 0 0}@media only screen and (min-width:576px){.key-descr{display:block}.tree .toolbar .toolbar-item{display:block}.toolbar{display:flex}}`;
|
|
9
9
|
|
|
10
10
|
exports.default = _default;
|
|
@@ -7,6 +7,6 @@ var _litElement = require("lit-element");
|
|
|
7
7
|
|
|
8
8
|
/* eslint-disable indent */
|
|
9
9
|
function callbackTemplate(callbacks) {
|
|
10
|
-
return (0, _litElement.html)` <div class="api-request col regular-font request-panel ${this.renderStyle}-mode"> ${Object.entries(callbacks).map(kv => (0, _litElement.html)` <div class="${this.renderStyle}-request"> <div class="req-res-title">CALLBACKS</div> <div class="table-title">${kv[0]}</div> ${Object.entries(kv[1]).map(pathObj => (0, _litElement.html)` <div class="mono-font small-font-size" style="display:flex"> <div style="width:100%"> ${Object.entries(pathObj[1]).map(method => (0, _litElement.html)` <div> <div style="margin-top:12px"> <div class="method method-fg ${method[0]}" style="width:70px;border:none;margin:0;padding:0;line-height:20px;vertical-align:baseline;text-align:left"> <span style="font-size:20px"> ⥄ </span> ${method[0]} </div> <span style="line-height:20px;vertical-align:baseline">${pathObj[0]} </span> </div> <div class="expanded-req-resp-container"> <api-request class="request-panel" callback="true" method="${method[0] || ''}" , path="${pathObj[0] || ''}" .parameters="${method[1] && method[1].parameters || ''}" .request_body="${method[1] && method[1].requestBody || ''}" fill-defaults="${this.fillRequestWithDefault}" enable-console="false" render-style="${this.renderStyle}" schema-style="${this.
|
|
10
|
+
return (0, _litElement.html)` <div class="api-request col regular-font request-panel ${this.renderStyle}-mode"> ${Object.entries(callbacks).map(kv => (0, _litElement.html)` <div class="${this.renderStyle}-request"> <div class="req-res-title">CALLBACKS</div> <div class="table-title">${kv[0]}</div> ${Object.entries(kv[1]).map(pathObj => (0, _litElement.html)` <div class="mono-font small-font-size" style="display:flex"> <div style="width:100%"> ${Object.entries(pathObj[1]).map(method => (0, _litElement.html)` <div> <div style="margin-top:12px"> <div class="method method-fg ${method[0]}" style="width:70px;border:none;margin:0;padding:0;line-height:20px;vertical-align:baseline;text-align:left"> <span style="font-size:20px"> ⥄ </span> ${method[0]} </div> <span style="line-height:20px;vertical-align:baseline">${pathObj[0]} </span> </div> <div class="expanded-req-resp-container"> <api-request class="request-panel" callback="true" method="${method[0] || ''}" , path="${pathObj[0] || ''}" .parameters="${method[1] && method[1].parameters || ''}" .request_body="${method[1] && method[1].requestBody || ''}" fill-defaults="${this.fillRequestWithDefault}" enable-console="false" render-style="${this.renderStyle}" schema-style="${this.displaySchemaAsTable ? 'table' : 'tree'}" active-schema-tab="${this.defaultSchemaTab}" schema-expand-level="${this.schemaExpandLevel}" schema-description-expanded="${this.schemaDescriptionExpanded}" schema-hide-read-only="${this.schemaHideReadOnly}" fetch-credentials="${this.fetchCredentials}" exportparts="btn btn-fill btn-outline btn-try"> </api-request> <api-response callback="true" .responses="${method[1] && method[1].responses}" render-style="${this.renderStyle}" schema-style="${this.displaySchemaAsTable ? 'table' : 'tree'}" active-schema-tab="${this.defaultSchemaTab}" schema-expand-level="${this.schemaExpandLevel}" schema-description-expanded="${this.schemaDescriptionExpanded}" exportparts="btn--resp btn-fill--resp btn-outline--resp"> </api-response> </div> </div> `)} </div> </div> `)} </div> `)} </div> `;
|
|
11
11
|
}
|
|
12
12
|
/* eslint-enable indent */
|
|
@@ -18,7 +18,7 @@ require("../components/schema-tree");
|
|
|
18
18
|
/* eslint-disable no-console */
|
|
19
19
|
function componentBodyTemplate(sComponent) {
|
|
20
20
|
const formdataPartSchema = (0, _schemaUtils.schemaInObjectNotation)(sComponent.component, {});
|
|
21
|
-
return (0, _litElement.html)` <div class="expanded-endpoint-body observe-me ${sComponent.name}" id="cmp--${sComponent.id}"> <h2>${sComponent.name}</h2> <div class="mono-font regular-font-size" style="padding:8px 0;color:var(--fg2)">
|
|
21
|
+
return (0, _litElement.html)` <div class="expanded-endpoint-body observe-me ${sComponent.name}" id="cmp--${sComponent.id}"> <h2>${sComponent.name}</h2> <div class="mono-font regular-font-size" style="padding:8px 0;color:var(--fg2)"> ${this.displaySchemaAsTable ? (0, _litElement.html)`<schema-table .data="${formdataPartSchema}" schema-expand-level="${this.schemaExpandLevel}" schema-description-expanded="${this.schemaDescriptionExpanded}" schema-hide-read-only="false" schema-hide-write-only="false"> </schema-table>` : (0, _litElement.html)`<schema-tree .data="${formdataPartSchema}" schema-expand-level="${this.schemaExpandLevel}" schema-description-expanded="${this.schemaDescriptionExpanded}" schema-hide-read-only="false" schema-hide-write-only="false"> </schema-tree>`} </div> </div> `;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
function componentsTemplate() {
|
|
@@ -93,7 +93,7 @@ function endpointBodyTemplate(path) {
|
|
|
93
93
|
|
|
94
94
|
const nonEmptyApiKeys = this.resolvedSpec.securitySchemes.filter(v => v.finalKeyValue && path.security && path.security.some(ps => ps[v.apiKeyId])) || [];
|
|
95
95
|
const codeSampleTabPanel = path.xCodeSamples ? (0, _codeSamplesTemplate.default)(path.xCodeSamples) : '';
|
|
96
|
-
return (0, _litElement.html)` <div class="endpoint-body ${path.method}"> <div class="summary"> ${path.summary ? (0, _litElement.html)`<div class="title">${path.summary}<div></div></div>` : path.shortSummary !== path.description ? (0, _litElement.html)`<div class="title">${path.shortSummary}</div>` : ''} ${path.description ? (0, _litElement.html)`<div class="m-markdown"> ${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(path.description))}</div>` : ''} <slot name="${path.elementId}"></slot> ${_securitySchemeTemplate.pathSecurityTemplate.call(this, path.security)} ${codeSampleTabPanel} </div> <div class="req-resp-container"> <div style="display:flex;flex-direction:column" class="request"> <api-request class="request-panel" style="width:100%" method="${path.method}" , path="${path.path}" .parameters="${path.parameters}" .request_body="${path.requestBody}" .api_keys="${nonEmptyApiKeys}" .servers="${path.servers}" server-url="${path.servers && path.servers.length > 0 ? path.servers[0].url : this.selectedServer.computedUrl}" active-schema-tab="${this.defaultSchemaTab}" fill-defaults="${this.fillRequestWithDefault}" enable-console="${this.allowTry}" accept="${accept}" render-style="${this.renderStyle}" schema-style="${this.
|
|
96
|
+
return (0, _litElement.html)` <div class="endpoint-body ${path.method}"> <div class="summary"> ${path.summary ? (0, _litElement.html)`<div class="title">${path.summary}<div></div></div>` : path.shortSummary !== path.description ? (0, _litElement.html)`<div class="title">${path.shortSummary}</div>` : ''} ${path.description ? (0, _litElement.html)`<div class="m-markdown"> ${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(path.description))}</div>` : ''} <slot name="${path.elementId}"></slot> ${_securitySchemeTemplate.pathSecurityTemplate.call(this, path.security)} ${codeSampleTabPanel} </div> <div class="req-resp-container"> <div style="display:flex;flex-direction:column" class="request"> <api-request class="request-panel" style="width:100%" method="${path.method}" , path="${path.path}" .parameters="${path.parameters}" .request_body="${path.requestBody}" .api_keys="${nonEmptyApiKeys}" .servers="${path.servers}" server-url="${path.servers && path.servers.length > 0 ? path.servers[0].url : this.selectedServer.computedUrl}" active-schema-tab="${this.defaultSchemaTab}" fill-defaults="${this.fillRequestWithDefault}" enable-console="${this.allowTry}" accept="${accept}" render-style="${this.renderStyle}" schema-style="${this.displaySchemaAsTable ? 'table' : 'tree'}" schema-expand-level="${this.schemaExpandLevel}" schema-description-expanded="${this.schemaDescriptionExpanded}" schema-hide-read-only="${this.schemaHideReadOnly}" fetch-credentials="${this.fetchCredentials}" exportparts="btn btn-fill btn-outline btn-try"> </api-request> </div> ${path.callbacks ? _callbackTemplate.default.call(this, path.callbacks) : ''} <api-response class="request response" .responses="${path.responses}" active-schema-tab="${this.defaultSchemaTab}" render-style="${this.renderStyle}" schema-style="${this.displaySchemaAsTable ? 'table' : 'tree'}" schema-expand-level="${this.schemaExpandLevel}" schema-description-expanded="${this.schemaDescriptionExpanded}" schema-hide-write-only="${this.schemaHideWriteOnly}" selected-status="${Object.keys(path.responses || {})[0] || ''}" exportparts="btn--resp btn-fill--resp btn-outline--resp"> </api-response> </div> </div>`;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
function endpointTemplate() {
|
|
@@ -36,7 +36,7 @@ function expandedEndpointBodyTemplate(path, tagName = '') {
|
|
|
36
36
|
|
|
37
37
|
const nonEmptyApiKeys = this.resolvedSpec.securitySchemes.filter(v => v.finalKeyValue && path.security && path.security.some(ps => ps[v.apiKeyId])) || [];
|
|
38
38
|
const codeSampleTabPanel = path.xCodeSamples ? _codeSamplesTemplate.default.call(this, path.xCodeSamples) : '';
|
|
39
|
-
return (0, _litElement.html)` ${this.renderStyle === 'read' ? (0, _litElement.html)`<div class="divider" part="operation-divider"></div>` : ''} <div class="expanded-endpoint-body observe-me ${path.method}" part="section-operation ${path.elementId}" id="${path.elementId}"> ${this.renderStyle === 'focused' && tagName !== 'General ⦂' ? (0, _litElement.html)`<h3 class="upper" style="font-weight:700"> ${tagName} </h3>` : ''} ${path.deprecated ? (0, _litElement.html)`<div class="bold-text red-text"> DEPRECATED </div>` : ''} ${(0, _litElement.html)` <h2> ${path.shortSummary || `${path.method.toUpperCase()} ${path.path}`}</h2> <div class='mono-font part="section-operation-url" regular-font-size' style="padding:8px 0;color:var(--fg3)"> ${path.isWebhook ? (0, _litElement.html)`<span style="color:var(--primary-color)"> WEBHOOK </span>` : ''} <span part="label-operation-method" class="regular-font upper method-fg bold-text ${path.method}">${path.method}</span> <span part="label-operation-path">${path.path}</span> </div>`} ${path.description ? (0, _litElement.html)`<div class="m-markdown"> ${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(path.description))}</div>` : ''} <slot name="${path.elementId}"></slot> ${_securitySchemeTemplate.pathSecurityTemplate.call(this, path.security)} ${codeSampleTabPanel} <div class="expanded-req-resp-container"> <api-request class="request-panel" method="${path.method}" path="${path.path}" .parameters="${path.parameters}" .request_body="${path.requestBody}" .api_keys="${nonEmptyApiKeys}" .servers="${path.servers}" server-url="${path.servers && path.servers[0] && path.servers[0].url || this.selectedServer.computedUrl}" fill-defaults="${this.fillRequestWithDefault}" enable-console="${this.allowTry}" accept="${accept}" render-style="${this.renderStyle}" schema-style="${this.
|
|
39
|
+
return (0, _litElement.html)` ${this.renderStyle === 'read' ? (0, _litElement.html)`<div class="divider" part="operation-divider"></div>` : ''} <div class="expanded-endpoint-body observe-me ${path.method}" part="section-operation ${path.elementId}" id="${path.elementId}"> ${this.renderStyle === 'focused' && tagName !== 'General ⦂' ? (0, _litElement.html)`<h3 class="upper" style="font-weight:700"> ${tagName} </h3>` : ''} ${path.deprecated ? (0, _litElement.html)`<div class="bold-text red-text"> DEPRECATED </div>` : ''} ${(0, _litElement.html)` <h2> ${path.shortSummary || `${path.method.toUpperCase()} ${path.path}`}</h2> <div class='mono-font part="section-operation-url" regular-font-size' style="padding:8px 0;color:var(--fg3)"> ${path.isWebhook ? (0, _litElement.html)`<span style="color:var(--primary-color)"> WEBHOOK </span>` : ''} <span part="label-operation-method" class="regular-font upper method-fg bold-text ${path.method}">${path.method}</span> <span part="label-operation-path">${path.path}</span> </div>`} ${path.description ? (0, _litElement.html)`<div class="m-markdown"> ${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(path.description))}</div>` : ''} <slot name="${path.elementId}"></slot> ${_securitySchemeTemplate.pathSecurityTemplate.call(this, path.security)} ${codeSampleTabPanel} <div class="expanded-req-resp-container"> <api-request class="request-panel" method="${path.method}" path="${path.path}" .parameters="${path.parameters}" .request_body="${path.requestBody}" .api_keys="${nonEmptyApiKeys}" .servers="${path.servers}" server-url="${path.servers && path.servers[0] && path.servers[0].url || this.selectedServer.computedUrl}" fill-defaults="${this.fillRequestWithDefault}" enable-console="${this.allowTry}" accept="${accept}" render-style="${this.renderStyle}" schema-style="${this.displaySchemaAsTable ? 'table' : 'tree'}" active-schema-tab="${this.defaultSchemaTab}" schema-expand-level="${this.schemaExpandLevel}" schema-description-expanded="${this.schemaDescriptionExpanded}" schema-hide-read-only="${this.schemaHideReadOnly}" fetch-credentials="${this.fetchCredentials}" exportparts="btn btn-fill btn-outline btn-try"> </api-request> ${path.callbacks ? _callbackTemplate.default.call(this, path.callbacks) : ''} <api-response class="response-panel" .responses="${path.responses}" render-style="${this.renderStyle}" schema-style="${this.displaySchemaAsTable ? 'table' : 'tree'}" active-schema-tab="${this.defaultSchemaTab}" schema-expand-level="${this.schemaExpandLevel}" schema-description-expanded="${this.schemaDescriptionExpanded}" schema-hide-write-only="${this.schemaHideWriteOnly}" selected-status="${Object.keys(path.responses || {})[0] || ''}" exportparts="btn--resp btn-fill--resp btn-outline--resp"> </api-response> </div> </div> `;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
function expandedEndpointTemplate() {
|
|
@@ -61,7 +61,7 @@ function focusedEndpointTemplate() {
|
|
|
61
61
|
focusedTemplate = _serverTemplate.default.call(this);
|
|
62
62
|
} else if (focusElId === 'section') {
|
|
63
63
|
focusedTemplate = (0, _litElement.html)` <section id="section" class="observe-me"> <slot name="custom-section"></slot> </section>`;
|
|
64
|
-
} else if (focusElId.startsWith('cmp--') && this.
|
|
64
|
+
} else if (focusElId.startsWith('cmp--') && !this.hideComponents) {
|
|
65
65
|
focusedTemplate = _componentsTemplate.default.call(this);
|
|
66
66
|
} else if (focusElId.startsWith('tag--')) {
|
|
67
67
|
const idToFocus = focusElId.indexOf('--', 4) > 0 ? focusElId.substring(0, focusElId.indexOf('--', 5)) : focusElId;
|
|
@@ -49,6 +49,6 @@ function navbarTemplate() {
|
|
|
49
49
|
return true;
|
|
50
50
|
}).map(p => (0, _litElement.html)` <div class="nav-bar-path ${this.usePathInNavBar === 'true' ? 'small-font' : ''}" data-content-id="${p.elementId}" id="link-${p.elementId}" @click="${e => {
|
|
51
51
|
this.scrollToEventTarget(e, false);
|
|
52
|
-
}}"> <span style="line-break:anywhere;${p.deprecated ? 'filter:opacity(0.5)' : ''}"> ${this.usePathInNavBar === 'true' ? (0, _litElement.html)`<span class="mono-font">${p.method.toUpperCase()} ${p.path}</span>` : p.summary || p.shortSummary} ${p.isWebhook ? '(Webhook)' : ''} </span> </div>`)} </div> </div> </slot> `)} ${this.resolvedSpec.components && this.
|
|
52
|
+
}}"> <span style="line-break:anywhere;${p.deprecated ? 'filter:opacity(0.5)' : ''}"> ${this.usePathInNavBar === 'true' ? (0, _litElement.html)`<span class="mono-font">${p.method.toUpperCase()} ${p.path}</span>` : p.summary || p.shortSummary} ${p.isWebhook ? '(Webhook)' : ''} </span> </div>`)} </div> </div> </slot> `)} ${this.resolvedSpec.components && !this.hideComponents ? (0, _litElement.html)` <div class="sticky-scroll-element"> <div id="link-components" class="nav-bar-section"> <div class="nav-bar-section-title">COMPONENTS</div> </div> </div> ${this.resolvedSpec.components.map(component => component.subComponents.filter(s => s.expanded).length ? (0, _litElement.html)` <div class="nav-bar-tag" data-content-id="cmp--${component.name.toLowerCase()}" id="link-cmp--${component.name.toLowerCase()}" @click="${e => this.scrollToEventTarget(e, false)}"> ${component.name} </div> ${component.subComponents.filter(s => s.expanded).map(p => (0, _litElement.html)` <div class="nav-bar-path" data-content-id="cmp--${p.id}" id="link-cmp--${p.id}" @click="${e => this.scrollToEventTarget(e, false)}"> <span> ${p.name} </span> </div>`)}` : '')}` : ''} </nav>`} </nav> `;
|
|
53
53
|
}
|
|
54
54
|
/* eslint-enable indent */
|
|
@@ -101,6 +101,7 @@ function getTypeInfo(schema) {
|
|
|
101
101
|
readOrWriteOnly: info.readOrWriteOnly,
|
|
102
102
|
constraint: info.constraint,
|
|
103
103
|
defaultValue: info.default,
|
|
104
|
+
example: info.example,
|
|
104
105
|
allowedValues: info.allowedValues,
|
|
105
106
|
pattern: info.pattern,
|
|
106
107
|
schemaDescription: info.description,
|
|
@@ -364,19 +365,6 @@ function getExampleValuesFromSchemaRecursive(schema, config = {}) {
|
|
|
364
365
|
const value = getSampleValueByType(schema, config.propertyName, config.skipExampleStrings);
|
|
365
366
|
return [value];
|
|
366
367
|
}
|
|
367
|
-
|
|
368
|
-
function removeTitlesAndDescriptions(obj) {
|
|
369
|
-
if (typeof obj !== 'object' || obj === null) {
|
|
370
|
-
return;
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
delete obj['::TITLE'];
|
|
374
|
-
delete obj['::DESCRIPTION'];
|
|
375
|
-
|
|
376
|
-
for (const k in obj) {
|
|
377
|
-
removeTitlesAndDescriptions(obj[k]);
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
368
|
/**
|
|
381
369
|
* For changing OpenAPI-Schema to an Object Notation,
|
|
382
370
|
* This Object would further be an input to UI Components to generate an Object-Tree
|
|
@@ -708,9 +696,6 @@ function generateExample(examples, example, schema, rawMimeType, includeReadOnly
|
|
|
708
696
|
}
|
|
709
697
|
|
|
710
698
|
return samples.map((sample, sampleCounter) => {
|
|
711
|
-
const summary = sample['::TITLE'] || `Example ${sampleCounter + 1}`;
|
|
712
|
-
const description = sample['::DESCRIPTION'] || '';
|
|
713
|
-
removeTitlesAndDescriptions(sample);
|
|
714
699
|
let exampleValue = '';
|
|
715
700
|
|
|
716
701
|
if (mimeType.toLowerCase().includes('xml')) {
|
|
@@ -724,8 +709,8 @@ function generateExample(examples, example, schema, rawMimeType, includeReadOnly
|
|
|
724
709
|
|
|
725
710
|
return {
|
|
726
711
|
exampleId: `Example-${sampleCounter}`,
|
|
727
|
-
exampleSummary:
|
|
728
|
-
exampleDescription:
|
|
712
|
+
exampleSummary: `Example ${sampleCounter + 1}`,
|
|
713
|
+
exampleDescription: '',
|
|
729
714
|
exampleType: mimeType,
|
|
730
715
|
exampleFormat: mimeType.toLowerCase().includes('xml') ? 'text' : outputType,
|
|
731
716
|
exampleValue
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openapi-explorer",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.337",
|
|
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": {
|