-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Segment parsed types by namespace to avoid clobbering of types with t…
…he same type name but different namespaces
- Loading branch information
Showing
9 changed files
with
151 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
spec/fixtures/types_with_same_name_in_separate_namespaces.wsdl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<definitions | ||
xmlns="http://schemas.xmlsoap.org/wsdl/" | ||
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" | ||
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" | ||
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" | ||
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:s="http://www.w3.org/2001/XMLSchema" | ||
xmlns:article="http://example.com/article" | ||
xmlns:actions="http://example.com/actions" | ||
targetNamespace="http://example.com/actions"> | ||
<types> | ||
<s:schema elementFormDefault="qualified" targetNamespace="http://example.com/actions"> | ||
<s:element name="Save"> | ||
<s:complexType> | ||
<s:sequence> | ||
<s:element name="article" type="article:Article"/> | ||
<s:element name="actionHeader" type="actions:Header" /> | ||
<s:element name="articleHeader" type="article:Header" /> | ||
</s:sequence> | ||
</s:complexType> | ||
</s:element> | ||
<s:complexType name="Header"> | ||
<s:sequence> | ||
<s:element minOccurs="0" name="ActionHeaderField1" type="s:string"/> | ||
<s:element minOccurs="0" name="Description" type="s:string"/> | ||
</s:sequence> | ||
</s:complexType> | ||
</s:schema> | ||
<s:schema elementFormDefault="qualified" targetNamespace="http://example.com/article"> | ||
<s:complexType name="Article"> | ||
<s:sequence> | ||
<s:element minOccurs="0" name="Author" type="s:string"/> | ||
<s:element minOccurs="0" name="Title" type="s:string"/> | ||
</s:sequence> | ||
</s:complexType> | ||
<s:complexType name="Header"> | ||
<s:sequence> | ||
<s:element minOccurs="0" name="ArticleHeaderField1" type="s:string"/> | ||
<s:element minOccurs="0" name="Description" type="s:string"/> | ||
</s:sequence> | ||
</s:complexType> | ||
</s:schema> | ||
</types> | ||
<message name="SaveSoapIn"> | ||
<part name="parameters" element="actions:Save"/> | ||
</message> | ||
<message name="SaveSoapOut"> | ||
<part name="parameters" element="actions:SaveResponse"/> | ||
</message> | ||
<portType name="ArticleSoap"> | ||
<operation name="Save"> | ||
<input message="actions:SaveSoapIn"/> | ||
<output message="actions:SaveSoapOut"/> | ||
</operation> | ||
</portType> | ||
<binding name="ArticleSoap" type="actions:ArticleSoap"> | ||
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/> | ||
<operation name="Save"> | ||
<soap:operation soapAction="http://example.com/actions.Save" style="document"/> | ||
<input> | ||
<soap:body use="literal"/> | ||
</input> | ||
<output> | ||
<soap:body use="literal"/> | ||
</output> | ||
</operation> | ||
</binding> | ||
<service name="StudyMDL"> | ||
<port name="StudyMDLSoap" binding="actions:StudyMDLSoap"> | ||
<soap:address location="http://example.com:1234/soap"/> | ||
</port> | ||
</service> | ||
</definitions> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
spec/wasabi/parser/types_with_same_name_in_separate_namespaces_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require 'spec_helper' | ||
|
||
describe Wasabi::Parser do | ||
context 'with: types_with_same_name_in_separate_namespaces.wsdl' do | ||
subject do | ||
parser = Wasabi::Parser.new Nokogiri::XML(xml) | ||
parser.parse | ||
parser | ||
end | ||
|
||
let(:xml) { fixture(:types_with_same_name_in_separate_namespaces).read } | ||
|
||
it 'parses two types in separate namespaces' do | ||
expect(subject.types['http://example.com/article'].keys.sort).to eq(['Article', 'Header']) | ||
expect(subject.types['http://example.com/actions'].keys.sort).to eq(['Header', 'Save']) | ||
end | ||
|
||
it 'assigns the correct type to the appropriate namespace' do | ||
expect(subject.types['http://example.com/article']['Header'][:order!]).to eq(['ArticleHeaderField1', 'Description']) | ||
expect(subject.types['http://example.com/article']['Header'][:namespace]).to eq('http://example.com/article') | ||
|
||
expect(subject.types['http://example.com/actions']['Header'][:order!]).to eq(['ActionHeaderField1', 'Description']) | ||
expect(subject.types['http://example.com/actions']['Header'][:namespace]).to eq('http://example.com/actions') | ||
end | ||
|
||
end | ||
end |