rapidoc 9.3.2 → 9.3.3

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.
@@ -3,6 +3,7 @@ import { unsafeHTML } from 'lit/directives/unsafe-html.js'; // eslint-disable-li
3
3
  import { guard } from 'lit/directives/guard.js'; // eslint-disable-line import/extensions
4
4
  import { live } from 'lit/directives/live.js'; // eslint-disable-line import/extensions
5
5
  import { marked } from 'marked';
6
+ import formatXml from 'xml-but-prettier';
6
7
  import Prism from 'prismjs';
7
8
  import TableStyles from '~/styles/table-styles';
8
9
  import FlexStyles from '~/styles/flex-styles';
@@ -12,8 +13,15 @@ import BorderStyles from '~/styles/border-styles';
12
13
  import TabStyles from '~/styles/tab-styles';
13
14
  import PrismStyles from '~/styles/prism-styles';
14
15
  import CustomStyles from '~/styles/custom-styles';
15
- import { copyToClipboard, prettyXml, downloadResource, viewResource } from '~/utils/common-utils';
16
- import { schemaInObjectNotation, getTypeInfo, generateExample, normalizeExamples, getSchemaFromParam, json2xml, nestExampleIfPresent } from '~/utils/schema-utils';
16
+ import { copyToClipboard, downloadResource, viewResource } from '~/utils/common-utils';
17
+ import { schemaInObjectNotation,
18
+ getTypeInfo,
19
+ generateExample,
20
+ normalizeExamples,
21
+ getSchemaFromParam,
22
+ json2xml,
23
+ nestExampleIfPresent,
24
+ anyExampleWithSummaryOrDescription } from '~/utils/schema-utils';
17
25
  import '~/components/json-tree';
18
26
  import '~/components/schema-tree';
19
27
  import '~/components/tag-input';
