@postman/wsdl-to-postman
Advanced tools
Comparing version 1.8.0 to 1.8.1
@@ -1,2 +0,3 @@ | ||
const POST_METHOD = 'POST', | ||
const _ = require('lodash'), | ||
POST_METHOD = 'POST', | ||
GET_METHOD = 'GET'; | ||
@@ -17,3 +18,3 @@ | ||
}; | ||
return (verbs[stringVerb.toLowerCase()] || verbs.default); | ||
return (verbs[_.toLower(stringVerb)] || verbs.default); | ||
} | ||
@@ -20,0 +21,0 @@ |
@@ -139,3 +139,6 @@ const | ||
} | ||
jObj[fixedAttributeName] = value; | ||
if (jObj && typeof jObj === 'object') { | ||
jObj[fixedAttributeName] = value; | ||
} | ||
} | ||
@@ -142,0 +145,0 @@ |
const | ||
_ = require('lodash'), | ||
{ | ||
@@ -127,5 +128,9 @@ getHttpVerb, | ||
getAbstractDefinitionName(binding, tnsNamespace) { | ||
let tnsNamespacePrefix = (tnsNamespace && tnsNamespace.key === 'string') ? tnsNamespace.key + ':' : THIS_NS_PREFIX; | ||
let tnsNamespacePrefix = (tnsNamespace && tnsNamespace.key === 'string') ? tnsNamespace.key + ':' : THIS_NS_PREFIX, | ||
attribute = getAttributeByName(binding, ATTRIBUTE_TYPE); | ||
return getAttributeByName(binding, ATTRIBUTE_TYPE).replace(tnsNamespacePrefix, ''); | ||
if (typeof attribute === 'string') { | ||
return attribute.replace(tnsNamespacePrefix, ''); | ||
} | ||
return ''; | ||
} | ||
@@ -163,3 +168,3 @@ | ||
serviceLocation = this.getLocationFromBindingOperation(bindingOperation, bindingTagInfo), | ||
address = servicePort[addressKey]; | ||
address = servicePort[addressKey] || {}; | ||
serviceLocation = serviceLocation ? serviceLocation : ''; | ||
@@ -241,5 +246,9 @@ url = getAttributeByName(address, LOCATION_TAG) + serviceLocation; | ||
elementName = excludeSeparatorFromName(elementName); | ||
foundElement = elementsFromWSDL.find((element) => { | ||
return element.name === elementName; | ||
}); | ||
if (Array.isArray(elementsFromWSDL)) { | ||
foundElement = elementsFromWSDL.find((element) => { | ||
return element.name === elementName; | ||
}); | ||
} | ||
if (foundElement === undefined) { | ||
@@ -273,3 +282,3 @@ elementsArray.push(createErrorElement({}, elementName)); | ||
messages = getArrayFrom(getNodeByName(definitions, principalPrefix, MESSAGE_TAG)), | ||
foundMessage = messages.find((message) => { | ||
foundMessage = Array.isArray(messages) && messages.find((message) => { | ||
return getAttributeByName(message, ATTRIBUTE_NAME) === messageOnlyName; | ||
@@ -495,5 +504,6 @@ }); | ||
* @param {NameSpace} httpNamespace the http namespace information | ||
* @param {Array} allNameSpaces All namespaces present in wsdl definition | ||
* @returns {object} a new object with the information | ||
*/ | ||
getBindingInfoFromBindingTag(binding, soapNamespace, soap12Namespace, httpNamespace) { | ||
getBindingInfoFromBindingTag(binding, soapNamespace, soap12Namespace, httpNamespace, allNameSpaces) { | ||
if (!binding || typeof binding !== 'object') { | ||
@@ -510,18 +520,47 @@ throw new WsdlError('Cannot get binding info from undefined or null object'); | ||
} | ||
}); | ||
}), | ||
isProtocolSoap12, | ||
isProtocolSoap, | ||
isProtocolHttp; | ||
if (namespace === undefined) { | ||
throw new WsdlError('Cannot get binding from WSDL'); | ||
} | ||
const protocolKey = getQNamePrefix(namespace); | ||
protocolPrefix = getQNamePrefixFilter(namespace); | ||
if (soap12Namespace && protocolKey === soap12Namespace.key) { | ||
/** | ||
* There can be multiple namespaces defined with same binding URL. | ||
* In such cases detect binding namespaces by going through all namespaces and | ||
* identifying correct one via URL. | ||
*/ | ||
isProtocolSoap12 = soap12Namespace && (protocolKey === soap12Namespace.key || | ||
_.some(allNameSpaces, (namespace) => { | ||
return soap12Namespace.url === namespace.url && soap12Namespace.key !== namespace.key; | ||
})); | ||
if (!isProtocolSoap12) { | ||
isProtocolSoap = soapNamespace && (protocolKey === soapNamespace.key || | ||
_.some(allNameSpaces, (namespace) => { | ||
return soapNamespace.url === namespace.url && soapNamespace.key !== namespace.key; | ||
})); | ||
} | ||
if (!isProtocolSoap12 && !isProtocolSoap) { | ||
isProtocolHttp = httpNamespace && (protocolKey === httpNamespace.key || | ||
_.some(allNameSpaces, (namespace) => { | ||
return httpNamespace.url === namespace.url && httpNamespace.key !== namespace.key; | ||
})); | ||
} | ||
if (isProtocolSoap12) { | ||
protocol = SOAP12_PROTOCOL; | ||
verb = POST_METHOD; | ||
} | ||
else if (soapNamespace && protocolKey === soapNamespace.key) { | ||
else if (isProtocolSoap) { | ||
protocol = SOAP_PROTOCOL; | ||
verb = POST_METHOD; | ||
} | ||
else if (httpNamespace && protocolKey === httpNamespace.key) { | ||
else if (isProtocolHttp) { | ||
protocol = HTTP_PROTOCOL; | ||
@@ -528,0 +567,0 @@ verb = getHttpVerb(getAttributeByName(binding[namespace], ATTRIBUTE_VERB)); |
const | ||
_ = require('lodash'), | ||
{ | ||
@@ -109,5 +110,9 @@ getNodeByName, | ||
getAbstractDefinitionName(binding, tnsNamespace) { | ||
let tnsNamespacePrefix = (tnsNamespace && tnsNamespace.key === 'string') ? tnsNamespace.key + ':' : THIS_NS_PREFIX; | ||
let tnsNamespacePrefix = (tnsNamespace && tnsNamespace.key === 'string') ? tnsNamespace.key + ':' : THIS_NS_PREFIX, | ||
attribute = getAttributeByName(binding, INTERFACE_TAG); | ||
return getAttributeByName(binding, INTERFACE_TAG).replace(tnsNamespacePrefix, ''); | ||
if (typeof attribute === 'string') { | ||
return attribute.replace(tnsNamespacePrefix, ''); | ||
} | ||
return ''; | ||
} | ||
@@ -187,3 +192,3 @@ | ||
getServiceURL(serviceEndpoint, bindingOperation, bindingTagInfo, decodeFunction) { | ||
if (!serviceEndpoint) { | ||
if (!_.isObject(serviceEndpoint)) { | ||
return ''; | ||
@@ -263,5 +268,6 @@ } | ||
* @param {NameSpace} httpNamespace the documentos found namespace | ||
* @param {Array} allNameSpaces All namespaces present in wsdl definition | ||
* @returns {object} the protocol information | ||
*/ | ||
getBindingInfoFromBindingTag(binding, soapNamespace, soap12Namespace, httpNamespace) { | ||
getBindingInfoFromBindingTag(binding, soapNamespace, soap12Namespace, httpNamespace, allNameSpaces) { | ||
const type = getAttributeByName(binding, ATTRIBUTE_TYPE); | ||
@@ -277,5 +283,23 @@ let protocol = '', | ||
version = getAttributeByName(binding, namespaceKey + XML_NAMESPACE_SEPARATOR + ATTRIBUTE_VERSION); | ||
/** | ||
* There can be multiple namespaces defined with same binding URL. | ||
* In such cases detect binding namespaces by going through all namespaces and | ||
* identifying correct one via URL. | ||
*/ | ||
_.forEach(allNameSpaces, (namespace) => { | ||
if (_.get(soap12Namespace, 'url', _.get(soapNamespace, 'url')) === namespace.url && | ||
namespaceKey !== namespace.key) { | ||
let currVersion = getAttributeByName(binding, namespace.key + XML_NAMESPACE_SEPARATOR + ATTRIBUTE_VERSION); | ||
if (currVersion) { | ||
version = currVersion; | ||
namespaceKey = namespace.key; | ||
return false; | ||
} | ||
} | ||
}); | ||
if (version === '1.2') { | ||
protocol = SOAP12_PROTOCOL; | ||
protocol = SOAP12_PROTOCOL; | ||
verb = POST_METHOD; | ||
@@ -294,2 +318,22 @@ protocolPrefix = namespaceKey; | ||
ATTRIBUTE_METHOD_DEFAULT); | ||
protocolPrefix = httpNamespace.key; | ||
/** | ||
* There can be multiple namespaces defined with same binding URL. | ||
* In such cases detect binding namespaces by going through all namespaces and | ||
* identifying correct one via URL. | ||
*/ | ||
_.forEach(allNameSpaces, (namespace) => { | ||
if (_.get(httpNamespace, 'url') === namespace.url && _.get(httpNamespace, 'key') !== namespace.key) { | ||
let currReadVerb = getAttributeByName(binding, namespace.key + XML_NAMESPACE_SEPARATOR + | ||
ATTRIBUTE_METHOD_DEFAULT); | ||
if (currReadVerb) { | ||
readVerb = currReadVerb; | ||
protocolPrefix = namespace.key; | ||
return false; | ||
} | ||
} | ||
}); | ||
if (!readVerb) { | ||
@@ -301,3 +345,2 @@ verb = undefined; | ||
} | ||
protocolPrefix = httpNamespace.key; | ||
} | ||
@@ -472,6 +515,10 @@ else { | ||
elementName = getAttributeByName(information, ATTRIBUTE_ELEMENT); | ||
element = elementsFromWSDL.find((element) => { | ||
let fixedName = getQNameLocal(elementName); | ||
return element.name === fixedName; | ||
}); | ||
if (Array.isArray(elementsFromWSDL)) { | ||
element = elementsFromWSDL.find((element) => { | ||
let fixedName = getQNameLocal(elementName); | ||
return element.name === fixedName; | ||
}); | ||
} | ||
if (element === undefined) { | ||
@@ -478,0 +525,0 @@ elements.push(createErrorElement({}, elementName)); |
const | ||
_ = require('lodash'), | ||
WsdlObject = require('./WSDLObject').WsdlObject, | ||
@@ -157,3 +158,4 @@ Operation = require('./WSDLObject').Operation, | ||
newWsdlObject.SOAP12Namespace, | ||
newWsdlObject.HTTPNamespace), | ||
newWsdlObject.HTTPNamespace, | ||
newWsdlObject.allNameSpaces), | ||
bindingOperations = getBindingOperation(binding, principalPrefix, newWsdlObject), | ||
@@ -239,3 +241,3 @@ | ||
wsdlOperation.name, | ||
wsdlObject.wsdlNamespace.url, | ||
_.get(wsdlObject, 'wsdlNamespace.url'), | ||
wsdlObject.tnsNamespace | ||
@@ -242,0 +244,0 @@ ); |
{ | ||
"name": "@postman/wsdl-to-postman", | ||
"version": "1.8.0", | ||
"version": "1.8.1", | ||
"description": "Convert a given WSDL specification (1.1) to Postman Collection", | ||
@@ -55,3 +55,3 @@ "main": "index.js", | ||
"engines": { | ||
"node": ">=8" | ||
"node": ">=12" | ||
}, | ||
@@ -58,0 +58,0 @@ "dependencies": { |
Sorry, the diff of this file is too big to display
1315615
34719