@postman/wsdl-to-postman
Advanced tools
Comparing version 1.9.0 to 1.10.0
@@ -5,2 +5,12 @@ # WSDL to Postman Changelog | ||
## [v1.10.0] - 2023-06-27 | ||
### Added | ||
- [#11768](https://github.com/postmanlabs/postman-app-support/issues/11768) Added support for element and attribute prefixes for qualified schema types and elements. | ||
### Fixed | ||
- Fixed issue where max stack size was reached while generating collection from certain WSDL definition. | ||
## [v1.9.0] - 2023-05-04 | ||
@@ -80,4 +90,6 @@ | ||
[Unreleased]: https://github.com/postmanlabs/wsdl-to-postman/compare/v1.9.0...HEAD | ||
[Unreleased]: https://github.com/postmanlabs/wsdl-to-postman/compare/v1.10.0...HEAD | ||
[v1.10.0]: https://github.com/postmanlabs/wsdl-to-postman/compare/v1.9.0...v1.10.0 | ||
[v1.9.0]: https://github.com/postmanlabs/wsdl-to-postman/compare/v1.8.1...v1.9.0 | ||
@@ -84,0 +96,0 @@ |
@@ -242,3 +242,3 @@ const sdk = require('postman-collection'), | ||
operationOutput = operationFromWSDL.output.find((currentOutput) => { | ||
return currentOutput.name === info.name; | ||
return currentOutput.name === info.name || `${currentOutput.nsPrefix}:${currentOutput.name}` === info.name; | ||
}); | ||
@@ -248,3 +248,3 @@ | ||
operationOutput = operationFromWSDL.fault.find((currentFault) => { | ||
return currentFault.name === info.name; | ||
return currentFault.name === info.name || `${currentFault.nsPrefix}:${currentFault.name}` === info.name; | ||
}); | ||
@@ -251,0 +251,0 @@ } |
@@ -10,2 +10,3 @@ const { SOAPMessageHelper } = require('./SOAPMessageHelper'), | ||
{ XMLXSDValidator } = require('./../xsdValidation/XMLXSDValidator'), | ||
{ generatePrefixedElementName } = require('./WSDLElementUtils'), | ||
{ | ||
@@ -83,10 +84,12 @@ HTTP_PROTOCOL | ||
function getBodyMessage(nodeElement, protocol, cleanBody = true) { | ||
const soapMessageHelper = new SOAPMessageHelper(); | ||
const soapMessageHelper = new SOAPMessageHelper(), | ||
elementName = generatePrefixedElementName(nodeElement); | ||
bodyMessage = soapMessageHelper.convertInputToMessage(nodeElement, [], protocol, | ||
new XMLParser()); | ||
if (cleanBody) { | ||
cleanBodyMessage = nodeElement ? unwrapAndCleanBody(bodyMessage, nodeElement.name) : ''; | ||
cleanBodyMessage = nodeElement ? unwrapAndCleanBody(bodyMessage, elementName) : ''; | ||
} | ||
else { | ||
cleanBodyMessage = nodeElement ? getMessagePayload(bodyMessage, nodeElement.name) : ''; | ||
cleanBodyMessage = nodeElement ? getMessagePayload(bodyMessage, elementName) : ''; | ||
} | ||
@@ -93,0 +96,0 @@ return cleanBodyMessage; |
@@ -129,3 +129,3 @@ | ||
toProcess = schemasToOrderInformation.find((schema) => { | ||
return schema.targetNamespace === importedName; | ||
return typeof importedName !== 'undefined' && schema.targetNamespace === importedName; | ||
}); | ||
@@ -132,0 +132,0 @@ schemaAndInformation.dependencies.add( |
@@ -5,2 +5,3 @@ const | ||
} = require('./knownTypes'), | ||
{ generatePrefixedElementName } = require('./WSDLElementUtils'), | ||
{ | ||
@@ -75,15 +76,17 @@ ELEMENT_NOT_FOUND | ||
for (let childrenIndex = 0; childrenIndex < currentMessageParameter.children.length; childrenIndex++) { | ||
let elementChild = currentMessageParameter.children[childrenIndex]; | ||
let elementChild = currentMessageParameter.children[childrenIndex], | ||
elementChildName = generatePrefixedElementName(elementChild); | ||
if (elementChild.isComplex) { | ||
this.assignPropertyValue(messageJSObject, elementChild.name, {}); | ||
this.assignPropertyValue(messageJSObject, elementChildName, {}); | ||
} | ||
else if (elementChild.type === ERROR_ELEMENT_IDENTIFIER) { | ||
this.assignPropertyValue(messageJSObject, elementChild.name, 'The element or type could not be found'); | ||
this.assignPropertyValue(messageJSObject, elementChildName, 'The element or type could not be found'); | ||
} | ||
else { | ||
this.assignPropertyValue(messageJSObject, elementChild.name, getValueExample(elementChild)); | ||
this.assignPropertyValue(messageJSObject, elementChildName, getValueExample(elementChild)); | ||
} | ||
if (!visitedElements.has(elementChild)) { | ||
messageParametersQueue.push(elementChild); | ||
createdJavascriptObjectQueue.push(messageJSObject[elementChild.name]); | ||
createdJavascriptObjectQueue.push(messageJSObject[elementChildName]); | ||
visitedElements.add(elementChild); | ||
@@ -103,7 +106,11 @@ } | ||
processMessageParent(messageParent, messageJSObject, createdJSOBjectReference, visitedElements) { | ||
const messageParentName = generatePrefixedElementName(messageParent), | ||
tnsKey = `${this.parserAttributePlaceHolder}xmlns` + | ||
(messageParent.attributeFormDefault && messageParent.nsPrefix ? `:${messageParent.nsPrefix}` : ''); | ||
if (messageParent.isComplex) { | ||
messageJSObject[messageParent.name] = {}; | ||
createdJSOBjectReference = messageJSObject[messageParent.name]; | ||
messageJSObject[messageParentName] = {}; | ||
createdJSOBjectReference = messageJSObject[messageParentName]; | ||
if (messageParent.namespace) { | ||
messageJSObject[messageParent.name][`${this.parserAttributePlaceHolder}xmlns`] = messageParent.namespace; | ||
messageJSObject[messageParentName][tnsKey] = messageParent.namespace; | ||
} | ||
@@ -115,8 +122,8 @@ } | ||
else if (messageParent.namespace && messageParent.namespace !== '') { | ||
messageJSObject[messageParent.name] = {}; | ||
messageJSObject[messageParent.name]['#text'] = getValueExample(messageParent); | ||
messageJSObject[messageParent.name][`${this.parserAttributePlaceHolder}xmlns`] = messageParent.namespace; | ||
messageJSObject[messageParentName] = {}; | ||
messageJSObject[messageParentName]['#text'] = getValueExample(messageParent); | ||
messageJSObject[messageParentName][tnsKey] = messageParent.namespace; | ||
} | ||
else { | ||
messageJSObject[messageParent.name] = getValueExample(messageParent); | ||
messageJSObject[messageParentName] = getValueExample(messageParent); | ||
} | ||
@@ -123,0 +130,0 @@ |
@@ -42,6 +42,38 @@ const IS_COMPLEX = false, | ||
/** | ||
* Generates element name with prefix based on `attributeFormDefault` and `elementFormDefault` attributes | ||
* for the provided element. | ||
* `attributeFormDefault` and `elementFormDefault` are inherited from the parent schema of corresponding element | ||
* | ||
* @param {object} element WSDL element from which the name is to be generated | ||
* @returns {string} Generated element name with prefix | ||
*/ | ||
function generatePrefixedElementName (element) { | ||
let elementName = element.name, | ||
prefixedElementName = elementName; | ||
if (typeof elementName !== 'string') { | ||
return ''; | ||
} | ||
if (elementName.startsWith(element.nsPrefix + ':') || elementName.startsWith('@' + element.nsPrefix + ':') || | ||
!element.nsPrefix) { | ||
return elementName; | ||
} | ||
if (elementName.startsWith('@') && element.attributeFormDefault) { | ||
prefixedElementName = '@' + element.nsPrefix + ':' + elementName.slice(1); | ||
} | ||
else if (!elementName.startsWith('@') && element.elementFormDefault) { | ||
prefixedElementName = element.nsPrefix + ':' + elementName; | ||
} | ||
return prefixedElementName; | ||
} | ||
module.exports = { | ||
createErrorElement, | ||
createEmptyElement | ||
createEmptyElement, | ||
generatePrefixedElementName | ||
}; |
{ | ||
"name": "@postman/wsdl-to-postman", | ||
"version": "1.9.0", | ||
"version": "1.10.0", | ||
"description": "Convert a given WSDL specification (1.1) to Postman Collection", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is too big to display
1321488
34813