openapi-explorer 2.2.728 → 2.2.730

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.
@@ -162,13 +162,17 @@ export default class ApiRequest extends LitElement {
162
162
  return keyed(id, html` <div id="api-request-${id}" class="api-request col regular-font request-panel ${this.renderStyle === 'focused' || this.callback === 'true' ? 'focused-mode' : 'view-mode'}"> <div class="${this.callback === 'true' ? 'tiny-title' : 'req-res-title'}"> ${this.callback === 'true' ? 'CALLBACK REQUEST' : getI18nText('operations.request')} </div> <div> ${this.inputParametersTemplate('path')} ${this.inputParametersTemplate('query')} ${this.inputParametersTemplate('header')} ${this.inputParametersTemplate('cookie')} ${this.requestBodyTemplate()} ${this.allowTry === 'false' ? '' : html`${this.apiCallTemplate()}`} </div> </div> `);
163
163
  }
164
164
  updated(changedProperties) {
165
+ // When the operation is changed, reset the display view properties
166
+ if (changedProperties.get('elementId')) {
167
+ this.activeResponseTab = 'curl';
168
+ }
165
169
  // In focused mode after rendering the request component, update the text-areas(which contains examples) using the original values from hidden textareas.
166
170
  // This is done coz, user may update the dom by editing the textarea's and once the DOM is updated externally change detection wont happen, therefore update the values manually
167
171
  if (this.renderStyle !== 'focused') {
168
172
  return;
169
173
  }
170
174
 
171
- // dont update example as only tabs is switched
175
+ // don't update example as only tabs is switched
172
176
  if (changedProperties.size === 1 && changedProperties.has('activeSchemaTab')) {
173
177
  return;
174
178
  }
@@ -451,7 +455,7 @@ export default class ApiRequest extends LitElement {
451
455
  return;
452
456
  }
453
457
  this.activeResponseTab = e.target.dataset.tab;
454
- }}"> <br> <div style="width:100%"> <button class="tab-btn ${!hasResponse || this.activeResponseTab === 'curl' ? 'active' : ''}" data-tab="curl">FULL REQUEST</button> ${!hasResponse ? '' : html` <button class="tab-btn ${this.activeResponseTab === 'response' ? 'active' : ''}" data-tab="response">${getI18nText('operations.response')}</button> <button class="tab-btn ${this.activeResponseTab === 'headers' ? 'active' : ''}" data-tab="headers">${getI18nText('operations.response-headers')}</button>`} </div> </div> ${this.responseIsBlob ? html` <div class="tab-content col" style="flex:1;display:${this.activeResponseTab === 'response' ? 'flex' : 'none'}"> ${this.responseBlobType === 'image' ? html`<img style="max-height:var(--resp-area-height,300px);object-fit:contain" class="mar-top-8" src="${this.responseBlobUrl}">` : ''} <div style="display:flex;justify-content:center"> <div> <button class="m-btn thin-border mar-top-8" style="width:135px" @click="${this.downloadResponseBlob}" part="btn btn-outline">DOWNLOAD</button> ${this.responseBlobType === 'view' || this.responseBlobType === 'image' ? html`<button class="m-btn thin-border mar-top-8" style="width:135px" @click="${this.viewResponseBlob}" part="btn btn-outline">VIEW (NEW TAB)</button>` : ''} </div> </div> </div>` : html` <div class="tab-content col m-markdown" style="flex:1;display:${this.activeResponseTab === 'response' ? 'flex' : 'none'}"> <syntax-highlighter style="min-height:60px" mime-type="${this.responseContentType}" .content="${this.responseText}"> </div>`} <div class="tab-content col m-markdown" style="flex:1;display:${this.activeResponseTab === 'headers' ? 'flex' : 'none'}"> <syntax-highlighter language="http" .content="${this.responseHeaders}"> </div> <div class="tab-content m-markdown col" style="flex:1;display:${this.activeResponseTab === 'curl' ? 'flex' : 'none'}"> <syntax-highlighter language="shell" .content="${curlSyntax.trim()}"> </div> </div>`;
458
+ }}"> <br> <div style="width:100%"> <button class="tab-btn ${!hasResponse || this.activeResponseTab === 'curl' ? 'active' : ''}" data-tab="curl">REQUEST</button> ${!hasResponse ? '' : html` <button class="tab-btn ${this.activeResponseTab === 'response' ? 'active' : ''}" data-tab="response">${getI18nText('operations.response')}</button> <button class="tab-btn ${this.activeResponseTab === 'headers' ? 'active' : ''}" data-tab="headers">${getI18nText('operations.response-headers')}</button>`} </div> </div> ${this.responseIsBlob ? html` <div class="tab-content col" style="flex:1;display:${this.activeResponseTab === 'response' ? 'flex' : 'none'}"> ${this.responseBlobType === 'image' ? html`<img style="max-height:var(--resp-area-height,300px);object-fit:contain" class="mar-top-8" src="${this.responseBlobUrl}">` : ''} <div style="display:flex;justify-content:center"> <div> <button class="m-btn thin-border mar-top-8" style="width:135px" @click="${this.downloadResponseBlob}" part="btn btn-outline">DOWNLOAD</button> ${this.responseBlobType === 'view' || this.responseBlobType === 'image' ? html`<button class="m-btn thin-border mar-top-8" style="width:135px" @click="${this.viewResponseBlob}" part="btn btn-outline">VIEW (NEW TAB)</button>` : ''} </div> </div> </div>` : html` <div class="tab-content col m-markdown" style="flex:1;display:${this.activeResponseTab === 'response' ? 'flex' : 'none'}"> <syntax-highlighter style="min-height:60px" mime-type="${this.responseContentType}" .content="${this.responseText}"> </div>`} <div class="tab-content col m-markdown" style="flex:1;display:${this.activeResponseTab === 'headers' ? 'flex' : 'none'}"> <syntax-highlighter style="min-height:60px" language="http" .content="${this.responseHeaders}"> </div> <div class="tab-content m-markdown col" style="flex:1;display:${this.activeResponseTab === 'curl' ? 'flex' : 'none'}"> <syntax-highlighter style="min-height:60px" language="shell" .content="${curlSyntax.trim()}"> </div> </div>`;
455
459
  }
