openapi-explorer 2.2.725 → 2.2.728

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.
@@ -195,7 +195,7 @@ export default class ApiRequest extends LitElement {
195
195
  }[paramLocation];
196
196
  const tableRows = [];
197
197
  for (const param of filteredParams) {
198
- var _this$storedParamValu, _paramSchema$allowedV;
198
+ var _param$style, _param$explode;
199
199
  if (!param.schema) {
200
200
  continue;
201
201
  }
@@ -207,33 +207,57 @@ export default class ApiRequest extends LitElement {
207
207
  continue;
208
208
  }
209
209
  const defaultVal = Array.isArray(paramSchema.default) ? paramSchema.default : `${paramSchema.default}`;
210
- let paramStyle = 'form';
211
- let paramExplode = true;
212
- if (paramLocation === 'query') {
213
- if (param.style && 'form spaceDelimited pipeDelimited'.includes(param.style)) {
214
- paramStyle = param.style;
215
- }
216
- if (typeof param.explode === 'boolean') {
217
- paramExplode = param.explode;
218
- }
210
+ // Set the default style: https://spec.openapis.org/oas/v3.1.0.html#fixed-fields-9
211
+ const paramStyle = (_param$style = param.style) !== null && _param$style !== void 0 ? _param$style : {
212
+ query: 'form',
213
+ path: 'simple',
214
+ header: 'simple',
215
+ cookie: 'form'
216
+ }[paramLocation];
217
+ const paramExplode = (_param$explode = param.explode) !== null && _param$explode !== void 0 ? _param$explode : param.style === 'form';
218
+ const rowGenerator = ({
219
+ name: paramName,
220
+ description: paramDescription,
221
+ required: paramRequired
222
+ }, generatedParamSchema) => {
223
+ var _this$storedParamValu, _generatedParamSchema;
224
+ const displayAllowedValuesHints = (generatedParamSchema.type === 'object' || generatedParamSchema.type === 'array') && generatedParamSchema.allowedValues;
225
+ return html` <tr> <td colspan="1" style="width:160px;min-width:50px;vertical-align:top"> <div class="param-name ${generatedParamSchema.deprecated ? 'deprecated' : ''}" style="margin-top:1rem"> ${paramName}${!generatedParamSchema.deprecated && paramRequired ? html`<span style="color:var(--red)">*</span>` : ''} </div> <div class="param-type" style="margin-bottom:1rem"> ${generatedParamSchema.type === 'array' ? `${generatedParamSchema.arrayType}` : `${generatedParamSchema.format ? generatedParamSchema.format : generatedParamSchema.type}`}${!generatedParamSchema.deprecated && paramRequired ? html`<span style="opacity:0">*</span>` : ''} </div> </td> <td colspan="2" style="min-width:160px;vertical-align:top"> ${this.allowTry === 'true' ? generatedParamSchema.type === 'array' && html` <div style="margin-top:1rem;margin-bottom:1rem"> <tag-input class="request-param" autocomplete="on" id="request-param-${paramName}" style="width:100%" data-ptype="${paramLocation}" data-pname="${paramName}" data-default="${Array.isArray(defaultVal) ? defaultVal.join('~|~') : defaultVal}" data-param-serialize-style="${paramStyle}" data-param-serialize-explode="${paramExplode}" data-array="true" placeholder="add-multiple ↩" @change="${e => {
226
+ this.storedParamValues[paramName] = e.detail.value;
227
+ this.computeCurlSyntax();
228
+ }}" .value="${(_this$storedParamValu = this.storedParamValues[paramName]) !== null && _this$storedParamValu !== void 0 ? _this$storedParamValu : this.fillRequestWithDefault === 'true' && Array.isArray(defaultVal) ? defaultVal : defaultVal.split(',')}"></tag-input> </div>` || generatedParamSchema.type === 'object' && html` <textarea autocomplete="on" id="request-param-${paramName}" @input="${() => {
229
+ this.computeCurlSyntax();
230
+ }}" class="textarea small request-param" part="textarea small textarea-param" rows="3" data-ptype="${paramLocation}" data-pname="${paramName}" data-default="${defaultVal}" data-param-serialize-style="${paramStyle}" data-param-serialize-explode="${paramExplode}" spellcheck="false" placeholder="${generatedParamSchema.example || defaultVal || ''}" style="width:100%;margin-top:1rem;margin-bottom:1rem" .value="${this.fillRequestWithDefault === 'true' ? defaultVal : ''}"></textarea>` || generatedParamSchema.allowedValues && html` <select aria-label="mime type" style="width:100%;margin-top:1rem;margin-bottom:1rem" data-ptype="${paramLocation}" data-pname="${paramName}" .value="${this.fillRequestWithDefault === 'true' ? defaultVal : ''}" @change="${e => {
231
+ this.storedParamValues[paramName] = e;
232
+ this.computeCurlSyntax();
233
+ }}"> ${generatedParamSchema.allowedValues.map(allowedValue => html` <option value="${allowedValue}" ?selected="${allowedValue === this.storedParamValues[paramName]}"> ${allowedValue === null ? '-' : allowedValue} </option>`)} </select>` || html` <input type="${generatedParamSchema.format === 'password' ? 'password' : 'text'}" spellcheck="false" style="width:100%;margin-top:1rem;margin-bottom:1rem" autocomplete="on" id="request-param-${paramName}" @input="${() => {
234
+ this.computeCurlSyntax();
235
+ }}" placeholder="${generatedParamSchema.example || defaultVal || ''}" class="request-param" part="textbox textbox-param" data-ptype="${paramLocation}" data-pname="${paramName}" data-default="${Array.isArray(defaultVal) ? defaultVal.join('~|~') : defaultVal}" data-array="false" @keyup="${this.requestParamFunction}" .value="${this.fillRequestWithDefault === 'true' ? defaultVal : ''}">` : ''} ${this.exampleListTemplate.call(this, param, generatedParamSchema.type)} </td> ${this.renderStyle === 'focused' ? html` <td colspan="2" style="vertical-align:top"> ${paramDescription ? html` <div class="param-description" style="margin-top:1rem"> ${unsafeHTML(toMarkdown(paramDescription))} </div>` : ''} ${generatedParamSchema.constraints.length || displayAllowedValuesHints || generatedParamSchema.pattern ? html` <div class="param-constraint" style="margin-top:1rem"> ${generatedParamSchema.constraints.length ? html`<span style="font-weight:700">Constraints: </span>${generatedParamSchema.constraints.join(', ')}<br>` : ''} ${generatedParamSchema.pattern ? html` <div class="tooltip tooltip-replace" style="cursor:pointer;max-width:100%;display:flex"> <div style="white-space:nowrap;font-weight:700;margin-right:2px">Pattern: </div> <div style="white-space:nowrap;text-overflow:ellipsis;max-width:100%;overflow:hidden">${generatedParamSchema.pattern}</div> <br> <div class="tooltip-text" style="position:absolute;display:block">${generatedParamSchema.pattern}</div> </div> ` : ''} ${(_generatedParamSchema = generatedParamSchema.allowedValues) === null || _generatedParamSchema === void 0 ? void 0 : _generatedParamSchema.map((v, i) => html` ${i > 0 ? '|' : html`<span style="font-weight:700">Allowed: </span>`} ${html` <a part="anchor anchor-param-constraint" class="${this.allowTry === 'true' ? '' : 'inactive-link'}" data-type="${generatedParamSchema.type === 'array' ? 'array' : 'string'}" data-enum="${v === null || v === void 0 ? void 0 : v.trim()}" @click="${e => {
236
+ const inputEl = e.target.closest('table').querySelector(`[data-pname="${paramName}"]`);
237
+ if (inputEl) {
238
+ inputEl.value = e.target.dataset.type === 'array' ? [e.target.dataset.enum] : e.target.dataset.enum;
239
+ }
240
+ }}"> ${v === null ? '-' : v} </a>`}`)} </div>` : ''} </td> ` : ''} </tr>`;
241
+ };
242
+ let newRows = [];
243
+ if (paramStyle === 'form' && paramExplode) {
244
+ newRows = Object.keys(param.schema.properties).map(explodedParamKey => {
245
+ var _param$schema, _param$schema$require;
246
+ const explodedParam = param.schema.properties[explodedParamKey];
247
+ const explodedParamSchema = getTypeInfo(explodedParam, {
248
+ includeNulls: this.includeNulls,
249
+ enableExampleGeneration: true
250
+ });
251
+ return rowGenerator({
252
+ name: explodedParamKey,
253
+ description: explodedParam.description,
254
+ required: (_param$schema = param.schema) === null || _param$schema === void 0 ? void 0 : (_param$schema$require = _param$schema.required) === null || _param$schema$require === void 0 ? void 0 : _param$schema$require.includes(explodedParamKey)
255
+ }, explodedParamSchema);
256
+ });
257
+ } else {
258
+ newRows = rowGenerator(param, paramSchema);
219
259
  }
