openapi-explorer 0.7.257 → 0.8.264

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openapi-explorer",
3
- "version": "0.7.257",
3
+ "version": "0.8.264",
4
4
  "description": "OpenAPI Explorer - API viewer with dynamically generated components, documentation, and interaction console",
5
5
  "author": "Rhosys Developers <developers@rhosys.ch>",
6
6
  "repository": {
@@ -757,9 +757,6 @@ export default class ApiRequest extends LitElement {
757
757
  ${
758
758
  this.parameters.length > 0 || this.request_body
759
759
  ? html`
760
- <button class="m-btn thin-border" part="btn btn-outline" style="margin-right:5px;" @click="${this.onFillRequestData}" title="Fills with example data (if provided)">
761
- RESET
762
- </button>
763
760
  <button class="m-btn thin-border" part="btn btn-outline" style="margin-right:5px;" @click="${this.onClearRequestData}">
764
761
  CLEAR
765
762
  </button>`
@@ -772,20 +769,6 @@ export default class ApiRequest extends LitElement {
772
769
  }
773
770
  /* eslint-enable indent */
774
771
 
775
- onFillRequestData(e) {
776
- const requestPanelEl = e.target.closest('.request-panel');
777
- const requestPanelInputEls = [...requestPanelEl.querySelectorAll('input, tag-input, textarea:not(.is-hidden)')];
778
- requestPanelInputEls.forEach((el) => {
779
- if (el.dataset.default) {
780
- if (el.tagName.toUpperCase() === 'TAG-INPUT') {
781
- el.value = el.dataset.default.split('~|~');
782
- } else {
783
- el.value = el.dataset.default;
784
- }
785
- }
786
- });
787
- }
788
-
789
772
  onClearRequestData(e) {
790
773
  const requestPanelEl = e.target.closest('.request-panel');
791
774
  const requestPanelInputEls = [...requestPanelEl.querySelectorAll('input, tag-input, textarea:not(.is-hidden)')];
@@ -821,8 +804,8 @@ export default class ApiRequest extends LitElement {
821
804
  });
822
805
 
823
806
  // Query Params
807
+ const urlQueryParam = new URLSearchParams();
824
808
  if (queryParamEls.length > 0) {
825
- const urlQueryParam = new URLSearchParams();
826
809
  queryParamEls.forEach((el) => {
827
810
  if (el.dataset.array === 'false') {
828
811
  if (el.value !== '') {
@@ -848,12 +831,10 @@ export default class ApiRequest extends LitElement {
848
831
  }
849
832
  }
850
833
  });
851
- fetchUrl = `${fetchUrl}${urlQueryParam.toString() ? '?' : ''}${urlQueryParam.toString()}`;
852
834
  }
853
835
 
854
836
  // Query Params (Dynamic - create from JSON)
855
837
  if (queryParamObjTypeEls.length > 0) {
856
- const urlDynQueryParam = new URLSearchParams();
857
838
  queryParamObjTypeEls.map((el) => {
858
839
  try {
859
840
  let queryParamObj = {};
@@ -864,24 +845,23 @@ export default class ApiRequest extends LitElement {
864
845
  if (typeof queryParamObj[key] === 'object') {
865
846
  if (Array.isArray(queryParamObj[key])) {
866
847
  if (paramSerializeStyle === 'spaceDelimited') {
867
- urlDynQueryParam.append(key, queryParamObj[key].join(' '));
848
+ urlQueryParam.append(key, queryParamObj[key].join(' '));
868
849
  } else if (paramSerializeStyle === 'pipeDelimited') {
869
- urlDynQueryParam.append(key, queryParamObj[key].join('|'));
850
+ urlQueryParam.append(key, queryParamObj[key].join('|'));
870
851
  } else {
871
852
  if (paramSerializeExplode === 'true') { // eslint-disable-line no-lonely-if
872
853
  queryParamObj[key].forEach((v) => {
873
- urlDynQueryParam.append(key, v);
854
+ urlQueryParam.append(key, v);
874
855
  });
875
856
  } else {
876
- urlDynQueryParam.append(key, queryParamObj[key]);
857
+ urlQueryParam.append(key, queryParamObj[key]);
877
858
  }
878
859
  }
879
860
  }
880
861
  } else {
881
- urlDynQueryParam.append(key, queryParamObj[key]);
862
+ urlQueryParam.append(key, queryParamObj[key]);
882
863
  }
883
864
  }
884
- fetchUrl = `${fetchUrl}${urlDynQueryParam.toString() ? '?' : ''}${urlDynQueryParam.toString()}`;
885
865
  } catch (err) {
886
866
  console.log('OpenAPI Explorer: unable to parse %s into object', el.value); // eslint-disable-line no-console
887
867
  }
@@ -891,7 +871,7 @@ export default class ApiRequest extends LitElement {
891
871
  // Add Authentication api keys if provided
892
872
  this.api_keys.filter((v) => v.finalKeyValue).forEach((v) => {
893
873
  if (v.in === 'query') {
894
- fetchUrl = `${fetchUrl}${fetchUrl.includes('?') ? '&' : '?'}${v.name}=${encodeURIComponent(v.finalKeyValue)}`;
874
+ urlQueryParam.append(v.name, v.finalKeyValue);
895
875
  return;
896
876
  }
897
877
 
@@ -900,6 +880,8 @@ export default class ApiRequest extends LitElement {
900
880
  curlHeaders += ` -H "${v.name}: ${v.finalKeyValue}" \\\n`;
901
881
  });
902
882
 
883
+ fetchUrl = `${fetchUrl}${urlQueryParam.toString() ? '?' : ''}${urlQueryParam.toString()}`;
884
+
903
885
  // Final URL for API call
904
886
  fetchUrl = `${this.serverUrl.replace(/\/$/, '')}${fetchUrl}`;
905
887
  if (fetchUrl.startsWith('http') === false) {
@@ -171,7 +171,16 @@ export default class SchemaTree extends LitElement {
171
171
  closeBracket = ']';
172
172
  }
173
173
  }
174
+
174
175
  if (typeof data === 'object') {
176
+ const flags = data['::flags'] || {};
177
+ if (flags['🆁'] && this.schemaHideReadOnly === 'true') {
178
+ return undefined;
179
+ }
180
+ if (flags['🆆'] && this.schemaHideWriteOnly === 'true') {
181
+ return undefined;
182
+ }
183
+ const displayLine = [flags['🆁'] || flags['🆆'], description].filter(v => v).join(' ');
175
184
  return html`
176
185
  <div class="tr ${schemaLevel < this.schemaExpandLevel || data['::type'] && data['::type'].startsWith('xxx-of') ? 'expanded' : 'collapsed'} ${data['::type'] || 'no-type-info'}">
177
186
  <div class="td key ${data['::deprecated'] ? 'deprecated' : ''}" style='min-width:${minFieldColWidth}px'>
@@ -188,13 +197,17 @@ export default class SchemaTree extends LitElement {
188
197
  ${data['::type'] === 'xxx-of' && dataType === 'array' ? html`<span style="color:var(--primary-color)">ARRAY</span>` : ''}
189
198
  ${openBracket}
190
199
  </div>
191
- <div class='td key-descr m-markdown-small'>${unsafeHTML(marked(description || ''))}</div>
200
+ <div class="td key-descr">
201
+ <span class="m-markdown-small" style="font-family: var(--font-mono); vertical-align: middle;" title="${flags['🆁'] && 'Read only attribute' || flags['🆆'] && 'Write only attribute' || ''}">
202
+ ${unsafeHTML(marked(displayLine))}
203
+ </span>
204
+ </div>
192
205
  </div>
193
206
  <div class='inside-bracket ${data['::type'] || 'no-type-info'}' style='padding-left:${data['::type'] === 'xxx-of-option' || data['::type'] === 'xxx-of-array' ? 0 : leftPadding}px;'>
194
207
  ${Array.isArray(data) && data[0] ? html`${this.generateTree(data[0], 'xxx-of-option', '::ARRAY~OF', '', newSchemaLevel, newIndentLevel)}`
195
208
  : html`
196
209
  ${Object.keys(data).map((dataKey) =>
197
- ['::title', '::description', '::type', '::props', '::deprecated'].includes(dataKey) && data[dataKey]['::type'] !== 'array' && data[dataKey]['::type'] !== 'object' ? ''
210
+ dataKey.startsWith('::') && data[dataKey]['::type'] !== 'array' && data[dataKey]['::type'] !== 'object' ? ''
198
211
  : html`${this.generateTree(data[dataKey]['::type'] === 'array' ? data[dataKey]['::props'] : data[dataKey],
199
212
  data[dataKey]['::type'], dataKey, data[dataKey]['::description'], newSchemaLevel, newIndentLevel)}`
200
213
  )}`
@@ -70,8 +70,6 @@ export default class OpenApiExplorer extends LitElement {
70
70
  schemaStyle: { type: String, attribute: 'schema-style' },
71
71
  schemaExpandLevel: { type: Number, attribute: 'schema-expand-level' },
72
72
  schemaDescriptionExpanded: { type: String, attribute: 'schema-description-expanded' },
73
- schemaHideReadOnly: { type: String, attribute: 'schema-hide-read-only' },
74
- schemaHideWriteOnly: { type: String, attribute: 'schema-hide-write-only' },
75
73
 
76
74
  // API Server
77
75
  serverUrl: { type: String, attribute: 'server-url' },
@@ -116,7 +114,7 @@ export default class OpenApiExplorer extends LitElement {
116
114
  loading: { type: Boolean }, // indicates spec is being loaded
117
115
  operationsCollapsed: { type: Boolean },
118
116
  showAdvancedSearchDialog: { type: Boolean },
119
- advancedSearchMatches: { type: Object },
117
+ advancedSearchMatches: { type: Object }
120
118
  };
121
119
  }
122
120
 
@@ -376,17 +374,8 @@ export default class OpenApiExplorer extends LitElement {
376
374
  if (!this.defaultSchemaTab || !'body, model,'.includes(`${this.defaultSchemaTab},`)) { this.defaultSchemaTab = 'model'; }
377
375
  if (!this.schemaExpandLevel || this.schemaExpandLevel < 1) { this.schemaExpandLevel = 99999; }
378
376
  if (!this.schemaDescriptionExpanded || !'true, false,'.includes(`${this.schemaDescriptionExpanded},`)) { this.schemaDescriptionExpanded = 'true'; }
379
- const writeMethodsWithBody = ['post', 'put', 'patch'];
380
- if (!this.schemaHideReadOnly) {
381
- this.schemaHideReadOnly = writeMethodsWithBody;
382
- } else if (this.schemaHideReadOnly !== 'never') {
383
- this.schemaHideReadOnly = writeMethodsWithBody.filter((value) => this.schemaHideReadOnly.includes(value));
384
- if (this.schemaHideReadOnly.length === 0) {
385
- this.schemaHideReadOnly = writeMethodsWithBody;
386
- }
387
- }
388
- this.schemaHideReadOnly += ['get', 'head', 'delete', 'options'];
389
- this.schemaHideWriteOnly = this.schemaHideWriteOnly !== 'never';
377
+ this.schemaHideReadOnly = ['post', 'put', 'patch'].join(',');
378
+ this.schemaHideWriteOnly = true;
390
379
  if (!this.fillRequestWithDefault || !'true, false,'.includes(`${this.fillRequestWithDefault},`)) { this.fillRequestWithDefault = 'true'; }
391
380
  if (!this.onNavTagClick || !'expand-collapse, show-description,'.includes(`${this.onNavTagClick},`)) { this.onNavTagClick = 'expand-collapse'; }
392
381
  if (!this.responseAreaHeight) {
@@ -502,6 +502,7 @@ export function schemaInObjectNotation(schema, obj, level = 0, suffix = '') {
502
502
  // 1. First iterate the regular properties
503
503
  if (schema.type === 'object' || schema.properties) {
504
504
  obj['::description'] = schema.description || '';
505
+ obj['::flags'] = { '🆁': schema.readOnly && '🆁', '🆆': schema.writeOnly && '🆆' };
505
506
  obj['::type'] = 'object';
506
507
  // obj['::deprecated'] = schema.deprecated || false;
507
508
  for (const key in schema.properties) {
@@ -580,6 +581,7 @@ export function schemaInObjectNotation(schema, obj, level = 0, suffix = '') {
580
581
  const objTypeOption = {
581
582
  '::title': schema.title || '',
582
583
  '::description': schema.description || '',
584
+ '::flags': { '🆁': schema.readOnly && '🆁', '🆆': schema.writeOnly && '🆆' },
583
585
  '::type': 'object',
584
586
  '::deprecated': schema.deprecated || false
585
587
  };
@@ -595,8 +597,9 @@ export function schemaInObjectNotation(schema, obj, level = 0, suffix = '') {
595
597
  multiTypeOptions[`::OPTION~${i + 1}`] = {
596
598
  '::title': schema.title || '',
597
599
  '::description': schema.description || '',
600
+ '::flags': { '🆁': schema.readOnly && '🆁', '🆆': schema.writeOnly && '🆆' },
598
601
  '::type': 'array',
599
- '::props': schemaInObjectNotation(schema.items, {}, (level + 1)),
602
+ '::props': schemaInObjectNotation(Object.assign({ readOnly: schema.readOnly, writeOnly: schema.writeOnly }, schema.items), {}, (level + 1)),
600
603
  };
601
604
  }
602
605
  });
@@ -606,6 +609,7 @@ export function schemaInObjectNotation(schema, obj, level = 0, suffix = '') {
606
609
  } else if (schema.type === 'object' || schema.properties) {
607
610
  obj['::title'] = schema.title || '';
608
611
  obj['::description'] = schema.description || '';
612
+ obj['::flags'] = { '🆁': schema.readOnly && '🆁', '🆆': schema.writeOnly && '🆆' };
609
613
  obj['::type'] = 'object';
610
614
  obj['::deprecated'] = schema.deprecated || false;
611
615
  for (const key in schema.properties) {
@@ -625,8 +629,9 @@ export function schemaInObjectNotation(schema, obj, level = 0, suffix = '') {
625
629
  : (schema.items && schema.items.description)
626
630
  ? `array&lt;${schema.items.description}&gt;`
627
631
  : '';
632
+ obj['::flags'] = { '🆁': schema.readOnly && '🆁', '🆆': schema.writeOnly && '🆆' };
628
633
  obj['::type'] = 'array';
629
- obj['::props'] = schemaInObjectNotation(schema.items, {}, (level + 1));
634
+ obj['::props'] = schemaInObjectNotation(Object.assign({ readOnly: schema.readOnly, writeOnly: schema.writeOnly }, schema.items), {}, (level + 1));
630
635
  } else {
631
636
  const typeObj = getTypeInfo(schema);
632
637
  if (typeObj && typeObj.html) {