456
460
  apiCallTemplate() {
457
461
  return html` <div style="display:flex;align-items:flex-end;margin:16px 0;font-size:var(--font-size-small)"> ${this.parameters.length > 0 || this.request_body ? html` <button class="m-btn thin-border" part="btn btn-outline" style="margin-right:5px" @click="${this.onClearRequestData}"> ${getI18nText('operations.clear')} </button>` : ''} <button class="m-btn primary btn-execute thin-border" part="btn btn-fill btn-try" @click="${this.onTryClick}">${getI18nText('operations.execute')}</button> </div> ${this.apiResponseTabTemplate()} `;
@@ -479,6 +483,16 @@ export default class ApiRequest extends LitElement {
479
483
  this.dispatchEvent(new CustomEvent('event', event));
480
484
  this.computeCurlSyntax();
481
485
  }
486
+ validateAllRequestParameters() {
487
+ const requestPanelEl = this.closest('.request-panel');
488
+ const pathParamEls = [...requestPanelEl.querySelectorAll("[data-ptype='path']")];
489
+ const missingPathParameterValue = pathParamEls.find(el => !el.value);
490
+ if (missingPathParameterValue) {
491
+ const error = Error(`All path parameters are required and a valid value was not found for the parameter: '${missingPathParameterValue.dataset.pname}'.`);
492
+ error.code = 'MissingPathParameter';
493
+ throw error;
494
+ }
495
+ }
482
496
  recomputeFetchOptions() {
483
497
  const requestPanelEl = this.closest('.request-panel');
484
498
  const pathParamEls = [...requestPanelEl.querySelectorAll("[data-ptype='path']")];
@@ -493,12 +507,6 @@ export default class ApiRequest extends LitElement {
493
507
  pathParameterMap[el.dataset.pname] = el.value;
494
508
  pathUrl = pathUrl.replace(`{${el.dataset.pname}}`, encodeURIComponent(el.value) || '-');
495
509
  });
496
- const missingPathParameterValue = pathParamEls.find(el => !el.value);
497
- if (missingPathParameterValue) {
498
- const error = Error(`All path parameters are required and a valid value was not found for the parameter: '${missingPathParameterValue.dataset.pname}'.`);
499
- error.code = 'MissingPathParameter';
500
- throw error;
501
- }
502
510
 
503
511
  // Handle relative serverUrls
504
512
  if (!pathUrl.startsWith('http')) {
@@ -723,6 +731,16 @@ export default class ApiRequest extends LitElement {
723
731
  this.activeResponseTab = 'response';
724
732
  return;
725
733
  }
734
+ try {
735
+ this.validateAllRequestParameters();
736
+ } catch (error) {
737
+ this.responseMessage = error.message;
738
+ this.responseStatus = 'error';
739
+ this.responseUrl = '';
740
+ this.responseHeaders = '';
741
+ this.responseText = '';
742
+ return;
743
+ }
726
744
  this.responseIsBlob = false;
727
745
  this.respContentDisposition = '';
728
746
  if (this.responseBlobUrl) {
@@ -167,13 +167,17 @@ class ApiRequest extends _lit.LitElement {
167
167
  return (0, _keyed.keyed)(id, (0, _lit.html)` <div id="api-request-${id}" class="api-request col regular-font request-panel ${this.renderStyle === 'focused' || this.callback === 'true' ? 'focused-mode' : 'view-mode'}"> <div class="${this.callback === 'true' ? 'tiny-title' : 'req-res-title'}"> ${this.callback === 'true' ? 'CALLBACK REQUEST' : (0, _index.getI18nText)('operations.request')} </div> <div> ${this.inputParametersTemplate('path')} ${this.inputParametersTemplate('query')} ${this.inputParametersTemplate('header')} ${this.inputParametersTemplate('cookie')} ${this.requestBodyTemplate()} ${this.allowTry === 'false' ? '' : (0, _lit.html)`${this.apiCallTemplate()}`} </div> </div> `);
168
168
  }
169
169
  updated(changedProperties) {
170
+ // When the operation is changed, reset the display view properties
171
+ if (changedProperties.get('elementId')) {
172
+ this.activeResponseTab = 'curl';
173
+ }
170
174
  // In focused mode after rendering the request component, update the text-areas(which contains examples) using the original values from hidden textareas.
171
175
  // This is done coz, user may update the dom by editing the textarea's and once the DOM is updated externally change detection wont happen, therefore update the values manually
172
176
  if (this.renderStyle !== 'focused') {
173
177
  return;
174
178
  }
175
179
 
176
- // dont update example as only tabs is switched
180
+ // don't update example as only tabs is switched
177
181
  if (changedProperties.size === 1 && changedProperties.has('activeSchemaTab')) {
178
182
  return;
179
183
  }
@@ -456,7 +460,7 @@ class ApiRequest extends _lit.LitElement {
456
460
  return;
457
461
  }
458
462
  this.activeResponseTab = e.target.dataset.tab;
459
- }}"> <br> <div style="width:100%"> <button class="tab-btn ${!hasResponse || this.activeResponseTab === 'curl' ? 'active' : ''}" data-tab="curl">FULL REQUEST</button> ${!hasResponse ? '' : (0, _lit.html)` <button class="tab-btn ${this.activeResponseTab === 'response' ? 'active' : ''}" data-tab="response">${(0, _index.getI18nText)('operations.response')}</button> <button class="tab-btn ${this.activeResponseTab === 'headers' ? 'active' : ''}" data-tab="headers">${(0, _index.getI18nText)('operations.response-headers')}</button>`} </div> </div> ${this.responseIsBlob ? (0, _lit.html)` <div class="tab-content col" style="flex:1;display:${this.activeResponseTab === 'response' ? 'flex' : 'none'}"> ${this.responseBlobType === 'image' ? (0, _lit.html)`<img style="max-height:var(--resp-area-height,300px);object-fit:contain" class="mar-top-8" src="${this.responseBlobUrl}">` : ''} <div style="display:flex;justify-content:center"> <div> <button class="m-btn thin-border mar-top-8" style="width:135px" @click="${this.downloadResponseBlob}" part="btn btn-outline">DOWNLOAD</button> ${this.responseBlobType === 'view' || this.responseBlobType === 'image' ? (0, _lit.html)`<button class="m-btn thin-border mar-top-8" style="width:135px" @click="${this.viewResponseBlob}" part="btn btn-outline">VIEW (NEW TAB)</button>` : ''} </div> </div> </div>` : (0, _lit.html)` <div class="tab-content col m-markdown" style="flex:1;display:${this.activeResponseTab === 'response' ? 'flex' : 'none'}"> <syntax-highlighter style="min-height:60px" mime-type="${this.responseContentType}" .content="${this.responseText}"> </div>`} <div class="tab-content col m-markdown" style="flex:1;display:${this.activeResponseTab === 'headers' ? 'flex' : 'none'}"> <syntax-highlighter language="http" .content="${this.responseHeaders}"> </div> <div class="tab-content m-markdown col" style="flex:1;display:${this.activeResponseTab === 'curl' ? 'flex' : 'none'}"> <syntax-highlighter language="shell" .content="${curlSyntax.trim()}"> </div> </div>`;
463
+ }}"> <br> <div style="width:100%"> <button class="tab-btn ${!hasResponse || this.activeResponseTab === 'curl' ? 'active' : ''}" data-tab="curl">REQUEST</button> ${!hasResponse ? '' : (0, _lit.html)` <button class="tab-btn ${this.activeResponseTab === 'response' ? 'active' : ''}" data-tab="response">${(0, _index.getI18nText)('operations.response')}</button> <button class="tab-btn ${this.activeResponseTab === 'headers' ? 'active' : ''}" data-tab="headers">${(0, _index.getI18nText)('operations.response-headers')}</button>`} </div> </div> ${this.responseIsBlob ? (0, _lit.html)` <div class="tab-content col" style="flex:1;display:${this.activeResponseTab === 'response' ? 'flex' : 'none'}"> ${this.responseBlobType === 'image' ? (0, _lit.html)`<img style="max-height:var(--resp-area-height,300px);object-fit:contain" class="mar-top-8" src="${this.responseBlobUrl}">` : ''} <div style="display:flex;justify-content:center"> <div> <button class="m-btn thin-border mar-top-8" style="width:135px" @click="${this.downloadResponseBlob}" part="btn btn-outline">DOWNLOAD</button> ${this.responseBlobType === 'view' || this.responseBlobType === 'image' ? (0, _lit.html)`<button class="m-btn thin-border mar-top-8" style="width:135px" @click="${this.viewResponseBlob}" part="btn btn-outline">VIEW (NEW TAB)</button>` : ''} </div> </div> </div>` : (0, _lit.html)` <div class="tab-content col m-markdown" style="flex:1;display:${this.activeResponseTab === 'response' ? 'flex' : 'none'}"> <syntax-highlighter style="min-height:60px" mime-type="${this.responseContentType}" .content="${this.responseText}"> </div>`} <div class="tab-content col m-markdown" style="flex:1;display:${this.activeResponseTab === 'headers' ? 'flex' : 'none'}"> <syntax-highlighter style="min-height:60px" language="http" .content="${this.responseHeaders}"> </div> <div class="tab-content m-markdown col" style="flex:1;display:${this.activeResponseTab === 'curl' ? 'flex' : 'none'}"> <syntax-highlighter style="min-height:60px" language="shell" .content="${curlSyntax.trim()}"> </div> </div>`;
460
464
  }
