openapi-explorer 2.2.770 → 2.2.772

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.
@@ -30,7 +30,7 @@ export default class ApiRequest extends LitElement {
30
30
  this.curlSyntax = '';
31
31
  this.activeResponseTab = 'curl'; // allowed values: response, headers, curl
32
32
  this.selectedRequestBodyType = '';
33
- this.selectedRequestBodyExample = '';
33
+ this.selectedRequestBodyExampleId = '';
34
34
  }
35
35
  static get properties() {
36
36
  return {
@@ -143,13 +143,11 @@ export default class ApiRequest extends LitElement {
143
143
  },
144
144
  // internal tracking of response-tab not exposed as a attribute
145
145
  selectedRequestBodyType: {
146
- type: String,
147
- attribute: 'selected-request-body-type'
146
+ type: String
148
147
  },
149
148
  // internal tracking of selected request-body type
150
- selectedRequestBodyExample: {
151
- type: String,
152
- attribute: 'selected-request-body-example'
149
+ selectedRequestBodyExampleId: {
150
+ type: String
153
151
  },
154
152
  // internal tracking of selected request-body example
155
153
  curlSyntax: {
@@ -317,17 +315,17 @@ export default class ApiRequest extends LitElement {
317
315
  }
318
316
  resetRequestBodySelection() {
319
317
  this.selectedRequestBodyType = '';
320
- this.selectedRequestBodyExample = '';
318
+ this.selectedRequestBodyExampleId = '';
321
319
  this.computeCurlSyntax();
322
320
  this.clearResponseData();
323
321
  }
324
322
 
325
323
  // Request-Body Event Handlers
326
324
  onSelectExample(e) {
327
- this.selectedRequestBodyExample = e.target.value;
325
+ this.selectedRequestBodyExampleId = e.target.value;
328
326
  const exampleDropdownEl = e.target;
329
327
  window.setTimeout(selectEl => {
330
- const exampleTextareaEl = selectEl.closest('.example-panel').querySelector(`.request-body-param[data-example="${this.selectedRequestBodyExample}"`);
328
+ const exampleTextareaEl = selectEl.closest('.example-panel').querySelector(`.request-body-param[data-example="${this.selectedRequestBodyExampleId}"`);
331
329
  const userInputExampleTextareaEl = selectEl.closest('.example-panel').querySelector('.request-body-param-user-input');
332
330
  userInputExampleTextareaEl.value = exampleTextareaEl.value;
333
331
  this.computeCurlSyntax();
@@ -336,7 +334,7 @@ export default class ApiRequest extends LitElement {
336
334
  onMimeTypeChange(e) {
337
335
  this.selectedRequestBodyType = e.target.value;
338
336
  const mimeDropdownEl = e.target;
339
- this.selectedRequestBodyExample = '';
337
+ this.selectedRequestBodyExampleId = '';
340
338
  window.setTimeout(selectEl => {
341
339
  const exampleTextareaEl = selectEl.closest('.request-body-container').querySelector('.request-body-param');
342
340
  if (exampleTextareaEl) {
@@ -387,11 +385,11 @@ export default class ApiRequest extends LitElement {
387
385
  // Generate Example
388
386
  if (this.selectedRequestBodyType.includes('json') || this.selectedRequestBodyType.includes('xml') || this.selectedRequestBodyType.includes('text')) {
389
387
  const reqBodyExamples = generateExample(reqBody.examples ? reqBody.examples : '', reqBody.example ? reqBody.example : '', reqBody.schema, reqBody.mimeType, false, true, 'text', true);
390
- if (!this.selectedRequestBodyExample) {
391
- this.selectedRequestBodyExample = reqBodyExamples.length > 0 ? reqBodyExamples[0].exampleId : '';
388
+ if (!this.selectedRequestBodyExampleId) {
389
+ this.selectedRequestBodyExampleId = reqBodyExamples.length > 0 ? reqBodyExamples[0].exampleId : '';
392
390
  }
393
- const displayedBodyExample = reqBodyExamples.find(v => v.exampleId === this.selectedRequestBodyExample) || reqBodyExamples[0];
394
- 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"> ${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(toMarkdown(displayedBodyExample.exampleDescription || ''))} </div>` : ''} <slot name="${this.elementId}--request-body"> <textarea @input="${() => {
391
+ const displayedBodyExample = reqBodyExamples.find(v => v.exampleId === this.selectedRequestBodyExampleId) || reqBodyExamples[0];
392
+ 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.selectedRequestBodyExampleId}"> ${v.exampleSummary.length > 80 ? v.exampleId : v.exampleSummary ? v.exampleSummary : v.exampleId} </option>`)} </select>`} ${displayedBodyExample ? html` <div class="example"> ${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(toMarkdown(displayedBodyExample.exampleDescription || ''))} </div>` : ''} <slot name="${this.elementId}--request-body"> <textarea @input="${() => {
395
393
  this.computeCurlSyntax();
396
394
  }}" class="textarea request-body-param-user-input" part="textarea textarea-param" aria-label="${getI18nText('operations.request-body')}" spellcheck="false" data-ptype="${reqBody.mimeType}" style="width:100%;resize:vertical" .value="${this.fillRequestWithDefault === 'true' ? displayedBodyExample.exampleFormat === 'text' ? displayedBodyExample.exampleValue : JSON.stringify(displayedBodyExample.exampleValue, null, 8) : ''}"></textarea> </slot> </div>` : ''} ${reqBodyExamples.map(bodyExample => html` <textarea class="textarea is-hidden request-body-param ${reqBody.mimeType.substring(reqBody.mimeType.indexOf('/') + 1)}" spellcheck="false" data-ptype="${reqBody.mimeType}" data-example="${bodyExample.exampleId}" style="width:100%;resize:vertical;display:none" .value="${bodyExample.exampleFormat === 'text' ? bodyExample.exampleValue : JSON.stringify(bodyExample.exampleValue, null, 8)}"></textarea> `)} </div> `;
397
395
  } else if (this.selectedRequestBodyType.includes('form-urlencoded') || this.selectedRequestBodyType.includes('form-data')) {
@@ -417,14 +415,15 @@ export default class ApiRequest extends LitElement {
417
415
  }
418
416
 
419
417
  // When the content type and the element stay the same, then don't change the updated body.
420
- if (((_this$cachedBodyData = this.cachedBodyData) === null || _this$cachedBodyData === void 0 ? void 0 : _this$cachedBodyData.contentType) === this.selectedRequestBodyType && this.elementId === this.cachedBodyData.elementId) {
418
+ if (((_this$cachedBodyData = this.cachedBodyData) === null || _this$cachedBodyData === void 0 ? void 0 : _this$cachedBodyData.contentType) === this.selectedRequestBodyType && this.elementId === this.cachedBodyData.elementId && this.selectedRequestBodyExampleId === this.cachedBodyData.exampleId) {
421
419
  reqBodyDefaultHtml = this.cachedBodyData.body;
422
420
  } else {
423
421
  // Otherwise use the recalculated body and cache that
424
422
  this.cachedBodyData = {
425
423
  body: reqBodyDefaultHtml,
426
424
  contentType: this.selectedRequestBodyType,
427
- elementId: this.elementId
425
+ elementId: this.elementId,
426
+ exampleId: this.selectedRequestBodyExampleId
428
427
  };
429
428
  }
430
429
  return html` <div class="request-body-container" data-selected-request-body-type="${this.selectedRequestBodyType}"> <div class="table-title top-gap row"> ${getI18nText('operations.request-body')} ${this.request_body.required ? html`<span class="mono-font" style="color:var(--red)">*</span>` : ''} <span style="font-weight:400;margin-left:5px"> ${this.selectedRequestBodyType}</span> <span style="flex:1"></span> ${reqBodyTypeSelectorHtml} </div> ${this.request_body.description ? html`<div class="m-markdown" style="margin-bottom:12px">${unsafeHTML(toMarkdown(this.request_body.description))}</div>` : ''} ${reqBodySchemaHtml || reqBodyDefaultHtml ? html` <div class="tab-panel col" style="border-width:0 0 1px 0"> <div class="tab-buttons row" role="group" @click="${e => {
@@ -449,7 +448,7 @@ export default class ApiRequest extends LitElement {
449
448
  // }
450
449
 
451
450
  apiResponseTabTemplate() {
452
- const curlSyntax = this.curlSyntax || this.computeCurlSyntax() || '';
451
+ const curlSyntax = this.curlSyntax || '';
453
452
  const hasResponse = this.responseMessage !== '';
454
453
  return html` <div class="row" style="font-size:var(--font-size-small);margin:5px 0"> ${this.responseMessage ? html`<div class="response-message ${this.responseStatus}">Response Status: ${this.responseMessage} ${this.responseElapsedMs ? html`<span><br>Execution Time: ${this.responseElapsedMs}ms</span>` : ''} </div>` : ''} <div style="flex:1"></div> ${!hasResponse ? '' : html`<button class="m-btn" part="btn btn-outline" @click="${this.clearResponseData}">${getI18nText('operations.clear-response')}</button>`} </div> <div class="tab-panel col" style="border-width:0 0 1px 0"> <div id="tab_buttons" class="tab-buttons row" @click="${e => {
455
454
  if (e.target.classList.contains('tab-btn') === false) {
@@ -5,6 +5,11 @@ import { getI18nText } from '../languages/index.js';
5
5
  import { expandCollapseComponent } from './endpoint-template.js';
6
6
  import { getComponentInfo } from './components-template.js';
7
7
  function onExpandCollapseTag(event, tagId) {
8
+ if (tagId === 'link-overview') {
9
+ this.resolvedSpec.info.expanded = !this.resolvedSpec.info.expanded;
10
+ this.scrollToEventTarget(event, false);
11
+ return;
12
+ }
8
13
  const tag = this.resolvedSpec.tags.find(t => t.elementId === tagId);
9
14
  if (!tag) {
10
15
  return;
@@ -12,6 +17,7 @@ function onExpandCollapseTag(event, tagId) {
12
17
  tag.expanded = !tag.expanded;
13
18
  if (tag.expanded && this.operationsCollapsed) {
14
19
  this.resolvedSpec.tags.filter(t => t.elementId !== tagId).forEach(t => t.expanded = false);
20
+ this.resolvedSpec.info.expanded = false;
15
21
  }
16
22
 
17
23
  // Only display the dedicated tag page if the tag has a description, otherwise, it will be an ugly page with nothing on it.
@@ -39,12 +45,14 @@ export function expandCollapseAllComponents() {
39
45
 
40
46
  /* eslint-disable indent */
41
47
  export default function navbarTemplate() {
42
- var _this$resolvedSpec$co;
43
- return html` <nav class="nav-bar ${this.renderStyle}" part="section-navbar" aria-label="${getI18nText('menu.menu')}"> <slot name="nav-header"></slot> ${this.hideSearch ? '' : html` <div style="display:flex;flex-direction:row;justify-content:center;align-items:center;padding:24px"> <div style="display:flex;flex:1;line-height:22px"> <input id="nav-bar-search" part="textbox textbox-nav-filter" style="width:100%;padding-right:20px;color:var(--nav-hover-text-color);border-color:var(--secondary-color);background-color:var(--nav-hover-bg-color)" type="text" placeholder="${getI18nText('menu.filter')}" @input="${this.onSearchChange}" spellcheck="false"> </div> <button class="m-btn outline-primary" part="btn btn-fill btn-search" style="margin-left:5px" @click="${this.onShowSearchModalClicked}"> ${getI18nText('menu.search')} </button> </div> `} ${html`<nav class="nav-scroll" part="navbar-scroll"> ${this.hideInfo || !this.resolvedSpec.info ? '' : html`<div class="nav-bar-info" id="link-overview" data-content-id="overview" @click="${e => this.scrollToEventTarget(e, false)}" role="link" tabindex="0" @keydown="${e => {
48
+ var _this$resolvedSpec$in, _this$resolvedSpec$co;
49
+ return html` <nav class="nav-bar ${this.renderStyle}" part="section-navbar" aria-label="${getI18nText('menu.menu')}"> <slot name="nav-header"></slot> ${this.hideSearch ? '' : html` <div style="display:flex;flex-direction:row;justify-content:center;align-items:center;padding:24px"> <div style="display:flex;flex:1;line-height:22px"> <input id="nav-bar-search" part="textbox textbox-nav-filter" style="width:100%;padding-right:20px;color:var(--nav-hover-text-color);border-color:var(--secondary-color);background-color:var(--nav-hover-bg-color)" type="text" placeholder="${getI18nText('menu.filter')}" @input="${this.onSearchChange}" spellcheck="false"> </div> <button class="m-btn outline-primary" part="btn btn-fill btn-search" style="margin-left:5px" @click="${this.onShowSearchModalClicked}"> ${getI18nText('menu.search')} </button> </div> `} ${html`<nav class="nav-scroll" part="navbar-scroll"> ${this.hideInfo || !this.resolvedSpec.info ? '' : html` <div class="nav-bar-tag-and-paths ${this.resolvedSpec.info.expanded ? '' : 'collapsed'}"> <div class="nav-bar-info" id="link-overview" data-content-id="overview" @click="${e => {
50
+ onExpandCollapseTag.call(this, e, 'link-overview');
51
+ }}" role="link" tabindex="0" @keydown="${e => {
44
52
  if (e.key === 'Enter') {
45
53
  e.target.click();
46
54
  }
47
- }}" ; }> ${this.resolvedSpec.info.title || getI18nText('menu.overview')} </div>`} ${this.hideServerSelection ? '' : html`<div class="nav-bar-info" id="link-servers" data-content-id="servers" @click="${e => this.scrollToEventTarget(e, false)}" role="link" tabindex="0" @keydown="${e => {
55
+ }}" ; }> ${this.resolvedSpec.info.title || getI18nText('menu.overview')} </div> <div class="nav-bar-section-wrapper"> <div> ${((_this$resolvedSpec$in = this.resolvedSpec.info.headers) === null || _this$resolvedSpec$in === void 0 ? void 0 : _this$resolvedSpec$in.map(header => html` <div class="nav-bar-h${header.depth}" id="link-overview--${new marked.Slugger().slug(header.text)}" data-content-id="overview--${new marked.Slugger().slug(header.text)}" @click="${e => this.scrollToEventTarget(e, false)}"> ${header.text} </div>`)) || ''} </div> </div> </div> `} ${this.hideServerSelection ? '' : html`<div class="nav-bar-info" id="link-servers" data-content-id="servers" @click="${e => this.scrollToEventTarget(e, false)}" role="link" tabindex="0" @keydown="${e => {
48
56
  if (e.key === 'Enter') {
49
57
  e.target.click();
50
58
  }
@@ -110,8 +110,11 @@ export default async function ProcessSpec(specUrlOrObject, serverUrl = '') {
110
110
  }];
111
111
  }
112
112
  const parsedSpec = {
113
- info: jsonParsedSpec.info,
114
- infoDescriptionHeaders,
113
+ info: {
114
+ ...jsonParsedSpec.info,
115
+ expanded: true,
116
+ headers: infoDescriptionHeaders
117
+ },
115
118
  tags,
116
119
  components,
117
120
  // pathGroups,
@@ -35,7 +35,7 @@ class ApiRequest extends _lit.LitElement {
35
35
  this.curlSyntax = '';
36
36
  this.activeResponseTab = 'curl'; // allowed values: response, headers, curl
37
37
  this.selectedRequestBodyType = '';
38
- this.selectedRequestBodyExample = '';
38
+ this.selectedRequestBodyExampleId = '';
39
39
  }
40
40
  static get properties() {
41
41
  return {
@@ -148,13 +148,11 @@ class ApiRequest extends _lit.LitElement {
148
148
  },
149
149
  // internal tracking of response-tab not exposed as a attribute
150
150
  selectedRequestBodyType: {
151
- type: String,
152
- attribute: 'selected-request-body-type'
151
+ type: String
153
152
  },
154
153
  // internal tracking of selected request-body type
155
- selectedRequestBodyExample: {
156
- type: String,
157
- attribute: 'selected-request-body-example'
154
+ selectedRequestBodyExampleId: {
155
+ type: String
158
156
  },
159
157
  // internal tracking of selected request-body example
160
158
  curlSyntax: {
@@ -322,17 +320,17 @@ class ApiRequest extends _lit.LitElement {
322
320
  }
323
321
  resetRequestBodySelection() {
324
322
  this.selectedRequestBodyType = '';
325
- this.selectedRequestBodyExample = '';
323
+ this.selectedRequestBodyExampleId = '';
326
324
  this.computeCurlSyntax();
327
325
  this.clearResponseData();
328
326
  }
329
327
 
330
328
  // Request-Body Event Handlers
331
329
  onSelectExample(e) {
332
- this.selectedRequestBodyExample = e.target.value;
330
+ this.selectedRequestBodyExampleId = e.target.value;
333
331
  const exampleDropdownEl = e.target;
334
332
  window.setTimeout(selectEl => {
335
- const exampleTextareaEl = selectEl.closest('.example-panel').querySelector(`.request-body-param[data-example="${this.selectedRequestBodyExample}"`);
333
+ const exampleTextareaEl = selectEl.closest('.example-panel').querySelector(`.request-body-param[data-example="${this.selectedRequestBodyExampleId}"`);
336
334
  const userInputExampleTextareaEl = selectEl.closest('.example-panel').querySelector('.request-body-param-user-input');
337
335
  userInputExampleTextareaEl.value = exampleTextareaEl.value;
338
336
  this.computeCurlSyntax();
@@ -341,7 +339,7 @@ class ApiRequest extends _lit.LitElement {
341
339
  onMimeTypeChange(e) {
342
340
  this.selectedRequestBodyType = e.target.value;
343
341
  const mimeDropdownEl = e.target;
344
- this.selectedRequestBodyExample = '';
342
+ this.selectedRequestBodyExampleId = '';
345
343
  window.setTimeout(selectEl => {
346
344
  const exampleTextareaEl = selectEl.closest('.request-body-container').querySelector('.request-body-param');
347
345
  if (exampleTextareaEl) {
@@ -392,11 +390,11 @@ class ApiRequest extends _lit.LitElement {
392
390
  // Generate Example
393
391
  if (this.selectedRequestBodyType.includes('json') || this.selectedRequestBodyType.includes('xml') || this.selectedRequestBodyType.includes('text')) {
394
392
  const reqBodyExamples = (0, _schemaUtils.generateExample)(reqBody.examples ? reqBody.examples : '', reqBody.example ? reqBody.example : '', reqBody.schema, reqBody.mimeType, false, true, 'text', true);
395
- if (!this.selectedRequestBodyExample) {
396
- this.selectedRequestBodyExample = reqBodyExamples.length > 0 ? reqBodyExamples[0].exampleId : '';
393
+ if (!this.selectedRequestBodyExampleId) {
394
+ this.selectedRequestBodyExampleId = reqBodyExamples.length > 0 ? reqBodyExamples[0].exampleId : '';
397
395
  }
398
- const displayedBodyExample = reqBodyExamples.find(v => v.exampleId === this.selectedRequestBodyExample) || reqBodyExamples[0];
399
- 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"> ${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, _commonUtils.toMarkdown)(displayedBodyExample.exampleDescription || ''))} </div>` : ''} <slot name="${this.elementId}--request-body"> <textarea @input="${() => {
396
+ const displayedBodyExample = reqBodyExamples.find(v => v.exampleId === this.selectedRequestBodyExampleId) || reqBodyExamples[0];
397
+ 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.selectedRequestBodyExampleId}"> ${v.exampleSummary.length > 80 ? v.exampleId : v.exampleSummary ? v.exampleSummary : v.exampleId} </option>`)} </select>`} ${displayedBodyExample ? (0, _lit.html)` <div class="example"> ${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, _commonUtils.toMarkdown)(displayedBodyExample.exampleDescription || ''))} </div>` : ''} <slot name="${this.elementId}--request-body"> <textarea @input="${() => {
400
398
  this.computeCurlSyntax();
401
399
  }}" class="textarea request-body-param-user-input" part="textarea textarea-param" aria-label="${(0, _index.getI18nText)('operations.request-body')}" spellcheck="false" data-ptype="${reqBody.mimeType}" style="width:100%;resize:vertical" .value="${this.fillRequestWithDefault === 'true' ? displayedBodyExample.exampleFormat === 'text' ? displayedBodyExample.exampleValue : JSON.stringify(displayedBodyExample.exampleValue, null, 8) : ''}"></textarea> </slot> </div>` : ''} ${reqBodyExamples.map(bodyExample => (0, _lit.html)` <textarea class="textarea is-hidden request-body-param ${reqBody.mimeType.substring(reqBody.mimeType.indexOf('/') + 1)}" spellcheck="false" data-ptype="${reqBody.mimeType}" data-example="${bodyExample.exampleId}" style="width:100%;resize:vertical;display:none" .value="${bodyExample.exampleFormat === 'text' ? bodyExample.exampleValue : JSON.stringify(bodyExample.exampleValue, null, 8)}"></textarea> `)} </div> `;
402
400
  } else if (this.selectedRequestBodyType.includes('form-urlencoded') || this.selectedRequestBodyType.includes('form-data')) {
@@ -422,14 +420,15 @@ class ApiRequest extends _lit.LitElement {
422
420
  }
423
421
 
424
422
  // When the content type and the element stay the same, then don't change the updated body.
425
- if (((_this$cachedBodyData = this.cachedBodyData) === null || _this$cachedBodyData === void 0 ? void 0 : _this$cachedBodyData.contentType) === this.selectedRequestBodyType && this.elementId === this.cachedBodyData.elementId) {
423
+ if (((_this$cachedBodyData = this.cachedBodyData) === null || _this$cachedBodyData === void 0 ? void 0 : _this$cachedBodyData.contentType) === this.selectedRequestBodyType && this.elementId === this.cachedBodyData.elementId && this.selectedRequestBodyExampleId === this.cachedBodyData.exampleId) {
426
424
  reqBodyDefaultHtml = this.cachedBodyData.body;
427
425
  } else {
428
426
  // Otherwise use the recalculated body and cache that
429
427
  this.cachedBodyData = {
430
428
  body: reqBodyDefaultHtml,
431
429
  contentType: this.selectedRequestBodyType,
432
- elementId: this.elementId
430
+ elementId: this.elementId,
431
+ exampleId: this.selectedRequestBodyExampleId
433
432
  };
434
433
  }
435
434
  return (0, _lit.html)` <div class="request-body-container" data-selected-request-body-type="${this.selectedRequestBodyType}"> <div class="table-title top-gap row"> ${(0, _index.getI18nText)('operations.request-body')} ${this.request_body.required ? (0, _lit.html)`<span class="mono-font" style="color:var(--red)">*</span>` : ''} <span style="font-weight:400;margin-left:5px"> ${this.selectedRequestBodyType}</span> <span style="flex:1"></span> ${reqBodyTypeSelectorHtml} </div> ${this.request_body.description ? (0, _lit.html)`<div class="m-markdown" style="margin-bottom:12px">${(0, _unsafeHtml.unsafeHTML)((0, _commonUtils.toMarkdown)(this.request_body.description))}</div>` : ''} ${reqBodySchemaHtml || reqBodyDefaultHtml ? (0, _lit.html)` <div class="tab-panel col" style="border-width:0 0 1px 0"> <div class="tab-buttons row" role="group" @click="${e => {
@@ -454,7 +453,7 @@ class ApiRequest extends _lit.LitElement {
454
453
  // }
455
454
 
456
455
  apiResponseTabTemplate() {
457
- const curlSyntax = this.curlSyntax || this.computeCurlSyntax() || '';
456
+ const curlSyntax = this.curlSyntax || '';
458
457
  const hasResponse = this.responseMessage !== '';
459
458
  return (0, _lit.html)` <div class="row" style="font-size:var(--font-size-small);margin:5px 0"> ${this.responseMessage ? (0, _lit.html)`<div class="response-message ${this.responseStatus}">Response Status: ${this.responseMessage} ${this.responseElapsedMs ? (0, _lit.html)`<span><br>Execution Time: ${this.responseElapsedMs}ms</span>` : ''} </div>` : ''} <div style="flex:1"></div> ${!hasResponse ? '' : (0, _lit.html)`<button class="m-btn" part="btn btn-outline" @click="${this.clearResponseData}">${(0, _index.getI18nText)('operations.clear-response')}</button>`} </div> <div class="tab-panel col" style="border-width:0 0 1px 0"> <div id="tab_buttons" class="tab-buttons row" @click="${e => {
460
459
  if (e.target.classList.contains('tab-btn') === false) {
@@ -11,6 +11,11 @@ var _index = require("../languages/index.js");
11
11
  var _endpointTemplate = require("./endpoint-template.js");
12
12
  var _componentsTemplate = require("./components-template.js");
13
13
  function onExpandCollapseTag(event, tagId) {
14
+ if (tagId === 'link-overview') {
15
+ this.resolvedSpec.info.expanded = !this.resolvedSpec.info.expanded;
16
+ this.scrollToEventTarget(event, false);
17
+ return;
18
+ }
14
19
  const tag = this.resolvedSpec.tags.find(t => t.elementId === tagId);
15
20
  if (!tag) {
16
21
  return;
@@ -18,6 +23,7 @@ function onExpandCollapseTag(event, tagId) {
18
23
  tag.expanded = !tag.expanded;
19
24
  if (tag.expanded && this.operationsCollapsed) {
20
25
  this.resolvedSpec.tags.filter(t => t.elementId !== tagId).forEach(t => t.expanded = false);
26
+ this.resolvedSpec.info.expanded = false;
21
27
  }
22
28
 
23
29
  // Only display the dedicated tag page if the tag has a description, otherwise, it will be an ugly page with nothing on it.
@@ -45,12 +51,14 @@ function expandCollapseAllComponents() {
45
51
 
46
52
  /* eslint-disable indent */
47
53
  function navbarTemplate() {
48
- var _this$resolvedSpec$co;
49
- return (0, _lit.html)` <nav class="nav-bar ${this.renderStyle}" part="section-navbar" aria-label="${(0, _index.getI18nText)('menu.menu')}"> <slot name="nav-header"></slot> ${this.hideSearch ? '' : (0, _lit.html)` <div style="display:flex;flex-direction:row;justify-content:center;align-items:center;padding:24px"> <div style="display:flex;flex:1;line-height:22px"> <input id="nav-bar-search" part="textbox textbox-nav-filter" style="width:100%;padding-right:20px;color:var(--nav-hover-text-color);border-color:var(--secondary-color);background-color:var(--nav-hover-bg-color)" type="text" placeholder="${(0, _index.getI18nText)('menu.filter')}" @input="${this.onSearchChange}" spellcheck="false"> </div> <button class="m-btn outline-primary" part="btn btn-fill btn-search" style="margin-left:5px" @click="${this.onShowSearchModalClicked}"> ${(0, _index.getI18nText)('menu.search')} </button> </div> `} ${(0, _lit.html)`<nav class="nav-scroll" part="navbar-scroll"> ${this.hideInfo || !this.resolvedSpec.info ? '' : (0, _lit.html)`<div class="nav-bar-info" id="link-overview" data-content-id="overview" @click="${e => this.scrollToEventTarget(e, false)}" role="link" tabindex="0" @keydown="${e => {
54
+ var _this$resolvedSpec$in, _this$resolvedSpec$co;
55
+ return (0, _lit.html)` <nav class="nav-bar ${this.renderStyle}" part="section-navbar" aria-label="${(0, _index.getI18nText)('menu.menu')}"> <slot name="nav-header"></slot> ${this.hideSearch ? '' : (0, _lit.html)` <div style="display:flex;flex-direction:row;justify-content:center;align-items:center;padding:24px"> <div style="display:flex;flex:1;line-height:22px"> <input id="nav-bar-search" part="textbox textbox-nav-filter" style="width:100%;padding-right:20px;color:var(--nav-hover-text-color);border-color:var(--secondary-color);background-color:var(--nav-hover-bg-color)" type="text" placeholder="${(0, _index.getI18nText)('menu.filter')}" @input="${this.onSearchChange}" spellcheck="false"> </div> <button class="m-btn outline-primary" part="btn btn-fill btn-search" style="margin-left:5px" @click="${this.onShowSearchModalClicked}"> ${(0, _index.getI18nText)('menu.search')} </button> </div> `} ${(0, _lit.html)`<nav class="nav-scroll" part="navbar-scroll"> ${this.hideInfo || !this.resolvedSpec.info ? '' : (0, _lit.html)` <div class="nav-bar-tag-and-paths ${this.resolvedSpec.info.expanded ? '' : 'collapsed'}"> <div class="nav-bar-info" id="link-overview" data-content-id="overview" @click="${e => {
56
+ onExpandCollapseTag.call(this, e, 'link-overview');
57
+ }}" role="link" tabindex="0" @keydown="${e => {
50
58
  if (e.key === 'Enter') {
51
59
  e.target.click();
52
60
  }
53
- }}" ; }> ${this.resolvedSpec.info.title || (0, _index.getI18nText)('menu.overview')} </div>`} ${this.hideServerSelection ? '' : (0, _lit.html)`<div class="nav-bar-info" id="link-servers" data-content-id="servers" @click="${e => this.scrollToEventTarget(e, false)}" role="link" tabindex="0" @keydown="${e => {
61
+ }}" ; }> ${this.resolvedSpec.info.title || (0, _index.getI18nText)('menu.overview')} </div> <div class="nav-bar-section-wrapper"> <div> ${((_this$resolvedSpec$in = this.resolvedSpec.info.headers) === null || _this$resolvedSpec$in === void 0 ? void 0 : _this$resolvedSpec$in.map(header => (0, _lit.html)` <div class="nav-bar-h${header.depth}" id="link-overview--${new _marked.marked.Slugger().slug(header.text)}" data-content-id="overview--${new _marked.marked.Slugger().slug(header.text)}" @click="${e => this.scrollToEventTarget(e, false)}"> ${header.text} </div>`)) || ''} </div> </div> </div> `} ${this.hideServerSelection ? '' : (0, _lit.html)`<div class="nav-bar-info" id="link-servers" data-content-id="servers" @click="${e => this.scrollToEventTarget(e, false)}" role="link" tabindex="0" @keydown="${e => {
54
62
  if (e.key === 'Enter') {
55
63
  e.target.click();
56
64
  }
@@ -116,8 +116,11 @@ async function ProcessSpec(specUrlOrObject, serverUrl = '') {
116
116
  }];
117
117
  }
118
118
  const parsedSpec = {
119
- info: jsonParsedSpec.info,
120
- infoDescriptionHeaders,
119
+ info: {
120
+ ...jsonParsedSpec.info,
121
+ expanded: true,
122
+ headers: infoDescriptionHeaders
123
+ },
121
124
  tags,
122
125
  components,
123
126
  // pathGroups,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openapi-explorer",
3
- "version": "2.2.770",
3
+ "version": "2.2.772",
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",