@api-components/amf-helper-mixin
Advanced tools
Comparing version 4.0.22 to 4.0.23
@@ -836,2 +836,3 @@ /** | ||
} | ||
/** | ||
@@ -845,2 +846,3 @@ * Computes endpoint's URI based on `amf` and `endpoint` models. | ||
* @return {String} Endpoint's URI | ||
* @deprecated Use `_computeUri()` instead | ||
*/ | ||
@@ -860,3 +862,35 @@ _computeEndpointUri(server, endpoint, baseUri, version) { | ||
} | ||
/** | ||
* Computes endpoint's URI based on `endpoint` model. | ||
* | ||
* @param {Object} endpoint Model for the endpoint | ||
* @param {Object} opts Configuration options | ||
* @param {?Object} opts.server Model for current server, if available. | ||
* @param {?String} opts.baseUri Base URI to be used with the endpoint's paht. | ||
* Note, base URI is ignored when `ignoreBase` is set | ||
* @param {?String} version Current version of the API. It is used to replace | ||
* `{version}` from the URI template. | ||
* @param {?Boolean} [ignoreBase = false] Whether or not to ignore rendering | ||
* of the base URI with path. | ||
* @return {String} The base uri for the endpoint. | ||
*/ | ||
_computeUri(endpoint, { server, baseUri, version, ignoreBase=false } = {}) { | ||
let base = ''; | ||
if (ignoreBase === false) { | ||
base = this._getBaseUri(baseUri, server) || ''; | ||
if (base && base[base.length - 1] === '/') { | ||
base = base.substr(0, base.length - 1); | ||
} | ||
base = this._ensureUrlScheme(base); | ||
} | ||
const path = this._getValue(endpoint, this.ns.aml.vocabularies.apiContract.path); | ||
let result = base + (path || ''); | ||
if (version && result) { | ||
result = result.replace('{version}', version); | ||
} | ||
return result; | ||
} | ||
/** | ||
* Computes base URI value from either `baseUri`, `iron-meta` with | ||
@@ -863,0 +897,0 @@ * `ApiBaseUri` key or `amf` value (in this order). |
{ | ||
"name": "@api-components/amf-helper-mixin", | ||
"description": "A mixin with common functions user by most AMF components to compyte AMF values", | ||
"version": "4.0.22", | ||
"version": "4.0.23", | ||
"license": "Apache-2.0", | ||
@@ -6,0 +6,0 @@ "main": "amf-helper-mixin.js", |
Sorry, the diff of this file is too big to display
231359
1787