220
- const displayAllowedValuesHints = (paramSchema.type === 'object' || paramSchema.type === 'array') && paramSchema.allowedValues;
221
- tableRows.push(html` <tr> <td colspan="1" style="width:160px;min-width:50px;vertical-align:top"> <div class="param-name ${paramSchema.deprecated ? 'deprecated' : ''}" style="margin-top:1rem"> ${param.name}${!paramSchema.deprecated && param.required ? html`<span style="color:var(--red)">*</span>` : ''} </div> <div class="param-type" style="margin-bottom:1rem"> ${paramSchema.type === 'array' ? `${paramSchema.arrayType}` : `${paramSchema.format ? paramSchema.format : paramSchema.type}`}${!paramSchema.deprecated && param.required ? html`<span style="opacity:0">*</span>` : ''} </div> </td> <td colspan="2" style="min-width:160px;vertical-align:top"> ${this.allowTry === 'true' ? paramSchema.type === 'array' && html` <div style="margin-top:1rem;margin-bottom:1rem"> <tag-input class="request-param" autocomplete="on" id="request-param-${param.name}" style="width:100%" data-ptype="${paramLocation}" data-pname="${param.name}" data-default="${Array.isArray(defaultVal) ? defaultVal.join('~|~') : defaultVal}" data-param-serialize-style="${paramStyle}" data-param-serialize-explode="${paramExplode}" data-array="true" placeholder="add-multiple ↩" @change="${e => {
222
- this.storedParamValues[param.name] = e.detail.value;
223
- this.computeCurlSyntax();
224
- }}" .value="${(_this$storedParamValu = this.storedParamValues[param.name]) !== null && _this$storedParamValu !== void 0 ? _this$storedParamValu : this.fillRequestWithDefault === 'true' && Array.isArray(defaultVal) ? defaultVal : defaultVal.split(',')}"></tag-input> </div>` || paramSchema.type === 'object' && html` <textarea autocomplete="on" id="request-param-${param.name}" @input="${() => {
225
- this.computeCurlSyntax();
226
- }}" class="textarea small request-param" part="textarea small textarea-param" rows="3" data-ptype="${paramLocation}" data-pname="${param.name}" data-default="${defaultVal}" data-param-serialize-style="${paramStyle}" data-param-serialize-explode="${paramExplode}" spellcheck="false" placeholder="${paramSchema.example || defaultVal || ''}" style="width:100%;margin-top:1rem;margin-bottom:1rem" .value="${this.fillRequestWithDefault === 'true' ? defaultVal : ''}"></textarea>` || paramSchema.allowedValues && html` <select aria-label="mime type" style="width:100%;margin-top:1rem;margin-bottom:1rem" data-ptype="${paramLocation}" data-pname="${param.name}" .value="${this.fillRequestWithDefault === 'true' ? defaultVal : ''}" @change="${e => {
227
- this.storedParamValues[param.name] = e;
228
- this.computeCurlSyntax();
229
- }}"> ${paramSchema.allowedValues.map(allowedValue => html` <option value="${allowedValue}" ?selected="${allowedValue === this.storedParamValues[param.name]}"> ${allowedValue === null ? '-' : allowedValue} </option>`)} </select>` || html` <input type="${paramSchema.format === 'password' ? 'password' : 'text'}" spellcheck="false" style="width:100%;margin-top:1rem;margin-bottom:1rem" autocomplete="on" id="request-param-${param.name}" @input="${() => {
230
- this.computeCurlSyntax();
231
- }}" placeholder="${paramSchema.example || defaultVal || ''}" class="request-param" part="textbox textbox-param" data-ptype="${paramLocation}" data-pname="${param.name}" data-default="${Array.isArray(defaultVal) ? defaultVal.join('~|~') : defaultVal}" data-array="false" @keyup="${this.requestParamFunction}" .value="${this.fillRequestWithDefault === 'true' ? defaultVal : ''}">` : ''} ${this.exampleListTemplate.call(this, param, paramSchema.type)} </td> ${this.renderStyle === 'focused' ? html` <td colspan="2" style="vertical-align:top"> ${param.description ? html` <div class="param-description" style="margin-top:1rem"> ${unsafeHTML(toMarkdown(param.description))} </div>` : ''} ${paramSchema.constraints.length || displayAllowedValuesHints || paramSchema.pattern ? html` <div class="param-constraint" style="margin-top:1rem"> ${paramSchema.constraints.length ? html`<span style="font-weight:700">Constraints: </span>${paramSchema.constraints.join(', ')}<br>` : ''} ${paramSchema.pattern ? html` <div class="tooltip tooltip-replace" style="cursor:pointer;max-width:100%;display:flex"> <div style="white-space:nowrap;font-weight:700;margin-right:2px">Pattern: </div> <div style="white-space:nowrap;text-overflow:ellipsis;max-width:100%;overflow:hidden">${paramSchema.pattern}</div> <br> <div class="tooltip-text" style="position:absolute;display:block">${paramSchema.pattern}</div> </div> ` : ''} ${(_paramSchema$allowedV = paramSchema.allowedValues) === null || _paramSchema$allowedV === void 0 ? void 0 : _paramSchema$allowedV.map((v, i) => html` ${i > 0 ? '|' : html`<span style="font-weight:700">Allowed: </span>`} ${html` <a part="anchor anchor-param-constraint" class="${this.allowTry === 'true' ? '' : 'inactive-link'}" data-type="${paramSchema.type === 'array' ? 'array' : 'string'}" data-enum="${v === null || v === void 0 ? void 0 : v.trim()}" @click="${e => {
232
- const inputEl = e.target.closest('table').querySelector(`[data-pname="${param.name}"]`);
233
- if (inputEl) {
234
- inputEl.value = e.target.dataset.type === 'array' ? [e.target.dataset.enum] : e.target.dataset.enum;
235
- }
236
- }}"> ${v === null ? '-' : v} </a>`}`)} </div>` : ''} </td> ` : ''} </tr>`);
260
+ tableRows.push(newRows);
237
261
  }
