wasabi 3.2.1 → 3.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/wasabi/parser.rb +29 -31
- data/lib/wasabi/version.rb +1 -1
- data/spec/wasabi/document/authentication_spec.rb +1 -1
- data/spec/wasabi/document/multiple_namespaces_spec.rb +1 -1
- data/spec/wasabi/document/namespaced_actions_spec.rb +3 -3
- data/spec/wasabi/document/no_namespace_spec.rb +3 -3
- data/spec/wasabi/document/savon295_spec.rb +1 -1
- data/spec/wasabi/parser/no_message_parts_spec.rb +7 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15e2f65da4e86bbb4c50c5276f475a86d6d6a149
|
4
|
+
data.tar.gz: 18762d7946965501f5eb64a0294aac13c151aaaf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bcbf70c7681e5bf8dd07518f562c6715fe7fff2ba613f3186027e51359479f347f82241bc5f753b3fc666fd31b4330edaf610d948f2c36aa40e578ea3e6d42d
|
7
|
+
data.tar.gz: ae4b73c2cb9b53cb53f6df356e351d75438b335d6b44dc28374ce57162dba64d79d357c70012bf3c92e83c9eadad82ed05f9de6b516156df521226add6ca4437
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
# 3.2.2 (2013-12-09)
|
2
|
+
|
3
|
+
* Fix: [#32](https://github.com/savonrb/wasabi/issues/32) fixes a regression in operation names that was adversely affecting Savon: https://github.com/savonrb/savon/issues/520
|
4
|
+
|
5
|
+
# 3.2.1 (2013-12-05)
|
6
|
+
|
7
|
+
* Feature: Drops requirement for Nokogiri <= 1.6 for modern rubies. This was in place for ruby 1.8 but since support for that is going away, we shouldn't prevent users from using newer versions of Nokogiri.
|
8
|
+
|
1
9
|
## 3.2.0 (2013-07-26)
|
2
10
|
|
3
11
|
* Feature: [#20](https://github.com/savonrb/wasabi/issues/20) Limited support for listing an
|
data/lib/wasabi/parser.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'uri'
|
2
|
+
require 'wasabi/core_ext/string'
|
3
3
|
|
4
4
|
module Wasabi
|
5
5
|
|
@@ -8,10 +8,10 @@ module Wasabi
|
|
8
8
|
# Parses WSDL documents and remembers their important parts.
|
9
9
|
class Parser
|
10
10
|
|
11
|
-
XSD =
|
12
|
-
WSDL =
|
13
|
-
SOAP_1_1 =
|
14
|
-
SOAP_1_2 =
|
11
|
+
XSD = 'http://www.w3.org/2001/XMLSchema'
|
12
|
+
WSDL = 'http://schemas.xmlsoap.org/wsdl/'
|
13
|
+
SOAP_1_1 = 'http://schemas.xmlsoap.org/wsdl/soap/'
|
14
|
+
SOAP_1_2 = 'http://schemas.xmlsoap.org/wsdl/soap12/'
|
15
15
|
|
16
16
|
def initialize(document)
|
17
17
|
self.document = document
|
@@ -71,15 +71,15 @@ module Wasabi
|
|
71
71
|
@namespace = namespace.to_s if namespace
|
72
72
|
|
73
73
|
@namespaces = @document.namespaces.inject({}) do |memo, (key, value)|
|
74
|
-
memo[key.sub(
|
74
|
+
memo[key.sub('xmlns:', '')] = value
|
75
75
|
memo
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
79
|
def parse_endpoint
|
80
80
|
if service_node = service
|
81
|
-
endpoint = service_node.at_xpath(
|
82
|
-
endpoint ||= service_node.at_xpath(service_node,
|
81
|
+
endpoint = service_node.at_xpath('.//soap11:address/@location', 'soap11' => SOAP_1_1)
|
82
|
+
endpoint ||= service_node.at_xpath(service_node, './/soap12:address/@location', 'soap12' => SOAP_1_2)
|
83
83
|
end
|
84
84
|
|
85
85
|
@endpoint = parse_url(endpoint) if endpoint
|
@@ -118,12 +118,12 @@ module Wasabi
|
|
118
118
|
|
119
119
|
def parse_operations_parameters
|
120
120
|
root_elements = document.xpath("wsdl:definitions/wsdl:types/*[local-name()='schema']/*[local-name()='element']", 'wsdl' => WSDL).each do |element|
|
121
|
-
name = element.attribute(
|
121
|
+
name = element.attribute('name').to_s.snakecase.to_sym
|
122
122
|
|
123
123
|
if operation = @operations[name]
|
124
124
|
element.xpath("*[local-name() ='complexType']/*[local-name() ='sequence']/*[local-name() ='element']").each do |child_element|
|
125
|
-
attr_name = child_element.attribute(
|
126
|
-
attr_type = (attr_type = child_element.attribute(
|
125
|
+
attr_name = child_element.attribute('name').to_s
|
126
|
+
attr_type = (attr_type = child_element.attribute('type').to_s.split(':')).size > 1 ? attr_type[1] : attr_type[0]
|
127
127
|
|
128
128
|
operation[:parameters] ||= {}
|
129
129
|
operation[:parameters][attr_name.to_sym] = { :name => attr_name, :type => attr_type }
|
@@ -133,9 +133,9 @@ module Wasabi
|
|
133
133
|
end
|
134
134
|
|
135
135
|
def parse_operations
|
136
|
-
operations = document.xpath(
|
136
|
+
operations = document.xpath('wsdl:definitions/wsdl:binding/wsdl:operation', 'wsdl' => WSDL)
|
137
137
|
operations.each do |operation|
|
138
|
-
name = operation.attribute(
|
138
|
+
name = operation.attribute('name').to_s
|
139
139
|
|
140
140
|
# TODO: check for soap namespace?
|
141
141
|
soap_operation = operation.element_children.find { |node| node.name == 'operation' }
|
@@ -179,20 +179,20 @@ module Wasabi
|
|
179
179
|
@types[name] ||= { :namespace => namespace }
|
180
180
|
@types[name][:order!] = []
|
181
181
|
|
182
|
-
type.xpath(
|
183
|
-
element_name = inner.attribute(
|
184
|
-
@types[name][element_name] = { :type => inner.attribute(
|
182
|
+
type.xpath('./xs:sequence/xs:element', 'xs' => XSD).each do |inner|
|
183
|
+
element_name = inner.attribute('name').to_s
|
184
|
+
@types[name][element_name] = { :type => inner.attribute('type').to_s }
|
185
185
|
|
186
186
|
[ :nillable, :minOccurs, :maxOccurs ].each do |attr|
|
187
187
|
if v = inner.attribute(attr.to_s)
|
188
|
-
|
188
|
+
@types[name][element_name][attr] = v.to_s
|
189
189
|
end
|
190
190
|
end
|
191
191
|
|
192
192
|
@types[name][:order!] << element_name
|
193
193
|
end
|
194
194
|
|
195
|
-
type.xpath(
|
195
|
+
type.xpath('./xs:complexContent/xs:extension/xs:sequence/xs:element', 'xs' => XSD).each do |inner_element|
|
196
196
|
element_name = inner_element.attribute('name').to_s
|
197
197
|
@types[name][element_name] = { :type => inner_element.attribute('type').to_s }
|
198
198
|
|
@@ -226,15 +226,15 @@ module Wasabi
|
|
226
226
|
end
|
227
227
|
|
228
228
|
def input_for(operation)
|
229
|
-
|
229
|
+
input_output_for(operation, 'input')
|
230
230
|
end
|
231
231
|
|
232
232
|
def output_for(operation)
|
233
|
-
|
233
|
+
input_output_for(operation, 'output')
|
234
234
|
end
|
235
235
|
|
236
236
|
def input_output_for(operation, input_output)
|
237
|
-
operation_name = operation[
|
237
|
+
operation_name = operation['name']
|
238
238
|
|
239
239
|
# Look up the input by walking up to portType, then up to the message.
|
240
240
|
|
@@ -244,15 +244,15 @@ module Wasabi
|
|
244
244
|
end
|
245
245
|
|
246
246
|
port_type_input_output = port_type_operation &&
|
247
|
-
|
247
|
+
port_type_operation.element_children.find { |node| node.name == input_output }
|
248
248
|
|
249
249
|
# TODO: Stupid fix for missing support for imports.
|
250
250
|
# Sometimes portTypes are actually included in a separate WSDL.
|
251
251
|
if port_type_input_output
|
252
|
-
if port_type_input_output.attribute(
|
253
|
-
port_message_ns_id, port_message_type = port_type_input_output.attribute(
|
252
|
+
if port_type_input_output.attribute('message').to_s.include? ':'
|
253
|
+
port_message_ns_id, port_message_type = port_type_input_output.attribute('message').to_s.split(':')
|
254
254
|
else
|
255
|
-
port_message_type = port_type_input_output.attribute(
|
255
|
+
port_message_type = port_type_input_output.attribute('message').to_s
|
256
256
|
end
|
257
257
|
|
258
258
|
message_ns_id, message_type = nil
|
@@ -262,16 +262,16 @@ module Wasabi
|
|
262
262
|
port_message_part = message.element_children.find { |node| node.name == 'part' }
|
263
263
|
|
264
264
|
if port_message_part
|
265
|
-
if (port_message_part_element = port_message_part.attribute(
|
265
|
+
if (port_message_part_element = port_message_part.attribute('element'))
|
266
266
|
message_ns_id, message_type = port_message_part_element.to_s.split(':')
|
267
267
|
end
|
268
268
|
end
|
269
269
|
|
270
270
|
# Fall back to the name of the binding operation
|
271
271
|
if message_type
|
272
|
-
[message_ns_id,
|
272
|
+
[message_ns_id, operation_name]
|
273
273
|
else
|
274
|
-
[port_message_ns_id,
|
274
|
+
[port_message_ns_id, operation_name]
|
275
275
|
end
|
276
276
|
else
|
277
277
|
[nil, operation_name]
|
@@ -302,7 +302,5 @@ module Wasabi
|
|
302
302
|
|
303
303
|
@sections = sections
|
304
304
|
end
|
305
|
-
|
306
305
|
end
|
307
|
-
|
308
306
|
end
|
data/lib/wasabi/version.rb
CHANGED
@@ -15,7 +15,7 @@ describe Wasabi::Document do
|
|
15
15
|
|
16
16
|
its(:operations) do
|
17
17
|
should == {
|
18
|
-
:authenticate => { :input => "authenticate", :output => "
|
18
|
+
:authenticate => { :input => "authenticate", :output => "authenticate", :action => "authenticate", :namespace_identifier => "tns" }
|
19
19
|
}
|
20
20
|
end
|
21
21
|
|
@@ -14,7 +14,7 @@ describe Wasabi::Document do
|
|
14
14
|
it { should have(1).operations }
|
15
15
|
|
16
16
|
its(:operations) do
|
17
|
-
should == { :save => { :input => "Save", :output=>"
|
17
|
+
should == { :save => { :input => "Save", :output=>"Save", :action => "http://example.com/actions.Save", :namespace_identifier => "actions", :parameters => { :article => { :name => "article", :type => "Article" } } } }
|
18
18
|
end
|
19
19
|
|
20
20
|
its(:type_namespaces) do
|
@@ -15,9 +15,9 @@ describe Wasabi::Document do
|
|
15
15
|
|
16
16
|
its(:operations) do
|
17
17
|
should include(
|
18
|
-
{ :delete_client => { :input => "
|
19
|
-
{ :get_clients => { :input => "
|
20
|
-
{ :get_api_key => { :input => "
|
18
|
+
{ :delete_client => { :input => "DeleteClient", :output => "DeleteClient", :action => "http://api.example.com/api/Client.Delete", :namespace_identifier => "tns" } },
|
19
|
+
{ :get_clients => { :input => "GetClients", :output => "GetClients", :action => "http://api.example.com/api/User.GetClients", :namespace_identifier => "tns" } },
|
20
|
+
{ :get_api_key => { :input => "GetApiKey", :output => "GetApiKey", :action => "http://api.example.com/api/User.GetApiKey", :namespace_identifier => "tns" } }
|
21
21
|
)
|
22
22
|
end
|
23
23
|
|
@@ -15,9 +15,9 @@ describe Wasabi::Document do
|
|
15
15
|
|
16
16
|
its(:operations) do
|
17
17
|
should include(
|
18
|
-
{ :get_user_login_by_id => { :input => "GetUserLoginById", :output => "
|
19
|
-
{ :get_all_contacts => { :input => "GetAllContacts", :output =>"
|
20
|
-
{ :search_user => { :input => "SearchUser", :output =>"
|
18
|
+
{ :get_user_login_by_id => { :input => "GetUserLoginById", :output => "GetUserLoginById", :action => "/api/api/GetUserLoginById", :namespace_identifier => "typens" } },
|
19
|
+
{ :get_all_contacts => { :input => "GetAllContacts", :output =>"GetAllContacts", :action => "/api/api/GetAllContacts", :namespace_identifier => "typens" } },
|
20
|
+
{ :search_user => { :input => "SearchUser", :output =>"SearchUser", :action => "/api/api/SearchUser", :namespace_identifier => nil } }
|
21
21
|
)
|
22
22
|
end
|
23
23
|
|
@@ -7,7 +7,7 @@ describe Wasabi::Document do
|
|
7
7
|
|
8
8
|
its(:operations) do
|
9
9
|
should include(
|
10
|
-
{ :sendsms => { :input => "
|
10
|
+
{ :sendsms => { :input => "sendsms", :output => "sendsms", :action => "sendsms", :namespace_identifier => "tns" } }
|
11
11
|
)
|
12
12
|
end
|
13
13
|
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Wasabi::Parser do
|
4
|
-
context
|
4
|
+
context 'with: no_message_parts.wsdl' do
|
5
5
|
|
6
6
|
subject do
|
7
7
|
parser = Wasabi::Parser.new Nokogiri::XML(xml)
|
@@ -11,16 +11,16 @@ describe Wasabi::Parser do
|
|
11
11
|
|
12
12
|
let(:xml) { fixture(:no_message_parts).read }
|
13
13
|
|
14
|
-
it
|
14
|
+
it 'falls back to using the message type in the port element' do
|
15
15
|
# Operation's input has no part element in the message, so using the message type.
|
16
|
-
subject.operations[:save][:input].should ==
|
16
|
+
subject.operations[:save][:input].should == 'Save'
|
17
17
|
|
18
18
|
# Operation's output has part element in the message, so using part element's type.
|
19
|
-
subject.operations[:save][:output].should ==
|
19
|
+
subject.operations[:save][:output].should == 'Save'
|
20
20
|
end
|
21
21
|
|
22
|
-
it
|
23
|
-
subject.operations[:save][:namespace_identifier].should ==
|
22
|
+
it 'falls back to using the namespace ID in the port element' do
|
23
|
+
subject.operations[:save][:namespace_identifier].should == 'actions'
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wasabi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Harrington
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpi
|