openapi-explorer 2.2.773 → 2.2.775

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.
@@ -495,24 +495,6 @@ export default class OpenApiExplorer extends LitElement {
495
495
  }
496
496
  }, isExpandingNeeded ? 150 : 0);
497
497
  }
498
- isValidTopId(id) {
499
- return id.startsWith('overview') || id === 'servers' || id === 'auth';
500
- }
501
- isValidPathId(id) {
502
- if (id === 'overview' && !this.hideInfo) {
503
- return true;
504
- }
505
- if (id === 'servers' && !this.hideServerSelection) {
506
- return true;
507
- }
508
- if (id === 'auth' && !this.hideAuthentication) {
509
- return true;
510
- }
511
- if (id.startsWith('tag--')) {
512
- return this.resolvedSpec.tags && this.resolvedSpec.tags.find(tag => tag.elementId === id);
513
- }
514
- return this.resolvedSpec.tags && this.resolvedSpec.tags.find(tag => tag.paths.find(path => path.elementId === id));
515
- }
516
498
  onIntersect(entries) {
517
499
  if (this.isIntersectionObserverActive === false) {
518
500
  return;
@@ -639,7 +621,12 @@ export default class OpenApiExplorer extends LitElement {
639
621
  await sleep(0);
640
622
 
641
623
  // In the case of section scrolling, these are hard swaps, so just load "section". In the case of `tags` the headers have the element html Id in the last `--id`, so split that off and check for it
642
- const contentEl = this.shadowRoot.getElementById(elementId !== null && elementId !== void 0 && elementId.startsWith('section') ? 'section' : elementId) || this.shadowRoot.getElementById(elementId.split('--').slice(-1)[0]);
624
+ // NOTE: Really this whole nonsense is because Marked, inserts -- between the prefix and the type and we cannot control it at all. When upgrading to Node 20, marked 16+, we will have to change this and we might even be able to make it work correctly. The biggest problem is that both the separator `--` and invalid character replacement `-`, can stack up.
625
+ const contentEl = this.shadowRoot.getElementById(elementId !== null && elementId !== void 0 && elementId.startsWith('section') ? 'section' : elementId)
626
+ // Remove the prefix of the section as headers in sub sections are not prefixed with the type.
627
+ || elementId.split('--').length > 1 && this.shadowRoot.getElementById(elementId.split('--').slice(1).join('--'))
628
+ // Remove the prefix of the operation (tag--) and the tag name (tag--NAME--) from header, as headers in sub sections are not prefixed with the type.
629
+ || elementId.split('--').length > 2 && this.shadowRoot.getElementById(elementId.split('--').slice(2).join('--')) || this.shadowRoot.getElementById(elementId.split('--').slice(-1)[0]);
643
630
  if (!contentEl) {
644
631
  return;
645
632
  }
@@ -685,8 +672,8 @@ export default class OpenApiExplorer extends LitElement {
685
672
  // Update Location Hash
686
673
  replaceState(elementId);
687
674
  newNavEl = this.shadowRoot.getElementById(`link-${elementId}`);
688
- } else if (!elementId.match('cmp--') && !elementId.match('tag--') && !elementId.match(/--h[12]$/)) {
689
- this.shadowRoot.getElementById('operations-root').scrollIntoView({
675
+ } else if (elementId.match('cmp--') || elementId.match('tag--') || elementId.match('overview--') || elementId.match('auth--') || elementId.match('servers--')) {
676
+ contentEl.scrollIntoView({
690
677
  behavior: 'auto',
691
678
  block: 'start'
692
679
  });
@@ -695,7 +682,7 @@ export default class OpenApiExplorer extends LitElement {
695
682
  replaceState(elementId);
696
683
  newNavEl = this.shadowRoot.getElementById(`link-${elementId}`);
697
684
  } else {
698
- contentEl.scrollIntoView({
685
+ this.shadowRoot.getElementById('operations-root').scrollIntoView({
699
686
  behavior: 'auto',
700
687
  block: 'start'
701
688
  });
@@ -12,7 +12,7 @@ export function debounce(fn, delay) {
12
12
  }, delay);
13
13
  };
14
14
  }
15
- export const invalidCharsRegEx = new RegExp(/[\s#:?&={}]/, 'g'); // used for generating valid html element ids by replacing the invalid chars with hyphen (-)
15
+ export const invalidCharsRegEx = new RegExp(/[\s#:?&={}-]+/, 'g'); // used for generating valid html element ids by replacing the invalid chars with hyphen (-)
16
16
 
17
17
  export function sleep(ms) {
18
18
  return new Promise(resolve => setTimeout(resolve, ms));
@@ -501,24 +501,6 @@ class OpenApiExplorer extends _lit.LitElement {
501
501
  }
502
502
  }, isExpandingNeeded ? 150 : 0);
503
503
  }
504
- isValidTopId(id) {
505
- return id.startsWith('overview') || id === 'servers' || id === 'auth';
506
- }
507
- isValidPathId(id) {
508
- if (id === 'overview' && !this.hideInfo) {
509
- return true;
510
- }
511
- if (id === 'servers' && !this.hideServerSelection) {
512
- return true;
513
- }
514
- if (id === 'auth' && !this.hideAuthentication) {
515
- return true;
516
- }
517
- if (id.startsWith('tag--')) {
518
- return this.resolvedSpec.tags && this.resolvedSpec.tags.find(tag => tag.elementId === id);
519
- }
520
- return this.resolvedSpec.tags && this.resolvedSpec.tags.find(tag => tag.paths.find(path => path.elementId === id));
521
- }
522
504
  onIntersect(entries) {
523
505
  if (this.isIntersectionObserverActive === false) {
524
506
  return;
@@ -645,7 +627,12 @@ class OpenApiExplorer extends _lit.LitElement {
645
627
  await (0, _commonUtils.sleep)(0);
646
628
 
647
629
  // In the case of section scrolling, these are hard swaps, so just load "section". In the case of `tags` the headers have the element html Id in the last `--id`, so split that off and check for it
648
- const contentEl = this.shadowRoot.getElementById(elementId !== null && elementId !== void 0 && elementId.startsWith('section') ? 'section' : elementId) || this.shadowRoot.getElementById(elementId.split('--').slice(-1)[0]);
630
+ // NOTE: Really this whole nonsense is because Marked, inserts -- between the prefix and the type and we cannot control it at all. When upgrading to Node 20, marked 16+, we will have to change this and we might even be able to make it work correctly. The biggest problem is that both the separator `--` and invalid character replacement `-`, can stack up.
631
+ const contentEl = this.shadowRoot.getElementById(elementId !== null && elementId !== void 0 && elementId.startsWith('section') ? 'section' : elementId)
632
+ // Remove the prefix of the section as headers in sub sections are not prefixed with the type.
633
+ || elementId.split('--').length > 1 && this.shadowRoot.getElementById(elementId.split('--').slice(1).join('--'))
634
+ // Remove the prefix of the operation (tag--) and the tag name (tag--NAME--) from header, as headers in sub sections are not prefixed with the type.
635
+ || elementId.split('--').length > 2 && this.shadowRoot.getElementById(elementId.split('--').slice(2).join('--')) || this.shadowRoot.getElementById(elementId.split('--').slice(-1)[0]);
649
636
  if (!contentEl) {
650
637
  return;
651
638
  }
@@ -691,8 +678,8 @@ class OpenApiExplorer extends _lit.LitElement {
691
678
  // Update Location Hash
692
679
  (0, _commonUtils.replaceState)(elementId);
693
680
  newNavEl = this.shadowRoot.getElementById(`link-${elementId}`);
694
- } else if (!elementId.match('cmp--') && !elementId.match('tag--') && !elementId.match(/--h[12]$/)) {
695
- this.shadowRoot.getElementById('operations-root').scrollIntoView({
681
+ } else if (elementId.match('cmp--') || elementId.match('tag--') || elementId.match('overview--') || elementId.match('auth--') || elementId.match('servers--')) {
682
+ contentEl.scrollIntoView({
696
683
  behavior: 'auto',
697
684
  block: 'start'
698
685
  });
@@ -701,7 +688,7 @@ class OpenApiExplorer extends _lit.LitElement {
701
688
  (0, _commonUtils.replaceState)(elementId);
702
689
  newNavEl = this.shadowRoot.getElementById(`link-${elementId}`);
703
690
  } else {
704
- contentEl.scrollIntoView({
691
+ this.shadowRoot.getElementById('operations-root').scrollIntoView({
705
692
  behavior: 'auto',
706
693
  block: 'start'
707
694
  });
@@ -27,7 +27,7 @@ function debounce(fn, delay) {
27
27
  }, delay);
28
28
  };
29
29
  }
30
- const invalidCharsRegEx = exports.invalidCharsRegEx = new RegExp(/[\s#:?&={}]/, 'g'); // used for generating valid html element ids by replacing the invalid chars with hyphen (-)
30
+ const invalidCharsRegEx = exports.invalidCharsRegEx = new RegExp(/[\s#:?&={}-]+/, 'g'); // used for generating valid html element ids by replacing the invalid chars with hyphen (-)
31
31
 
32
32
  function sleep(ms) {
33
33
  return new Promise(resolve => setTimeout(resolve, ms));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openapi-explorer",
3
- "version": "2.2.773",
3
+ "version": "2.2.775",
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",