238
262
  return html` <div class="table-title top-gap">${title}${paramLocation === 'path' ? html`<span style="color:var(--red)">*</span>` : ''}</div> <div style="display:block;overflow-x:auto;max-width:100%"> <table role="presentation" class="m-table" style="width:100%;word-break:break-word"> ${tableRows} </table> </div>`;
239
263
  }
@@ -459,7 +483,6 @@ export default class ApiRequest extends LitElement {
459
483
  const requestPanelEl = this.closest('.request-panel');
460
484
  const pathParamEls = [...requestPanelEl.querySelectorAll("[data-ptype='path']")];
461
485
  const queryParamEls = [...requestPanelEl.querySelectorAll("[data-ptype='query']")];
462
- const queryParamObjTypeEls = [...requestPanelEl.querySelectorAll("[data-ptype='query-object']")];
463
486
  const headerParamEls = [...requestPanelEl.querySelectorAll("[data-ptype='header']")];
464
487
  const requestBodyContainerEl = requestPanelEl.querySelector('.request-body-container');
465
488
  let pathUrl = `${this.serverUrl.replace(/\/$/, '')}${this.path.replaceAll(' ', '')}`;
@@ -507,7 +530,7 @@ export default class ApiRequest extends LitElement {
507
530
  } else if (paramSerializeStyle === 'pipeDelimited') {
508
531
  fetchUrl.searchParams.append(el.dataset.pname, values.join('|').replace(/^\||\|$/g, ''));
509
532
  } else {
510
- if (paramSerializeExplode === 'true') {
533
+ if (paramSerializeExplode === 'true' || paramSerializeExplode === true) {
511
534
  // eslint-disable-line no-lonely-if
512
535
  values.forEach(v => {
513
536
  fetchUrl.searchParams.append(el.dataset.pname, v);
@@ -520,40 +543,6 @@ export default class ApiRequest extends LitElement {
520
543
  }
521
544
  });
522
545
 
523
- // Query Params (Dynamic - create from JSON)
524
- queryParamObjTypeEls.map(el => {
525
- try {
526
- let queryParamObj = {};
527
- const paramSerializeStyle = el.dataset.paramSerializeStyle;
528
- const paramSerializeExplode = el.dataset.paramSerializeExplode;
529
- queryParamObj = Object.assign(queryParamObj, JSON.parse(el.value.replace(/\s+/g, ' ')));
530
- for (const key in queryParamObj) {
531
- if (typeof queryParamObj[key] === 'object') {
532
- if (Array.isArray(queryParamObj[key])) {
533
- if (paramSerializeStyle === 'spaceDelimited') {
534
- fetchUrl.searchParams.append(key, queryParamObj[key].join(' '));
535
- } else if (paramSerializeStyle === 'pipeDelimited') {
536
- fetchUrl.searchParams.append(key, queryParamObj[key].join('|'));
537
- } else {
538
- if (paramSerializeExplode === 'true') {
539
- // eslint-disable-line no-lonely-if
540
- queryParamObj[key].forEach(v => {
541
- fetchUrl.searchParams.append(key, v);
542
- });
543
- } else {
544
- fetchUrl.searchParams.append(key, queryParamObj[key]);
545
- }
546
- }
547
- }
548
- } else {
549
- fetchUrl.searchParams.append(key, queryParamObj[key]);
550
- }
551
- }
552
- } catch (err) {
553
- console.log('OpenAPI Explorer: unable to parse %s into object', el.value); // eslint-disable-line no-console
554
- }
555
- });
556
-
557
546
  // Add Authentication api keys if provided
558
547
  this.api_keys.filter(v => v.finalKeyValue).forEach(v => {
559
548
  if (v.in === 'query') {
@@ -702,7 +691,7 @@ export default class ApiRequest extends LitElement {
702
691
  } = this.recomputeFetchOptions();
703
692
  const curl = `curl -X ${this.method.toUpperCase()} "${fetchUrl.toString()}"`;
704
693
  const headers = headerOverride !== null && headerOverride !== void 0 ? headerOverride : fetchOptions.headers;
705
- const curlHeaders = [...headers.entries()].reduce((acc, [key, value]) => `${acc} \\\n -H "${key}: ${value}"`, '');
694
+ const curlHeaders = [...headers.entries()].reduce((acc, [key, value]) => `${acc} \\\n -H "${key}: ${value.replace(/"/g, '\\"')}"`, '');
706
695
  this.curlSyntax = `${curl}${curlHeaders}${curlParts.data}${curlParts.form}`;
707
696
  } catch (error) {
708
697
  /* There was an explicit issue and likely it was because the fetch options threw. */
@@ -200,7 +200,7 @@ class ApiRequest extends _lit.LitElement {
200
200
  }[paramLocation];
201
201
  const tableRows = [];
202
202
  for (const param of filteredParams) {
203
- var _this$storedParamValu, _paramSchema$allowedV;
203
+ var _param$style, _param$explode;
204
204
  if (!param.schema) {
205
205
  continue;
206
206
  }
@@ -212,33 +212,57 @@ class ApiRequest extends _lit.LitElement {
212
212
  continue;
213
213
  }
214
214
  const defaultVal = Array.isArray(paramSchema.default) ? paramSchema.default : `${paramSchema.default}`;
215
- let paramStyle = 'form';
216
- let paramExplode = true;
217
- if (paramLocation === 'query') {
218
- if (param.style && 'form spaceDelimited pipeDelimited'.includes(param.style)) {
219
- paramStyle = param.style;
220
- }
221
- if (typeof param.explode === 'boolean') {
222
- paramExplode = param.explode;
223
- }
215
+ // Set the default style: https://spec.openapis.org/oas/v3.1.0.html#fixed-fields-9
216
+ const paramStyle = (_param$style = param.style) !== null && _param$style !== void 0 ? _param$style : {
217
+ query: 'form',
218
+ path: 'simple',
219
+ header: 'simple',
220
+ cookie: 'form'
221
+ }[paramLocation];
222
+ const paramExplode = (_param$explode = param.explode) !== null && _param$explode !== void 0 ? _param$explode : param.style === 'form';
223
+ const rowGenerator = ({
224
+ name: paramName,
225
+ description: paramDescription,
226
+ required: paramRequired
227
+ }, generatedParamSchema) => {
228
+ var _this$storedParamValu, _generatedParamSchema;
229
+ const displayAllowedValuesHints = (generatedParamSchema.type === 'object' || generatedParamSchema.type === 'array') && generatedParamSchema.allowedValues;
230
+ return (0, _lit.html)` <tr> <td colspan="1" style="width:160px;min-width:50px;vertical-align:top"> <div class="param-name ${generatedParamSchema.deprecated ? 'deprecated' : ''}" style="margin-top:1rem"> ${paramName}${!generatedParamSchema.deprecated && paramRequired ? (0, _lit.html)`<span style="color:var(--red)">*</span>` : ''} </div> <div class="param-type" style="margin-bottom:1rem"> ${generatedParamSchema.type === 'array' ? `${generatedParamSchema.arrayType}` : `${generatedParamSchema.format ? generatedParamSchema.format : generatedParamSchema.type}`}${!generatedParamSchema.deprecated && paramRequired ? (0, _lit.html)`<span style="opacity:0">*</span>` : ''} </div> </td> <td colspan="2" style="min-width:160px;vertical-align:top"> ${this.allowTry === 'true' ? generatedParamSchema.type === 'array' && (0, _lit.html)` <div style="margin-top:1rem;margin-bottom:1rem"> <tag-input class="request-param" autocomplete="on" id="request-param-${paramName}" style="width:100%" data-ptype="${paramLocation}" data-pname="${paramName}" data-default="${Array.isArray(defaultVal) ? defaultVal.join('~|~') : defaultVal}" data-param-serialize-style="${paramStyle}" data-param-serialize-explode="${paramExplode}" data-array="true" placeholder="add-multiple ↩" @change="${e => {
231
+ this.storedParamValues[paramName] = e.detail.value;
232
+ this.computeCurlSyntax();
233
+ }}" .value="${(_this$storedParamValu = this.storedParamValues[paramName]) !== null && _this$storedParamValu !== void 0 ? _this$storedParamValu : this.fillRequestWithDefault === 'true' && Array.isArray(defaultVal) ? defaultVal : defaultVal.split(',')}"></tag-input> </div>` || generatedParamSchema.type === 'object' && (0, _lit.html)` <textarea autocomplete="on" id="request-param-${paramName}" @input="${() => {
234
+ this.computeCurlSyntax();
235
+ }}" class="textarea small request-param" part="textarea small textarea-param" rows="3" data-ptype="${paramLocation}" data-pname="${paramName}" data-default="${defaultVal}" data-param-serialize-style="${paramStyle}" data-param-serialize-explode="${paramExplode}" spellcheck="false" placeholder="${generatedParamSchema.example || defaultVal || ''}" style="width:100%;margin-top:1rem;margin-bottom:1rem" .value="${this.fillRequestWithDefault === 'true' ? defaultVal : ''}"></textarea>` || generatedParamSchema.allowedValues && (0, _lit.html)` <select aria-label="mime type" style="width:100%;margin-top:1rem;margin-bottom:1rem" data-ptype="${paramLocation}" data-pname="${paramName}" .value="${this.fillRequestWithDefault === 'true' ? defaultVal : ''}" @change="${e => {
236
+ this.storedParamValues[paramName] = e;
237
+ this.computeCurlSyntax();
238
+ }}"> ${generatedParamSchema.allowedValues.map(allowedValue => (0, _lit.html)` <option value="${allowedValue}" ?selected="${allowedValue === this.storedParamValues[paramName]}"> ${allowedValue === null ? '-' : allowedValue} </option>`)} </select>` || (0, _lit.html)` <input type="${generatedParamSchema.format === 'password' ? 'password' : 'text'}" spellcheck="false" style="width:100%;margin-top:1rem;margin-bottom:1rem" autocomplete="on" id="request-param-${paramName}" @input="${() => {
239
+ this.computeCurlSyntax();
240
+ }}" placeholder="${generatedParamSchema.example || defaultVal || ''}" class="request-param" part="textbox textbox-param" data-ptype="${paramLocation}" data-pname="${paramName}" data-default="${Array.isArray(defaultVal) ? defaultVal.join('~|~') : defaultVal}" data-array="false" @keyup="${this.requestParamFunction}" .value="${this.fillRequestWithDefault === 'true' ? defaultVal : ''}">` : ''} ${this.exampleListTemplate.call(this, param, generatedParamSchema.type)} </td> ${this.renderStyle === 'focused' ? (0, _lit.html)` <td colspan="2" style="vertical-align:top"> ${paramDescription ? (0, _lit.html)` <div class="param-description" style="margin-top:1rem"> ${(0, _unsafeHtml.unsafeHTML)((0, _commonUtils.toMarkdown)(paramDescription))} </div>` : ''} ${generatedParamSchema.constraints.length || displayAllowedValuesHints || generatedParamSchema.pattern ? (0, _lit.html)` <div class="param-constraint" style="margin-top:1rem"> ${generatedParamSchema.constraints.length ? (0, _lit.html)`<span style="font-weight:700">Constraints: </span>${generatedParamSchema.constraints.join(', ')}<br>` : ''} ${generatedParamSchema.pattern ? (0, _lit.html)` <div class="tooltip tooltip-replace" style="cursor:pointer;max-width:100%;display:flex"> <div style="white-space:nowrap;font-weight:700;margin-right:2px">Pattern: </div> <div style="white-space:nowrap;text-overflow:ellipsis;max-width:100%;overflow:hidden">${generatedParamSchema.pattern}</div> <br> <div class="tooltip-text" style="position:absolute;display:block">${generatedParamSchema.pattern}</div> </div> ` : ''} ${(_generatedParamSchema = generatedParamSchema.allowedValues) === null || _generatedParamSchema === void 0 ? void 0 : _generatedParamSchema.map((v, i) => (0, _lit.html)` ${i > 0 ? '|' : (0, _lit.html)`<span style="font-weight:700">Allowed: </span>`} ${(0, _lit.html)` <a part="anchor anchor-param-constraint" class="${this.allowTry === 'true' ? '' : 'inactive-link'}" data-type="${generatedParamSchema.type === 'array' ? 'array' : 'string'}" data-enum="${v === null || v === void 0 ? void 0 : v.trim()}" @click="${e => {
241
+ const inputEl = e.target.closest('table').querySelector(`[data-pname="${paramName}"]`);
242
+ if (inputEl) {
243
+ inputEl.value = e.target.dataset.type === 'array' ? [e.target.dataset.enum] : e.target.dataset.enum;
244
+ }
245
+ }}"> ${v === null ? '-' : v} </a>`}`)} </div>` : ''} </td> ` : ''} </tr>`;
246
+ };
247
+ let newRows = [];
248
+ if (paramStyle === 'form' && paramExplode) {
249
+ newRows = Object.keys(param.schema.properties).map(explodedParamKey => {
250
+ var _param$schema, _param$schema$require;
251
+ const explodedParam = param.schema.properties[explodedParamKey];
252
+ const explodedParamSchema = (0, _schemaUtils.getTypeInfo)(explodedParam, {
253
+ includeNulls: this.includeNulls,
254
+ enableExampleGeneration: true
255
+ });
256
+ return rowGenerator({
257
+ name: explodedParamKey,
258
+ description: explodedParam.description,
259
+ required: (_param$schema = param.schema) === null || _param$schema === void 0 ? void 0 : (_param$schema$require = _param$schema.required) === null || _param$schema$require === void 0 ? void 0 : _param$schema$require.includes(explodedParamKey)
260
+ }, explodedParamSchema);
261
+ });
262
+ } else {
263
+ newRows = rowGenerator(param, paramSchema);
224
264
  }
225
- const displayAllowedValuesHints = (paramSchema.type === 'object' || paramSchema.type === 'array') && paramSchema.allowedValues;
226
- tableRows.push((0, _lit.html)` <tr> <td colspan="1" style="width:160px;min-width:50px;vertical-align:top"> <div class="param-name ${paramSchema.deprecated ? 'deprecated' : ''}" style="margin-top:1rem"> ${param.name}${!paramSchema.deprecated && param.required ? (0, _lit.html)`<span style="color:var(--red)">*</span>` : ''} </div> <div class="param-type" style="margin-bottom:1rem"> ${paramSchema.type === 'array' ? `${paramSchema.arrayType}` : `${paramSchema.format ? paramSchema.format : paramSchema.type}`}${!paramSchema.deprecated && param.required ? (0, _lit.html)`<span style="opacity:0">*</span>` : ''} </div> </td> <td colspan="2" style="min-width:160px;vertical-align:top"> ${this.allowTry === 'true' ? paramSchema.type === 'array' && (0, _lit.html)` <div style="margin-top:1rem;margin-bottom:1rem"> <tag-input class="request-param" autocomplete="on" id="request-param-${param.name}" style="width:100%" data-ptype="${paramLocation}" data-pname="${param.name}" data-default="${Array.isArray(defaultVal) ? defaultVal.join('~|~') : defaultVal}" data-param-serialize-style="${paramStyle}" data-param-serialize-explode="${paramExplode}" data-array="true" placeholder="add-multiple ↩" @change="${e => {
227
- this.storedParamValues[param.name] = e.detail.value;
228
- this.computeCurlSyntax();
229
- }}" .value="${(_this$storedParamValu = this.storedParamValues[param.name]) !== null && _this$storedParamValu !== void 0 ? _this$storedParamValu : this.fillRequestWithDefault === 'true' && Array.isArray(defaultVal) ? defaultVal : defaultVal.split(',')}"></tag-input> </div>` || paramSchema.type === 'object' && (0, _lit.html)` <textarea autocomplete="on" id="request-param-${param.name}" @input="${() => {
230
- this.computeCurlSyntax();
231
- }}" class="textarea small request-param" part="textarea small textarea-param" rows="3" data-ptype="${paramLocation}" data-pname="${param.name}" data-default="${defaultVal}" data-param-serialize-style="${paramStyle}" data-param-serialize-explode="${paramExplode}" spellcheck="false" placeholder="${paramSchema.example || defaultVal || ''}" style="width:100%;margin-top:1rem;margin-bottom:1rem" .value="${this.fillRequestWithDefault === 'true' ? defaultVal : ''}"></textarea>` || paramSchema.allowedValues && (0, _lit.html)` <select aria-label="mime type" style="width:100%;margin-top:1rem;margin-bottom:1rem" data-ptype="${paramLocation}" data-pname="${param.name}" .value="${this.fillRequestWithDefault === 'true' ? defaultVal : ''}" @change="${e => {
232
- this.storedParamValues[param.name] = e;
233
- this.computeCurlSyntax();
234
- }}"> ${paramSchema.allowedValues.map(allowedValue => (0, _lit.html)` <option value="${allowedValue}" ?selected="${allowedValue === this.storedParamValues[param.name]}"> ${allowedValue === null ? '-' : allowedValue} </option>`)} </select>` || (0, _lit.html)` <input type="${paramSchema.format === 'password' ? 'password' : 'text'}" spellcheck="false" style="width:100%;margin-top:1rem;margin-bottom:1rem" autocomplete="on" id="request-param-${param.name}" @input="${() => {
235
- this.computeCurlSyntax();
236
- }}" placeholder="${paramSchema.example || defaultVal || ''}" class="request-param" part="textbox textbox-param" data-ptype="${paramLocation}" data-pname="${param.name}" data-default="${Array.isArray(defaultVal) ? defaultVal.join('~|~') : defaultVal}" data-array="false" @keyup="${this.requestParamFunction}" .value="${this.fillRequestWithDefault === 'true' ? defaultVal : ''}">` : ''} ${this.exampleListTemplate.call(this, param, paramSchema.type)} </td> ${this.renderStyle === 'focused' ? (0, _lit.html)` <td colspan="2" style="vertical-align:top"> ${param.description ? (0, _lit.html)` <div class="param-description" style="margin-top:1rem"> ${(0, _unsafeHtml.unsafeHTML)((0, _commonUtils.toMarkdown)(param.description))} </div>` : ''} ${paramSchema.constraints.length || displayAllowedValuesHints || paramSchema.pattern ? (0, _lit.html)` <div class="param-constraint" style="margin-top:1rem"> ${paramSchema.constraints.length ? (0, _lit.html)`<span style="font-weight:700">Constraints: </span>${paramSchema.constraints.join(', ')}<br>` : ''} ${paramSchema.pattern ? (0, _lit.html)` <div class="tooltip tooltip-replace" style="cursor:pointer;max-width:100%;display:flex"> <div style="white-space:nowrap;font-weight:700;margin-right:2px">Pattern: </div> <div style="white-space:nowrap;text-overflow:ellipsis;max-width:100%;overflow:hidden">${paramSchema.pattern}</div> <br> <div class="tooltip-text" style="position:absolute;display:block">${paramSchema.pattern}</div> </div> ` : ''} ${(_paramSchema$allowedV = paramSchema.allowedValues) === null || _paramSchema$allowedV === void 0 ? void 0 : _paramSchema$allowedV.map((v, i) => (0, _lit.html)` ${i > 0 ? '|' : (0, _lit.html)`<span style="font-weight:700">Allowed: </span>`} ${(0, _lit.html)` <a part="anchor anchor-param-constraint" class="${this.allowTry === 'true' ? '' : 'inactive-link'}" data-type="${paramSchema.type === 'array' ? 'array' : 'string'}" data-enum="${v === null || v === void 0 ? void 0 : v.trim()}" @click="${e => {
237
- const inputEl = e.target.closest('table').querySelector(`[data-pname="${param.name}"]`);
238
- if (inputEl) {
239
- inputEl.value = e.target.dataset.type === 'array' ? [e.target.dataset.enum] : e.target.dataset.enum;
240
- }
241
- }}"> ${v === null ? '-' : v} </a>`}`)} </div>` : ''} </td> ` : ''} </tr>`);
265
+ tableRows.push(newRows);
242
266
  }
243
267
  return (0, _lit.html)` <div class="table-title top-gap">${title}${paramLocation === 'path' ? (0, _lit.html)`<span style="color:var(--red)">*</span>` : ''}</div> <div style="display:block;overflow-x:auto;max-width:100%"> <table role="presentation" class="m-table" style="width:100%;word-break:break-word"> ${tableRows} </table> </div>`;
244
268
  }
@@ -464,7 +488,6 @@ class ApiRequest extends _lit.LitElement {
464
488
  const requestPanelEl = this.closest('.request-panel');
465
489
  const pathParamEls = [...requestPanelEl.querySelectorAll("[data-ptype='path']")];
466
490
  const queryParamEls = [...requestPanelEl.querySelectorAll("[data-ptype='query']")];
467
- const queryParamObjTypeEls = [...requestPanelEl.querySelectorAll("[data-ptype='query-object']")];
468
491
  const headerParamEls = [...requestPanelEl.querySelectorAll("[data-ptype='header']")];
469
492
  const requestBodyContainerEl = requestPanelEl.querySelector('.request-body-container');
470
493
  let pathUrl = `${this.serverUrl.replace(/\/$/, '')}${this.path.replaceAll(' ', '')}`;
@@ -512,7 +535,7 @@ class ApiRequest extends _lit.LitElement {
512
535
  } else if (paramSerializeStyle === 'pipeDelimited') {
513
536
  fetchUrl.searchParams.append(el.dataset.pname, values.join('|').replace(/^\||\|$/g, ''));
514
537
  } else {
515
- if (paramSerializeExplode === 'true') {
538
+ if (paramSerializeExplode === 'true' || paramSerializeExplode === true) {
516
539
  // eslint-disable-line no-lonely-if
517
540
  values.forEach(v => {
518
541
  fetchUrl.searchParams.append(el.dataset.pname, v);
@@ -525,40 +548,6 @@ class ApiRequest extends _lit.LitElement {
525
548
  }
526
549
  });
527
550
 
528
- // Query Params (Dynamic - create from JSON)
529
- queryParamObjTypeEls.map(el => {
530
- try {
531
- let queryParamObj = {};
532
- const paramSerializeStyle = el.dataset.paramSerializeStyle;
533
- const paramSerializeExplode = el.dataset.paramSerializeExplode;
534
- queryParamObj = Object.assign(queryParamObj, JSON.parse(el.value.replace(/\s+/g, ' ')));
535
- for (const key in queryParamObj) {
536
- if (typeof queryParamObj[key] === 'object') {
537
- if (Array.isArray(queryParamObj[key])) {
538
- if (paramSerializeStyle === 'spaceDelimited') {
539
- fetchUrl.searchParams.append(key, queryParamObj[key].join(' '));
540
- } else if (paramSerializeStyle === 'pipeDelimited') {
541
- fetchUrl.searchParams.append(key, queryParamObj[key].join('|'));
542
- } else {
543
- if (paramSerializeExplode === 'true') {
544
- // eslint-disable-line no-lonely-if
545
- queryParamObj[key].forEach(v => {
546
- fetchUrl.searchParams.append(key, v);
547
- });
548
- } else {
549
- fetchUrl.searchParams.append(key, queryParamObj[key]);
550
- }
551
- }
552
- }
553
- } else {
554
- fetchUrl.searchParams.append(key, queryParamObj[key]);
555
- }
556
- }
557
- } catch (err) {
558
- console.log('OpenAPI Explorer: unable to parse %s into object', el.value); // eslint-disable-line no-console
559
- }
560
- });
561
-
562
551
  // Add Authentication api keys if provided
563
552
  this.api_keys.filter(v => v.finalKeyValue).forEach(v => {
564
553
  if (v.in === 'query') {
@@ -707,7 +696,7 @@ class ApiRequest extends _lit.LitElement {
707
696
  } = this.recomputeFetchOptions();
708
697
  const curl = `curl -X ${this.method.toUpperCase()} "${fetchUrl.toString()}"`;
709
698
  const headers = headerOverride !== null && headerOverride !== void 0 ? headerOverride : fetchOptions.headers;
710
- const curlHeaders = [...headers.entries()].reduce((acc, [key, value]) => `${acc} \\\n -H "${key}: ${value}"`, '');
699
+ const curlHeaders = [...headers.entries()].reduce((acc, [key, value]) => `${acc} \\\n -H "${key}: ${value.replace(/"/g, '\\"')}"`, '');
711
700
  this.curlSyntax = `${curl}${curlHeaders}${curlParts.data}${curlParts.form}`;
712
701
  } catch (error) {
713
702
  /* There was an explicit issue and likely it was because the fetch options threw. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openapi-explorer",
3
- "version": "2.2.725",
3
+ "version": "2.2.728",
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",