@@ -46,13 +54,13 @@ export default class ApiRequest extends LitElement {
46
54
  parser: { type: Object },
47
55
  accept: { type: String },
48
56
  callback: { type: String },
57
+ webhook: { type: String },
49
58
  responseMessage: { type: String, attribute: false },
50
59
  responseText: { type: String, attribute: false },
51
60
  responseHeaders: { type: String, attribute: false },
52
61
  responseStatus: { type: String, attribute: false },
53
62
  responseUrl: { type: String, attribute: false },
54
63
  fillRequestFieldsWithExample: { type: String, attribute: 'fill-request-fields-with-example' },
55
- useSummaryToListExamples: { type: String, attribute: 'use-summary-to-list-example' },
56
64
  allowTry: { type: String, attribute: 'allow-try' },
57
65
  renderStyle: { type: String, attribute: 'render-style' },
58
66
  schemaStyle: { type: String, attribute: 'schema-style' },
@@ -194,18 +202,19 @@ export default class ApiRequest extends LitElement {
194
202
  ${this.callback === 'true' ? 'CALLBACK REQUEST' : 'REQUEST'}
195
203
  </div>
196
204
  <div>
197
- ${guard([this.allowTry, this.parameters, this.activeParameterSchemaTabs], () => this.inputParametersTemplate('path'))}
198
- ${guard([this.allowTry, this.parameters, this.activeParameterSchemaTabs], () => this.inputParametersTemplate('query'))}
205
+ ${guard([this.method, this.path, this.allowTry, this.parameters, this.activeParameterSchemaTabs], () => this.inputParametersTemplate('path'))}
206
+ ${guard([this.method, this.path, this.allowTry, this.parameters, this.activeParameterSchemaTabs], () => this.inputParametersTemplate('query'))}
199
207
  ${this.requestBodyTemplate()}
200
- ${guard([this.allowTry, this.parameters, this.activeParameterSchemaTabs], () => this.inputParametersTemplate('header'))}
201
- ${guard([this.allowTry, this.parameters, this.activeParameterSchemaTabs], () => this.inputParametersTemplate('cookie'))}
208
+ ${guard([this.method, this.path, this.allowTry, this.parameters, this.activeParameterSchemaTabs], () => this.inputParametersTemplate('header'))}
209
+ ${guard([this.method, this.path, this.allowTry, this.parameters, this.activeParameterSchemaTabs], () => this.inputParametersTemplate('cookie'))}
202
210
  ${this.allowTry === 'false' ? '' : html`${this.apiCallTemplate()}`}
203
211
  </div>
204
212
  </div>
205
213
  `;
206
214
  }
207
215
 
208
- updated(changedProperties) {
216
+ /*
217
+ async updated(changedProperties) {
209
218
  // In focused mode after rendering the request component, update the text-areas(which contains examples) using
210
219
  // the original values from hidden textareas
211
220
  // 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
@@ -213,51 +222,98 @@ export default class ApiRequest extends LitElement {
213
222
  if (changedProperties.size === 1 && changedProperties.has('activeSchemaTab')) {
214
223
  // dont update example as only tabs is switched
215
224
  } else {
216
- const exampleTextAreaEls = [...this.shadowRoot.querySelectorAll('textarea[data-ptype="form-data"]')];
217
- exampleTextAreaEls.forEach((el) => {
218
- const origExampleEl = this.shadowRoot.querySelector(`textarea[data-pname='hidden-${el.dataset.pname}']`);
219
- if (origExampleEl) {
220
- el.value = origExampleEl.value;
221
- }
222
- });
225
+ this.requestUpdate();
223
226
  }
224
227
  }
225
228
  }
229
+ */
226
230
 
227
- /* eslint-disable indent */
231
+ async saveExampleState() {
232
+ if (this.renderStyle === 'focused') {
233
+ const reqBodyTextAreaEls = [...this.shadowRoot.querySelectorAll('textarea.request-body-param-user-input')];
234
+ reqBodyTextAreaEls.forEach((el) => {
235
+ el.dataset.user_example = el.value;
236
+ });
237
+ const exampleTextAreaEls = [...this.shadowRoot.querySelectorAll('textarea[data-ptype="form-data"]')];
238
+ exampleTextAreaEls.forEach((el) => {
239
+ el.dataset.user_example = el.value;
240
+ });
241
+ this.requestUpdate();
242
+ }
243
+ }
228
244
 
229
- exampleListTemplate(paramName, paramType, exampleList = []) {
245
+ async updateExamplesFromDataAttr() {
246
+ // In focused mode after rendering the request component, update the text-areas(which contains examples) using
247
+ // the original values from hidden textareas
248
+ // 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
249
+ if (this.renderStyle === 'focused') {
250
+ const reqBodyTextAreaEls = [...this.shadowRoot.querySelectorAll('textarea.request-body-param-user-input')];
251
+ reqBodyTextAreaEls.forEach((el) => {
252
+ el.value = el.dataset.user_example || el.dataset.example;
253
+ });
254
+ const exampleTextAreaEls = [...this.shadowRoot.querySelectorAll('textarea[data-ptype="form-data"]')];
255
+ exampleTextAreaEls.forEach((el) => {
256
+ el.value = el.dataset.user_example || el.dataset.example;
257
+ });
258
+ this.requestUpdate();
259
+ }
260
+ }
261
+
262
+ renderExample(example, paramType, paramName) {
230
263
  return html`
231
- ${(exampleList.length > 0
232
- ? html`<span style="font-weight:bold">Example: </span>
233
- ${exampleList.map((v, i) => html`
234
- ${i === 0 ? '' : '┃'}
235
- ${paramType === 'array' ? '[' : ''}
236
- <a part="anchor anchor-param-example" class = "${this.allowTry === 'true' ? '' : 'inactive-link'}"
237
- data-example-type="${paramType === 'array' ? paramType : 'string'}"
238
- data-example = "${v.value && Array.isArray(v.value) ? (v.value?.join('~|~')) : (v.value || '')}"
239
- @click="${(e) => {
240
- const inputEl = e.target.closest('table').querySelector(`[data-pname="${paramName}"]`);
241
- if (inputEl) {
242
- if (e.target.dataset.exampleType === 'array') {
243
- inputEl.value = e.target.dataset.example.split('~|~');
244
- } else {
245
- inputEl.value = e.target.dataset.example;
246
- }
247
- }
248
- }
249
- }"
250
- >
251
- ${this.useSummaryToListExamples === 'true'
252
- ? v.description || v.summary || (v.value && Array.isArray(v.value) ? (v.value?.join(', ')) : (v.value || ''))
253
- : v.value && Array.isArray(v.value) ? (v.value?.join(', ')) : (v.value || '')
254
- }
255
- </a>
256
- ${paramType === 'array' ? '] ' : ''}
264
+ ${paramType === 'array' ? '[' : ''}
265
+ <a
266
+ part="anchor anchor-param-example"
267
+ class="${this.allowTry === 'true' ? '' : 'inactive-link'}"
268
+ data-example-type="${paramType === 'array' ? paramType : 'string'}"
269
+ data-example="${example.value && Array.isArray(example.value) ? example.value?.join('~|~') : example.value || ''}"
270
+ @click="${(e) => {
271
+ const inputEl = e.target.closest('table').querySelector(`[data-pname="${paramName}"]`);
272
+ if (inputEl) {
273
+ if (e.target.dataset.exampleType === 'array') {
274
+ inputEl.value = e.target.dataset.example.split('~|~');
275
+ } else {
276
+ inputEl.value = e.target.dataset.example;
277
+ }
278
+ }
279
+ }
280
+ }"
281
+ >
282
+ ${example.value && Array.isArray(example.value) ? example.value?.join(', ') : example.value || '∅'}
283
+ </a>
284
+ ${paramType === 'array' ? '] ' : ''}
285
+ `;
286
+ }
287
+
288
+ renderShortFormatExamples(examples, paramType, paramName) {
289
+ return html`${examples.map((x, i) => html`
290
+ ${i === 0 ? '' : '┃'}
291
+ ${this.renderExample(x, paramType, paramName)}`)}`;
292
+ }
293
+
294
+ renderLongFormatExamples(exampleList, paramType, paramName) {
295
+ return html` <ul style="list-style-type: disclosure-closed;">
296
+ ${exampleList.map((v) => html`
297
+ <li>
298
+ ${this.renderExample(v, paramType, paramName)}
299
+ ${v.summary?.length > 0 ? html`<span>&lpar;${v.summary}&rpar;</span>` : ''}
300
+ ${v.description?.length > 0 ? html`<p>${unsafeHTML(marked(v.description))}</p>` : ''}
301
+ </li>
257
302
  `)}
