@api-components/amf-helper-mixin
Advanced tools
Comparing version 4.0.20 to 4.0.21
@@ -281,2 +281,21 @@ /** | ||
/** | ||
* @returns List of servers for method, if defined, or endpoint, if defined, or root level | ||
*/ | ||
_getServers({ | ||
endpointId, | ||
methodId | ||
}: any): any[]|null; | ||
/** | ||
* Compute values for `server` property based on node an optional selected id. | ||
* | ||
* @returns The server list or undefined if node has no servers | ||
*/ | ||
_getServer({ | ||
endpointId, | ||
methodId, | ||
id | ||
}: any): any[]|any|null; | ||
/** | ||
* Computes endpoint's URI based on `amf` and `endpoint` models. | ||
@@ -446,2 +465,20 @@ * | ||
_getLinkTarget(amf: any, id: any): any; | ||
/** | ||
* Resolves the shape of a given reference. | ||
* | ||
* @param references References object to search in | ||
* @param id Id of the shape to resolve | ||
* @returns Resolved shape for given reference, undefined otherwise | ||
*/ | ||
_obtainShapeFromReferences(references: object|null, id: object|null): object|null|undefined; | ||
/** | ||
* Searches a node with a given ID in an array | ||
* | ||
* @param array Array to search for a given ID | ||
* @param id Id to search for | ||
* @returns Node with the given ID when found, undefined otherwise | ||
*/ | ||
_findById(array: any[]|null, id: String|null): object|null|undefined; | ||
_getReferenceId(amf: any, id: any): any; | ||
@@ -448,0 +485,0 @@ _resolveRecursive(shape: any): void; |
@@ -775,2 +775,57 @@ /** | ||
/** | ||
* | ||
* @param {?String} endpointId Optional endpoint to look for the servers in | ||
* @param {?String} methodId Optional method to look for the servers in | ||
* @return {Array} List of servers for method, if defined, or endpoint, if defined, or root level | ||
*/ | ||
_getServers({ endpointId, methodId }){ | ||
const { amf } = this; | ||
let api = this._computeWebApi(amf); | ||
if (Array.isArray(api)) { | ||
api = api[0]; | ||
} | ||
if (!api) { | ||
return | ||
} | ||
const serverKey = this._getAmfKey(this.ns.aml.vocabularies.apiContract.server); | ||
const getRootServers = () => { | ||
return this._getValueArray(api, serverKey); | ||
}; | ||
const getEndpointServers = () => { | ||
const endpoint = this._computeEndpointModel(api, endpointId); | ||
if (endpoint) { | ||
return this._getValueArray(endpoint, serverKey); | ||
} | ||
return getRootServers(); | ||
}; | ||
const getMethodServers = () => { | ||
const method = this._computeMethodModel(api, methodId); | ||
if (method) { | ||
return this._getValueArray(method, serverKey); | ||
} | ||
return getEndpointServers() | ||
}; | ||
if (methodId) { | ||
return getMethodServers() | ||
} else if (endpointId) { | ||
return getEndpointServers() | ||
} | ||
return getRootServers() | ||
} | ||
/** | ||
* Compute values for `server` property based on node an optional selected id. | ||
* | ||
* @param {?String} endpointId Optional endpoint id, required if method is provided | ||
* @param {?String} methodId Optional method id | ||
* @param {?String} id Optional selected server id | ||
* @return {Array|any} The server list or undefined if node has no servers | ||
*/ | ||
_getServer({ endpointId, methodId, id }) { | ||
const servers = this._getServers({ endpointId, methodId }); | ||
return servers ? servers.filter(srv => this._getValue(srv, '@id') === id) : undefined; | ||
} | ||
/** | ||
* Computes endpoint's URI based on `amf` and `endpoint` models. | ||
@@ -777,0 +832,0 @@ * |
{ | ||
"name": "@api-components/amf-helper-mixin", | ||
"description": "A mixin with common functions user by most AMF components to compyte AMF values", | ||
"version": "4.0.20", | ||
"version": "4.0.21", | ||
"license": "Apache-2.0", | ||
@@ -6,0 +6,0 @@ "main": "amf-helper-mixin.js", |
Sorry, the diff of this file is too big to display
210667
1749