461
465
  apiCallTemplate() {
462
466
  return (0, _lit.html)` <div style="display:flex;align-items:flex-end;margin:16px 0;font-size:var(--font-size-small)"> ${this.parameters.length > 0 || this.request_body ? (0, _lit.html)` <button class="m-btn thin-border" part="btn btn-outline" style="margin-right:5px" @click="${this.onClearRequestData}"> ${(0, _index.getI18nText)('operations.clear')} </button>` : ''} <button class="m-btn primary btn-execute thin-border" part="btn btn-fill btn-try" @click="${this.onTryClick}">${(0, _index.getI18nText)('operations.execute')}</button> </div> ${this.apiResponseTabTemplate()} `;
@@ -484,6 +488,16 @@ class ApiRequest extends _lit.LitElement {
484
488
  this.dispatchEvent(new CustomEvent('event', event));
485
489
  this.computeCurlSyntax();
486
490
  }
491
+ validateAllRequestParameters() {
492
+ const requestPanelEl = this.closest('.request-panel');
493
+ const pathParamEls = [...requestPanelEl.querySelectorAll("[data-ptype='path']")];
494
+ const missingPathParameterValue = pathParamEls.find(el => !el.value);
495
+ if (missingPathParameterValue) {
496
+ const error = Error(`All path parameters are required and a valid value was not found for the parameter: '${missingPathParameterValue.dataset.pname}'.`);
497
+ error.code = 'MissingPathParameter';
498
+ throw error;
499
+ }
500
+ }
487
501
  recomputeFetchOptions() {
488
502
  const requestPanelEl = this.closest('.request-panel');
489
503
  const pathParamEls = [...requestPanelEl.querySelectorAll("[data-ptype='path']")];
@@ -498,12 +512,6 @@ class ApiRequest extends _lit.LitElement {
498
512
  pathParameterMap[el.dataset.pname] = el.value;
499
513
  pathUrl = pathUrl.replace(`{${el.dataset.pname}}`, encodeURIComponent(el.value) || '-');
500
514
  });
501
- const missingPathParameterValue = pathParamEls.find(el => !el.value);
502
- if (missingPathParameterValue) {
503
- const error = Error(`All path parameters are required and a valid value was not found for the parameter: '${missingPathParameterValue.dataset.pname}'.`);
504
- error.code = 'MissingPathParameter';
505
- throw error;
506
- }
507
515
 
508
516
  // Handle relative serverUrls
509
517
  if (!pathUrl.startsWith('http')) {
@@ -728,6 +736,16 @@ class ApiRequest extends _lit.LitElement {
728
736
  this.activeResponseTab = 'response';
729
737
  return;
730
738
  }
739
+ try {
740
+ this.validateAllRequestParameters();
741
+ } catch (error) {
742
+ this.responseMessage = error.message;
743
+ this.responseStatus = 'error';
744
+ this.responseUrl = '';
745
+ this.responseHeaders = '';
746
+ this.responseText = '';
747
+ return;
748
+ }
731
749
  this.responseIsBlob = false;
732
750
  this.respContentDisposition = '';
733
751
  if (this.responseBlobUrl) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openapi-explorer",
3
- "version": "2.2.728",
3
+ "version": "2.2.730",
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",