258
- `
259
- : ''
260
- )}`;
303
+ </ul>`;
304
+ }
305
+
306
+ /* eslint-disable indent */
307
+
308
+ exampleListTemplate(paramName, paramType, exampleList = []) {
309
+ return html` ${exampleList.length > 0
310
+ ? html`<span style="font-weight:bold">Examples: </span>
311
+ ${
312
+ anyExampleWithSummaryOrDescription(exampleList)
313
+ ? this.renderLongFormatExamples(exampleList, paramType, paramName)
314
+ : this.renderShortFormatExamples(exampleList, paramType, paramName)
315
+ }`
316
+ : ''}`;
261
317
  }
262
318
 
263
319
  inputParametersTemplate(paramType) {
@@ -305,7 +361,6 @@ export default class ApiRequest extends LitElement {
305
361
  paramAllowReserved = param.allowReserved;
306
362
  }
307
363
  }
308
-
309
364
  // openapi 3.1.0 spec based examples (which must be Object(string : { value:any, summary?: string, description?: string})
310
365
  const example = normalizeExamples(
311
366
  (param.examples
@@ -323,8 +378,9 @@ export default class ApiRequest extends LitElement {
323
378
  serializeStyle || 'json',
324
379
  '',
325
380
  '',
326
- !(this.schemaHideReadOnly && (this.schemaHideReadOnly.includes(this.method) || this.schemaHideReadOnly === 'true')),
327
- !(this.schemaHideWriteOnly && (this.schemaHideWriteOnly.includes(this.method) || this.schemaHideWriteOnly === 'true')),
381
+ this.callback === 'true' || this.webhook === 'true' ? true : false, // eslint-disable-line no-unneeded-ternary
382
+ this.callback === 'true' || this.webhook === 'true' ? false : true, // eslint-disable-line no-unneeded-ternary
383
+ true,
328
384
  'text',
329
385
  false,
330
386
  )[0].exampleValue;
@@ -358,9 +414,13 @@ export default class ApiRequest extends LitElement {
358
414
  data-param-serialize-style = "${paramStyle}"
359
415
  data-param-serialize-explode = "${paramExplode}"
360
416
  data-param-allow-reserved = "${paramAllowReserved}"
417
+ data-x-fill-example = "${param['x-fill-example'] || 'yes'}"
361
418
  data-array = "true"
362
419
  placeholder = "add-multiple &#x21a9;"
363
- .value = "${Array.isArray(example.exampleVal) ? example.exampleVal : example.exampleVal}"
420
+ .value="${param['x-fill-example'] === 'no'
421
+ ? []
422
+ : live(this.fillRequestFieldsWithExample === 'true' ? Array.isArray(example.exampleVal) ? example.exampleVal : [example.exampleVal] : [])
423
+ }"
364
424
  >
365
425
  </tag-input>`
366
426
  : paramSchema.type === 'object'
