From 322bdf1d3cf14dde87162ff823b756664165a292 Mon Sep 17 00:00:00 2001 From: Martin Schuster Date: Mon, 13 Jan 2020 18:37:26 +0100 Subject: [PATCH] fix for circular descriptions (#1101) * edge case when ref element and type have the same name * increased test coverage for elements.ts --- src/wsdl/elements.ts | 5 ++- test/wsdl-test.js | 18 ++++++++ test/wsdl/ref_element_same_as_type.wsdl | 56 +++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 test/wsdl/ref_element_same_as_type.wsdl diff --git a/src/wsdl/elements.ts b/src/wsdl/elements.ts index f9c8cc041..e39c7aaa1 100644 --- a/src/wsdl/elements.ts +++ b/src/wsdl/elements.ts @@ -224,7 +224,10 @@ export class ElementElement extends Element { if (!(typeName in definitions.descriptions.types)) { let elem: any = {}; - definitions.descriptions.types[typeName] = elem; + if (!this.$ref) { + definitions.descriptions.types[typeName] = elem; + } + const description = typeElement.description(definitions, xmlns); if (typeof description === 'string') { elem = description; diff --git a/test/wsdl-test.js b/test/wsdl-test.js index 6597f8c39..1f2e5b133 100644 --- a/test/wsdl-test.js +++ b/test/wsdl-test.js @@ -241,4 +241,22 @@ describe('WSDL Parser (non-strict)', () => { done(); }); }); + + it('should describe referenced elements with type of the same name', (done) => { + soap.createClient(__dirname+'/wsdl/ref_element_same_as_type.wsdl', function(err, client) { + assert.ifError(err); + var desc = client.describe(); + assert.equal(desc.MyService.MyPort.MyOperation.input.ExampleContent.MyID, 'xsd:string'); + done(); + }); + }); + + it('should describe port type', (done) => { + soap.createClient(__dirname+'/wsdl/ref_element_same_as_type.wsdl', function(err, client) { + assert.ifError(err); + var desc = client.wsdl.definitions.portTypes.MyPortType.description(client.wsdl.definitions); + assert.equal(desc.MyOperation.input.ExampleContent.MyID, 'xsd:string'); + done(); + }); + }); }); diff --git a/test/wsdl/ref_element_same_as_type.wsdl b/test/wsdl/ref_element_same_as_type.wsdl new file mode 100644 index 000000000..81fc3e77e --- /dev/null +++ b/test/wsdl/ref_element_same_as_type.wsdl @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Sample Port + + + + + + + + Sample Binding + + + + + + + + + + + + + + + + + +