openapi-explorer 0.8.295 → 0.8.298

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.8.295",
3
+ "version": "0.8.298",
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": {
@@ -517,6 +517,7 @@ export default class OpenApiExplorer extends LitElement {
517
517
  if (!this.serverUrl) {
518
518
  this.serverUrl = spec.servers[0].computedUrl || spec.servers[0].url;
519
519
  }
520
+ this.selectedServer = spec.servers.find((s) => s.url === this.serverUrl || !this.serverUrl) || spec.servers[0];
520
521
  this.afterSpecParsedAndValidated(spec);
521
522
  } catch (err) {
522
523
  this.loading = false;
@@ -554,30 +555,22 @@ export default class OpenApiExplorer extends LitElement {
554
555
  this.requestUpdate();
555
556
  }
556
557
 
557
- async afterSpecParsedAndValidated(spec) {
558
+ afterSpecParsedAndValidated(spec) {
558
559
  this.resolvedSpec = spec;
559
- this.selectedServer = this.resolvedSpec.servers.find((s) => s.url === this.serverUrl || !this.serverUrl);
560
+
560
561
  this.dispatchEvent(new CustomEvent('spec-loaded', { detail: spec }));
561
562
  this.requestUpdate();
562
563
 
563
564
  // Initiate IntersectionObserver and put it at the end of event loop, to allow loading all the child elements (must for larger specs)
564
565
  this.intersectionObserver.disconnect();
565
- if (this.renderStyle === 'read') {
566
- await sleep(100);
567
- this.observeExpandedContent(); // This will auto-highlight the selected nav-item in read-mode
566
+
567
+ if (this.renderStyle === 'focused') {
568
+ const defaultElementId = this.showInfo ? 'overview' : this.resolvedSpec.tags && this.resolvedSpec.tags[0] && this.resolvedSpec.tags[0].paths[0];
569
+ this.scrollTo(this.explorerLocation || defaultElementId);
568
570
  }
569
571
 
570
- // On first time Spec load, try to navigate to location hash if provided
571
- const locationHash = this.explorerLocation;
572
- if (locationHash) {
573
- if (this.renderStyle === 'view') {
574
- this.expandAndGotoOperation(locationHash);
575
- } else if (this.renderStyle === 'focused') {
576
- this.scrollTo(locationHash);
577
- }
578
- } else if (this.renderStyle === 'focused') {
579
- const defaultElementId = this.showInfo ? 'overview' : this.resolvedSpec.tags[0] && this.resolvedSpec.tags[0].paths[0];
580
- this.scrollTo(defaultElementId);
572
+ if (this.renderStyle === 'view' && this.explorerLocation) {
573
+ this.expandAndGotoOperation(this.explorerLocation);
581
574
  }
582
575
  }
583
576
 
@@ -702,11 +695,9 @@ export default class OpenApiExplorer extends LitElement {
702
695
  return;
703
696
  }
704
697
 
705
- if (this.renderStyle === 'focused') {
706
- // explorerLocation will get validated in the focused-endpoint-template
707
- this.explorerLocation = elementId;
708
- await sleep(0);
709
- }
698
+ // explorerLocation will get validated in the focused-endpoint-template
699
+ this.explorerLocation = elementId;
700
+ await sleep(0);
710
701
 
711
702
  const contentEl = this.shadowRoot.getElementById(elementId);
712
703
  if (!contentEl) {
@@ -714,22 +705,20 @@ export default class OpenApiExplorer extends LitElement {
714
705
  }
715
706
 
716
707
  // For focused APIs, always scroll to the top of the component
717
- if (this.renderStyle === 'focused' && !elementId.match('cmp--')) {
708
+ if (!elementId.match('cmp--')) {
718
709
  this.shadowRoot.getElementById('operations-root').scrollIntoView({ behavior: 'auto', block: 'start' });
719
710
  } else {
720
711
  contentEl.scrollIntoView({ behavior: 'auto', block: 'start' });
721
712
  }
722
713
 
723
714
  // for focused style it is important to reset request-body-selection and response selection which maintains the state for in case of multiple req-body or multiple response mime-type
724
- if (this.renderStyle === 'focused') {
725
- const requestEl = this.shadowRoot.querySelector('api-request');
726
- if (requestEl) {
727
- requestEl.resetRequestBodySelection();
728
- }
729
- const responseEl = this.shadowRoot.querySelector('api-response');
730
- if (responseEl) {
731
- responseEl.resetSelection();
732
- }
715
+ const requestEl = this.shadowRoot.querySelector('api-request');
716
+ if (requestEl) {
717
+ requestEl.resetRequestBodySelection();
718
+ }
719
+ const responseEl = this.shadowRoot.querySelector('api-response');
720
+ if (responseEl) {
721
+ responseEl.resetSelection();
733
722
  }
734
723
 
735
724
  // Update Location Hash
@@ -761,7 +750,7 @@ export default class OpenApiExplorer extends LitElement {
761
750
  node.classList.remove('active');
762
751
  });
763
752
  newNavEl.classList.add('active'); // must add the class after scrolling
764
- // this.requestUpdate();
753
+ this.requestUpdate();
765
754
  }
766
755
 
767
756
  // Event handler for Advanced Search text-inputs and checkboxes
@@ -68,8 +68,7 @@ export default css`
68
68
  color: var(--secondary-color);
69
69
  border-left:4px solid transparent;
70
70
  font-weight:bold;
71
- padding: 15px 15px 15px 10px;
72
- text-transform: capitalize;
71
+ padding: 15px 15px 15px 10px;
73
72
  }
74
73
 
75
74
  .nav-bar-components,
@@ -22,7 +22,6 @@ function onApiServerVarChange(e, serverObj) {
22
22
 
23
23
  /* eslint-disable indent */
24
24
  function serverVarsTemplate() {
25
- // const selectedServerObj = this.resolvedSpec.servers.find((v) => (v.url === this.selectedServer));
26
25
  return this.selectedServer && this.selectedServer.variables
27
26
  ? html`
28
27
  <div class="table-title"> SERVER VARIABLES</div>