api-console 6.6.66 → 6.6.70

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,7 +1,7 @@
1
1
  {
2
2
  "name": "api-console",
3
3
  "description": "The API Console to automatically generate API documentation from RAML and OAS files.",
4
- "version": "6.6.66",
4
+ "version": "6.6.70",
5
5
  "license": "CPAL-1.0",
6
6
  "main": "index.js",
7
7
  "module": "index.js",
@@ -40,7 +40,7 @@
40
40
  "@api-components/amf-helper-mixin": "^4.5.36",
41
41
  "@api-components/api-console-ext-comm": "^3.0.0",
42
42
  "@api-components/api-documentation": "^6.1.8",
43
- "@api-components/api-navigation": "^4.3.20",
43
+ "@api-components/api-navigation": "^4.3.22",
44
44
  "@api-components/api-request": "^0.3.8",
45
45
  "@api-components/api-summary": "^4.6.16",
46
46
  "@polymer/app-layout": "^3.1.0",
@@ -55,7 +55,7 @@
55
55
  "@anypoint-web-components/anypoint-listbox": "^1.0.4",
56
56
  "@anypoint-web-components/anypoint-menu-mixin": "^1.0.2",
57
57
  "@anypoint-web-components/anypoint-styles": "^1.0.1",
58
- "@api-components/api-model-generator": "^0.2.14",
58
+ "@api-components/api-model-generator": "^0.4.0",
59
59
  "@commitlint/cli": "^13.2.1",
60
60
  "@commitlint/config-conventional": "^13.2.0",
61
61
  "@open-wc/building-rollup": "^1.2.6",
@@ -66,7 +66,7 @@
66
66
  "@web/test-runner": "^0.13.15",
67
67
  "@web/test-runner-playwright": "^0.11.0",
68
68
  "@web/test-runner-visual-regression": "^0.6.4",
69
- "amf-client-js": "^5.4.4",
69
+ "amf-client-js": "^5.12.0",
70
70
  "body-parser": "^1.19.0",
71
71
  "deepmerge": "^4.2.1",
72
72
  "eslint": "^8.0.0",
@@ -120,7 +120,7 @@
120
120
  ]
121
121
  },
122
122
  "engines": {
123
- "node": ">=10.0.0"
123
+ "node": ">=18.0.0"
124
124
  },
125
125
  "remarkConfig": {
126
126
  "settings": {
@@ -155,7 +155,8 @@
155
155
  "semver": "7.5.4",
156
156
  "decode-uri-component": "0.4.1",
157
157
  "set-value": "4.1.0",
158
- "dompurify": "3.4.5"
158
+ "dompurify": "3.4.5",
159
+ "amf-client-js": "$amf-client-js"
159
160
  },
160
161
  "resolutions": {
161
162
  "dompurify": "3.4.5"
package/src/ApiConsole.js CHANGED
@@ -523,9 +523,36 @@ export class ApiConsole extends AmfHelperMixin(LitElement) {
523
523
  * `request`.
524
524
  */
525
525
  _tryitHandler() {
526
+ if (this._isWebhookOperation(this.selectedShape, this.webApi)) {
527
+ return;
528
+ }
526
529
  this.page = 'request';
527
530
  }
528
531
 
532
+ /**
533
+ * Whether `selected` is an OAS 3.1/3.2 top-level webhook operation.
534
+ * Webhooks have no invokable URL — the API calls the consumer, not the
535
+ * other way around — so the request/response "try it" panel doesn't
536
+ * apply to them.
537
+ * @param {String} selected Currently selected AMF shape (@id).
538
+ * @param {Object} webApi Computed AMF WebAPI model.
539
+ * @return {Boolean}
540
+ */
541
+ _isWebhookOperation(selected, webApi) {
542
+ if (!selected || !webApi || typeof this._computeWebhooks !== 'function') {
543
+ return false;
544
+ }
545
+ const webhooks = this._computeWebhooks(webApi);
546
+ if (!webhooks || !webhooks.length) {
547
+ return false;
548
+ }
549
+ const opKey = this._getAmfKey(this.ns.aml.vocabularies.apiContract.supportedOperation);
550
+ return webhooks.some((webhook) => {
551
+ const operations = this._ensureArray(webhook[opKey]);
552
+ return operations && operations.some((op) => op['@id'] === selected);
553
+ });
554
+ }
555
+
529
556
  /**
530
557
  * Resets current selection to "summary" page
531
558
  */
@@ -793,7 +820,6 @@ export class ApiConsole extends AmfHelperMixin(LitElement) {
793
820
  inlineMethods,
794
821
  compatibility,
795
822
  outlined,
796
- _noTryItValue,
797
823
  amf,
798
824
  selectedShape,
799
825
  selectedShapeType,
@@ -806,6 +832,7 @@ export class ApiConsole extends AmfHelperMixin(LitElement) {
806
832
  _noServerSelector,
807
833
  allowCustomBaseUri,
808
834
  } = this;
835
+ const noTryIt = this._noTryItValue || this._isWebhookOperation(selectedShape, this.webApi);
809
836
 
810
837
  return html`<api-documentation
811
838
  .amf="${amf}"
@@ -817,7 +844,7 @@ export class ApiConsole extends AmfHelperMixin(LitElement) {
817
844
  ?noServerSelector="${_noServerSelector}"
818
845
  ?allowCustomBaseUri="${allowCustomBaseUri}"
819
846
  .inlineMethods="${inlineMethods}"
820
- .noTryIt="${_noTryItValue}"
847
+ .noTryIt="${noTryIt}"
821
848
  .baseUri="${baseUri}"
822
849
  .redirectUri="${redirectUri}"
823
850
  .scrollTarget="${scrollTarget}"
@@ -374,9 +374,13 @@ export class ApiConsoleApp extends ApiConsole {
374
374
  * @return {TemplateResult} Template for the api documentation section
375
375
  */
376
376
  _apiDocumentationTemplate() {
377
+ // Webhooks have no invokable URL: the inline panel would render broken
378
+ // (no server/URL to send a request to) even though there's no "Try it"
379
+ // button to gate it, so the webhook check has to happen here too.
380
+ const webhookSelected = this._isWebhookOperation(this.selectedShape, this.webApi);
377
381
  return html`<section class="api-docs">
378
382
  ${super._apiDocumentationTemplate()}
379
- ${this._renderInlineTryit ? html`<div class="inline-request">
383
+ ${this._renderInlineTryit && !webhookSelected ? html`<div class="inline-request">
380
384
  ${this._bannerMessage()}
381
385
  ${this._requestPanelTemplate()}
382
386
  </div>` : ''}