@@ -387,13 +447,14 @@ export default class ApiRequest extends LitElement {
387
447
  data-param-serialize-style = "${paramStyle}"
388
448
  data-param-serialize-explode = "${paramExplode}"
389
449
  data-param-allow-reserved = "${paramAllowReserved}"
450
+ data-x-fill-example = "${param['x-fill-example'] || 'yes'}"
390
451
  spellcheck = "false"
391
- .textContent = "${this.fillRequestFieldsWithExample === 'true' ? example.exampleVal : ''}"
452
+ .textContent="${param['x-fill-example'] === 'no' ? '' : live(this.fillRequestFieldsWithExample === 'true' ? example.exampleVal : '')}"
392
453
  style = "resize:vertical; width:100%; height: ${'read focused'.includes(this.renderStyle) ? '180px' : '120px'};"
393
454
  ></textarea>
394
455
  </div>`
395
456
  : html`
396
- <div class="tab-content col">
457
+ <div class="tab-content col">
397
458
  <schema-tree
398
459
  class = 'json'
399
460
  style = 'display: block'
@@ -475,9 +536,16 @@ export default class ApiRequest extends LitElement {
475
536
  </div>`;
476
537
  }
477
538
 
478
- resetRequestBodySelection() {
539
+ // This method is called before navigation change in focusd mode
540
+ async beforerNavigationFocusedMode() {
541
+ // this.saveExampleState();
542
+ }
543
+
544
+ // This method is called after navigation change in focusd mode
545
+ async afterNavigationFocusedMode() {
479
546
  this.selectedRequestBodyType = '';
480
547
  this.selectedRequestBodyExample = '';
548
+ this.updateExamplesFromDataAttr();
481
549
  this.clearResponseData();
482
550
  }
483
551
 
@@ -559,8 +627,8 @@ export default class ApiRequest extends LitElement {
559
627
  reqBody.mimeType,
560
628
  reqBody.examples,
561
629
  reqBody.example,
562
- !(this.schemaHideReadOnly && (this.schemaHideReadOnly.includes(this.method) || this.schemaHideReadOnly === 'true')),
563
- !(this.schemaHideWriteOnly && (this.schemaHideWriteOnly.includes(this.method) || this.schemaHideWriteOnly === 'true')),
630
+ this.callback === 'true' || this.webhook === 'true' ? true : false, // eslint-disable-line no-unneeded-ternary
631
+ this.callback === 'true' || this.webhook === 'true' ? false : true, // eslint-disable-line no-unneeded-ternary
564
632
  'text',
565
633
  false,
566
634
  );
@@ -618,8 +686,8 @@ export default class ApiRequest extends LitElement {
618
686
  reqBody.mimeType,
619
687
  reqBody.examples,
620
688
  reqBody.example,
621
- !(this.schemaHideReadOnly && (this.schemaHideReadOnly.includes(this.method) || this.schemaHideReadOnly === 'true')),
622
- !(this.schemaHideWriteOnly && (this.schemaHideWriteOnly.includes(this.method) || this.schemaHideWriteOnly === 'true')),
689
+ this.callback === 'true' || this.webhook === 'true' ? true : false, // eslint-disable-line no-unneeded-ternary
690
+ this.callback === 'true' || this.webhook === 'true' ? false : true, // eslint-disable-line no-unneeded-ternary
623
691
  'text',
624
692
  false,
625
693
  );
@@ -691,10 +759,8 @@ export default class ApiRequest extends LitElement {
691
759
  <button class="tab-btn ${this.activeSchemaTab === 'example' ? 'active' : ''}" data-tab = 'example'>EXAMPLE</button>
692
760
  <button class="tab-btn ${this.activeSchemaTab !== 'example' ? 'active' : ''}" data-tab = 'schema'>SCHEMA</button>
693
761
  </div>
694
- ${this.activeSchemaTab === 'example'
695
- ? html`<div class="tab-content col"> ${reqBodyExampleHtml}</div>`
696
- : html`<div class="tab-content col"> ${reqBodySchemaHtml}</div>`
697
- }
762
+ ${html`<div class="tab-content col" style="display:${this.activeSchemaTab === 'example' ? 'block' : 'none'};"> ${reqBodyExampleHtml}</div>`}
763
+ ${html`<div class="tab-content col" style="display:${this.activeSchemaTab === 'example' ? 'none' : 'block'};"> ${reqBodySchemaHtml}</div>`}
698
764
  </div>`
699
765
  : html`
700
766
  ${reqBodyFileInputHtml}
@@ -712,8 +778,8 @@ export default class ApiRequest extends LitElement {
712
778
  'json',
713
779
  fieldSchema.examples,
714
780
  fieldSchema.example,
715
- !(this.schemaHideReadOnly && (this.schemaHideReadOnly.includes(this.method) || this.schemaHideReadOnly === 'true')),
716
- !(this.schemaHideWriteOnly && (this.schemaHideWriteOnly.includes(this.method) || this.schemaHideWriteOnly === 'true')),
781
+ this.callback === 'true' || this.webhook === 'true' ? true : false, // eslint-disable-line no-unneeded-ternary
782
+ this.callback === 'true' || this.webhook === 'true' ? false : true, // eslint-disable-line no-unneeded-ternary
717
783
  'text',
718
784
  false,
719
785
  );
@@ -755,8 +821,6 @@ export default class ApiRequest extends LitElement {
755
821
  .textContent = "${this.fillRequestFieldsWithExample === 'true' ? formdataPartExample[0].exampleValue : ''}"
756
822
  spellcheck = "false"
757
823
  ></textarea>
758
- <!-- This textarea(hidden) is to store the original example value, in focused mode on navbar change it is used to update the example text -->
759
- <textarea data-pname = "hidden-${fieldName}" data-ptype = "${mimeType.includes('form-urlencode') ? 'hidden-form-urlencode' : 'hidden-form-data'}" class="is-hidden" style="display:none">${formdataPartExample[0].exampleValue}</textarea>
760
824
  </div>`
761
825
  }
762
826
  ${html`
@@ -922,7 +986,24 @@ export default class ApiRequest extends LitElement {
922
986
  }
923
987
 
924
988
  apiResponseTabTemplate() {
925
- const responseFormat = this.responseHeaders.includes('json') ? 'json' : (this.responseHeaders.includes('html') || this.responseHeaders.includes('xml')) ? 'html' : '';
989
+ let responseFormat = '';
990
+ let responseContent = '';
991
+ if (!this.responseIsBlob) {
992
+ if (this.responseHeaders.includes('application/x-ndjson')) {
993
+ responseFormat = 'json';
994
+ const prismLines = this.responseText.split('\n').map((q) => Prism.highlight(q, Prism.languages[responseFormat], responseFormat)).join('\n');
995
+ responseContent = html`<code>${unsafeHTML(prismLines)}</code>`;
996
+ } else if (this.responseHeaders.includes('json')) {
997
+ responseFormat = 'json';
998
+ responseContent = html`<code>${unsafeHTML(Prism.highlight(this.responseText, Prism.languages[responseFormat], responseFormat))}</code>`;
999
+ } else if (this.responseHeaders.includes('html') || this.responseHeaders.includes('xml')) {
1000
+ responseFormat = 'html';
1001
+ responseContent = html`<code>${unsafeHTML(Prism.highlight(this.responseText, Prism.languages[responseFormat], responseFormat))}</code>`;
1002
+ } else {
1003
+ responseFormat = 'text';
1004
+ responseContent = html`<code>${this.responseText}</code>`;
1005
+ }
1006
+ }
926
1007
  return html`
927
1008
  <div class="row" style="font-size:var(--font-size-small); margin:5px 0">
928
1009
  <div class="response-message ${this.responseStatus}">Response Status: ${this.responseMessage}</div>
@@ -952,10 +1033,7 @@ export default class ApiRequest extends LitElement {
952
1033
  : html`
953
1034
  <div class="tab-content col m-markdown" style="flex:1; display:${this.activeResponseTab === 'response' ? 'flex' : 'none'};" >
954
1035
  <button class="toolbar-btn" style="position:absolute; top:12px; right:8px" @click='${(e) => { copyToClipboard(this.responseText, e); }}' part="btn btn-fill"> Copy </button>
955
- <pre style="white-space:pre; min-height:50px; height:400px; resize:vertical; overflow:auto">${responseFormat
956
- ? html`<code>${unsafeHTML(Prism.highlight(this.responseText, Prism.languages[responseFormat], responseFormat))}</code>`
957
- : `${this.responseText}`
958
- }</pre>
1036
+ <pre style="white-space:pre; min-height:50px; height:var(--resp-area-height, 400px); resize:vertical; overflow:auto">${responseContent}</pre>
959
1037
  </div>`
960
1038
  }
961
1039
  <div class="tab-content col m-markdown" style="flex:1; display:${this.activeResponseTab === 'headers' ? 'flex' : 'none'};" >
@@ -1355,6 +1433,9 @@ export default class ApiRequest extends LitElement {
1355
1433
  let respJson;
1356
1434
  let respText;
1357
1435
  tryBtnEl.disabled = true;
1436
+ this.responseText = '⌛';
1437
+ this.responseMessage = '';
1438
+ this.requestUpdate();
1358
1439
  const startTime = performance.now();
1359
1440
  fetchResponse = await fetch(fetchRequest, { signal });
1360
1441
  const endTime = performance.now();
@@ -1372,7 +1453,9 @@ export default class ApiRequest extends LitElement {
1372
1453
  if (respEmpty) {
1373
1454
  this.responseText = '';
1374
1455
  } else if (contentType) {
1375
- if (contentType.includes('json')) {
1456
+ if (contentType === 'application/x-ndjson') {
1457
+ this.responseText = await fetchResponse.text();
1458
+ } else if (contentType.includes('json')) {
1376
1459
  if ((/charset=[^"']+/).test(contentType)) {
1377
1460
  const encoding = contentType.split('charset=')[1];
1378
1461
  const buffer = await fetchResponse.arrayBuffer();
@@ -1401,9 +1484,10 @@ export default class ApiRequest extends LitElement {
1401
1484
  } else {
1402
1485
  respText = await fetchResponse.text();
1403
1486
  if (contentType.includes('xml')) {
1404
- this.responseText = prettyXml(respText);
1487
+ this.responseText = formatXml(respText, { textNodesOnSameLine: true, indentor: ' ' });
1488
+ } else {
1489
+ this.responseText = respText;
1405
1490
  }
1406
- this.responseText = respText;
1407
1491
  }
1408
1492
  if (this.responseIsBlob) {
1409
1493
  const contentDisposition = fetchResponse.headers.get('content-disposition');
@@ -24,6 +24,7 @@ export default class ApiResponse extends LitElement {
24
24
  static get properties() {
25
25
  return {
26
26
  callback: { type: String },
27
+ webhook: { type: String },
27
28
  responses: { type: Object },
28
29
  parser: { type: Object },
29
30
  schemaStyle: { type: String, attribute: 'schema-style' },
@@ -119,8 +120,8 @@ export default class ApiResponse extends LitElement {
119
120
  mimeResp,
120
121
  mimeRespObj.examples,
121
122
  mimeRespObj.example,
122
- !(this.schemaHideReadOnly && (this.schemaHideReadOnly.includes(this.method) || this.schemaHideReadOnly === 'true')),
123
- !(this.schemaHideWriteOnly && (this.schemaHideWriteOnly.includes(this.method) || this.schemaHideWriteOnly === 'true')),
123
+ this.callback === 'true' || this.webhook === 'true' ? false : true, // eslint-disable-line no-unneeded-ternary
124
+ this.callback === 'true' || this.webhook === 'true' ? true : false, // eslint-disable-line no-unneeded-ternary
124
125
  mimeResp.includes('json') ? 'json' : 'text',
125
126
  );
126
127
  allMimeResp[mimeResp] = {
@@ -312,6 +313,7 @@ export default class ApiResponse extends LitElement {
312
313
  allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}",
313
314
  schema-hide-read-only = "${this.schemaHideReadOnly}"
314
315
  schema-hide-write-only = "${this.schemaHideWriteOnly}"
316
+ exportparts = "schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
315
317
  > </schema-tree> `
316
318
  : html`
317
319
  <schema-tree
@@ -322,6 +324,7 @@ export default class ApiResponse extends LitElement {
322
324
  allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}",
323
325
  schema-hide-read-only = "${this.schemaHideReadOnly}"
324
326
  schema-hide-write-only = "${this.schemaHideWriteOnly}"
327
+ exportparts = "schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
325
328
  > </schema-tree>`
326
329
  }`;
327
330
  }
@@ -183,14 +183,14 @@ export default class SchemaTable extends LitElement {
183
183
  if (dataType === 'array') {
184
184
  detailObjType = 'array of object'; // Array of Object
185
185
  } else {
186
- detailObjType = 'object';
186
+ detailObjType = data['::dataTypeLabel'] || data['::type'];
187
187
  }
188
188
  } else if (data['::type'] === 'array') {
189
189
  if (dataType === 'array') {
190
190
  // detailObjType = 'array of array'; // Array of array
191
191
  detailObjType = `array of array ${arrayType !== 'object' ? `of ${arrayType}` : ''}`; // Array of array
192
192
  } else {
193
- detailObjType = 'array';
193
+ detailObjType = data['::dataTypeLabel'] || data['::type'];
194
194
  }
195
195
  }
196
196
 
@@ -244,7 +244,7 @@ export default class SchemaTable extends LitElement {
244
244
  ? html`${this.generateTree(data[0], 'xxx-of-option', '', '::ARRAY~OF', '', newSchemaLevel, newIndentLevel, '')}`
245
245
  : html`
246
246
  ${Object.keys(data).map((dataKey) => html`
247
- ${['::title', '::description', '::type', '::props', '::deprecated', '::array-type', '::readwrite'].includes(dataKey)
247
+ ${['::title', '::description', '::type', '::props', '::deprecated', '::array-type', '::readwrite', '::dataTypeLabel'].includes(dataKey)
248
248
  ? data[dataKey]['::type'] === 'array' || data[dataKey]['::type'] === 'object'
249
249
  ? html`${this.generateTree(
250
250
  data[dataKey]['::type'] === 'array' ? data[dataKey]['::props'] : data[dataKey],
@@ -246,7 +246,7 @@ export default class SchemaTree extends LitElement {
246
246
  ? html`${this.generateTree(data[0], 'xxx-of-option', '', '::ARRAY~OF', '', newSchemaLevel, newIndentLevel, data[0]['::readwrite'])}`
247
247
  : html`
248
248
  ${Object.keys(data).map((dataKey) => html`
249
- ${['::title', '::description', '::type', '::props', '::deprecated', '::array-type', '::readwrite'].includes(dataKey)
249
+ ${['::title', '::description', '::type', '::props', '::deprecated', '::array-type', '::readwrite', '::dataTypeLabel'].includes(dataKey)
250
250
  ? data[dataKey]['::type'] === 'array' || data[dataKey]['::type'] === 'object'
251
251
  ? html`${this.generateTree(
252
252
  data[dataKey]['::type'] === 'array' ? data[dataKey]['::props'] : data[dataKey],
@@ -229,7 +229,6 @@ export default class JsonSchemaViewer extends LitElement {
229
229
  if (!this.allowSearch || !'true, false,'.includes(`${this.allowSearch},`)) { this.allowSearch = 'true'; }
230
230
  if (!this.schemaExpandLevel || this.schemaExpandLevel < 1) { this.schemaExpandLevel = 99999; }
231
231
  if (!this.schemaDescriptionExpanded || !'true, false,'.includes(`${this.schemaDescriptionExpanded},`)) { this.schemaDescriptionExpanded = 'false'; }
232
- if (!this.responseAreaHeight) { this.responseAreaHeight = '300px'; }
233
232
  if (!this.fontSize || !'default, large, largest,'.includes(`${this.fontSize},`)) { this.fontSize = 'default'; }
234
233
  if (!this.matchType || !'includes regex'.includes(this.matchType)) { this.matchType = 'includes'; }
235
234
  if (!this.allowSchemaDescriptionExpandToggle || !'true, false,'.includes(`${this.allowSchemaDescriptionExpandToggle},`)) { this.allowSchemaDescriptionExpandToggle = 'true'; }
@@ -51,7 +51,6 @@ export default class RapiDocMini extends LitElement {
51
51
  responseAreaHeight: { type: String, attribute: 'response-area-height' },
52
52
  showSummaryWhenCollapsed: { type: String, attribute: 'show-summary-when-collapsed' },
53
53
  fillRequestFieldsWithExample: { type: String, attribute: 'fill-request-fields-with-example' },
54
- useSummaryToListExamples: { type: String, attribute: 'use-summary-to-list-example' },
55
54
  persistAuth: { type: String, attribute: 'persist-auth' },
56
55
 
57
56
  // Schema Styles
@@ -170,7 +169,6 @@ export default class RapiDocMini extends LitElement {
170
169
  if (!this.schemaExpandLevel || this.schemaExpandLevel < 1) { this.schemaExpandLevel = 99999; }
171
170
  if (!this.schemaDescriptionExpanded || !'true, false,'.includes(`${this.schemaDescriptionExpanded},`)) { this.schemaDescriptionExpanded = 'false'; }
172
171
  if (!this.fillRequestFieldsWithExample || !'true, false,'.includes(`${this.fillRequestFieldsWithExample},`)) { this.fillRequestFieldsWithExample = 'true'; }
173
- if (!this.useSummaryToListExamples || !'true, false,'.includes(`${this.useSummaryToListExamples},`)) { this.useSummaryToListExamples = 'false'; }
174
172
  if (!this.persistAuth || !'true, false,'.includes(`${this.persistAuth},`)) { this.persistAuth = 'false'; }
175
173
  if (!this.responseAreaHeight) { this.responseAreaHeight = '300px'; }
176
174
 
package/src/rapidoc.js CHANGED
@@ -63,7 +63,6 @@ export default class RapiDoc extends LitElement {
63
63
  defaultSchemaTab: { type: String, attribute: 'default-schema-tab' },
64
64
  responseAreaHeight: { type: String, attribute: 'response-area-height' },
65
65
  fillRequestFieldsWithExample: { type: String, attribute: 'fill-request-fields-with-example' },
66
- useSummaryToListExamples: { type: String, attribute: 'use-summary-to-list-example' },
67
66
  persistAuth: { type: String, attribute: 'persist-auth' },
68
67
  onNavTagClick: { type: String, attribute: 'on-nav-tag-click' },
69
68
 
@@ -451,23 +450,15 @@ export default class RapiDoc extends LitElement {
451
450
  }
452
451
  if (!this.schemaExpandLevel || this.schemaExpandLevel < 1) { this.schemaExpandLevel = 99999; }
453
452
  if (!this.schemaDescriptionExpanded || !'true, false,'.includes(`${this.schemaDescriptionExpanded},`)) { this.schemaDescriptionExpanded = 'false'; }
454
- const writeMethodsWithBody = ['post', 'put', 'patch'];
455
- if (!this.schemaHideReadOnly) {
456
- this.schemaHideReadOnly = writeMethodsWithBody;
457
- } else if (this.schemaHideReadOnly !== 'never') {
458
- this.schemaHideReadOnly = writeMethodsWithBody.filter((value) => this.schemaHideReadOnly.includes(value));
459
- if (this.schemaHideReadOnly.length === 0) {
460
- this.schemaHideReadOnly = writeMethodsWithBody;
461
- }
462
- }
463
- this.schemaHideReadOnly += ['get', 'head', 'delete', 'options'];
464
- this.schemaHideWriteOnly = this.schemaHideWriteOnly !== 'never';
453
+
454
+ if (!this.schemaHideReadOnly || !'default, never,'.includes(`${this.schemaHideReadOnly},`)) { this.schemaHideReadOnly = 'default'; }
455
+ if (!this.schemaHideWriteOnly || !'default, never,'.includes(`${this.schemaHideWriteOnly},`)) { this.schemaHideWriteOnly = 'default'; }
456
+
465
457
  if (!this.fillRequestFieldsWithExample || !'true, false,'.includes(`${this.fillRequestFieldsWithExample},`)) { this.fillRequestFieldsWithExample = 'true'; }
466
- if (!this.useSummaryToListExamples || !'true, false,'.includes(`${this.useSummaryToListExamples},`)) { this.useSummaryToListExamples = 'false'; }
467
458
  if (!this.persistAuth || !'true, false,'.includes(`${this.persistAuth},`)) { this.persistAuth = 'false'; }
468
459
  if (!this.onNavTagClick || !'expand-collapse, show-description,'.includes(`${this.onNavTagClick},`)) { this.onNavTagClick = 'expand-collapse'; }
469
460
  if (!this.responseAreaHeight) {
470
- this.responseAreaHeight = '300px';
461
+ this.responseAreaHeight = '400px';
471
462
  }
472
463
 
473
464
  if (!this.allowSearch || !'true, false,'.includes(`${this.allowSearch},`)) { this.allowSearch = 'true'; }
@@ -774,8 +765,11 @@ export default class RapiDoc extends LitElement {
774
765
  this.scrollTo(elementId);
775
766
  }
776
767
  } else if (this.renderStyle === 'focused') {
777
- const defaultElementId = this.showInfo ? 'overview' : this.resolvedSpec.tags[0]?.paths[0];
778
- this.scrollTo(defaultElementId);
768
+ // If goto-path is provided and no location-hash is present then try to scroll to default element
769
+ if (!this.gotoPath) {
770
+ const defaultElementId = this.showInfo ? 'overview' : this.resolvedSpec.tags[0]?.paths[0];
771
+ this.scrollTo(defaultElementId);
772
+ }
779
773
  }
780
774
  }
781
775
 
@@ -893,6 +887,12 @@ export default class RapiDoc extends LitElement {
893
887
  return;
894
888
  }
895
889
  this.isIntersectionObserverActive = false;
890
+ if (this.renderStyle === 'focused') {
891
+ const requestEl = this.shadowRoot.querySelector('api-request');
892
+ if (requestEl) {
893
+ requestEl.beforerNavigationFocusedMode();
894
+ }
895
+ }
896
896
  this.scrollTo(navEl.dataset.contentId, true, scrollNavItemToView);
897
897
  setTimeout(() => {
898
898
  this.isIntersectionObserverActive = true;
@@ -905,7 +905,6 @@ export default class RapiDoc extends LitElement {
905
905
  // for focused mode update this.focusedElementId to update the rendering, else it wont find the needed html elements
906
906
  // focusedElementId will get validated in the template
907
907
  this.focusedElementId = elementId;
908
- await sleep(0);
909
908
  }
910
909
  if (this.renderStyle === 'view') {
911
910
  this.expandAndGotoOperation(elementId, expandPath, true);
@@ -923,7 +922,7 @@ export default class RapiDoc extends LitElement {
923
922
  if (this.renderStyle === 'focused') {
924
923
  const requestEl = this.shadowRoot.querySelector('api-request');
925
924
  if (requestEl) {
926
- requestEl.resetRequestBodySelection();
925
+ requestEl.afterNavigationFocusedMode();
927
926
  }
928
927
  const responseEl = this.shadowRoot.querySelector('api-response');
929
928
  if (responseEl) {
@@ -40,7 +40,7 @@ export default css`
40
40
  .blue-text {color: var(--blue)}
41
41
  .multiline {
42
42
  overflow: scroll;
43
- max-height: var(--resp-area-height, 300px);
43
+ max-height: var(--resp-area-height, 400px);
44
44
  color: var(--fg3);
45
45
  }
46
46
  .method-fg.put { color: var(--orange); }
@@ -9,7 +9,7 @@ export default function callbackTemplate(callbacks) {
9
9
  ${kv[0]}
10
10
  ${Object.entries(kv[1]).map((pathObj) => html`
11
11
  <div class="mono-font small-font-size" style="display:flex; margin-left:16px;">
12
- <div>
12
+ <div style="width:100%">
13
13
  ${Object.entries(pathObj[1]).map((method) => html`
14
14
  <div>
15
15
  <div style="margin-top:12px;">
@@ -29,7 +29,6 @@ export default function callbackTemplate(callbacks) {
29
29
  .parameters = "${method[1]?.parameters || ''}"
30
30
  .request_body = "${method[1]?.requestBody || ''}"
31
31
  fill-request-fields-with-example = "${this.fillRequestFieldsWithExample}"
32
- use-summary-to-list-example = "${this.useSummaryToListExamples}"
33
32
  allow-try = "false"
34
33
  render-style="${this.renderStyle}"
35
34
  schema-style = "${this.schemaStyle}"
@@ -38,7 +37,7 @@ export default function callbackTemplate(callbacks) {
38
37
  schema-description-expanded = "${this.schemaDescriptionExpanded}"
39
38
  allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}",
40
39
  schema-hide-read-only = "false"
41
- schema-hide-write-only = "${this.schemaHideWriteOnly}"
40
+ schema-hide-write-only = "${this.schemaHideWriteOnly === 'never' ? 'false' : 'true'}"
42
41
  fetch-credentials = "${this.fetchCredentials}"
43
42
  exportparts = "btn:btn, btn-fill:btn-fill, btn-outline:btn-outline, btn-try:btn-try, btn-clear:btn-clear, btn-clear-resp:btn-clear-resp,
44
43
  file-input:file-input, textbox:textbox, textbox-param:textbox-param, textarea:textarea, textarea-param:textarea-param,
@@ -56,7 +55,7 @@ export default function callbackTemplate(callbacks) {
56
55
  schema-expand-level = "${this.schemaExpandLevel}"
57
56
  schema-description-expanded = "${this.schemaDescriptionExpanded}"
58
57
  allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}"
59
- schema-hide-read-only = "${this.schemaHideReadOnly}"
58
+ schema-hide-read-only = "${this.schemaHideReadOnly === 'never' ? 'false' : 'true'}"
60
59
  schema-hide-write-only = "false"
61
60
  exportparts = "btn:btn, btn-response-status:btn-response-status, btn-selected-response-status:btn-selected-response-status, btn-fill:btn-fill, btn-copy:btn-copy,
62
61
  schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"