shapewear 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +26 -0
- data/README.md +0 -1
- data/lib/shapewear/dsl.rb +6 -6
- data/lib/shapewear/request.rb +1 -1
- data/lib/shapewear/version.rb +1 -1
- data/lib/shapewear/wsdl.rb +74 -58
- data/spec/shapewear/service_definitions/complete_service.rb +0 -1
- metadata +4 -3
data/CHANGELOG.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## 0.0.5
|
4
|
+
* Removed the dual-namespace option. Now there's only one.
|
5
|
+
* Generating WSDL for SOAP 1.2;
|
6
|
+
* Added an option on the DSL to change the service name;
|
7
|
+
* Changed some conventions on the generated WSDL so Visual Studio .NET can understand it better.
|
8
|
+
|
9
|
+
## 0.0.4
|
10
|
+
* Fixed the samples;
|
11
|
+
* Fixed some bugs that prevented the generated WSDL to be used with Visual Studio.
|
12
|
+
|
13
|
+
## 0.0.3
|
14
|
+
* Added support for WSDL documentation;
|
15
|
+
* Added wasabi and WebMock to the specs;
|
16
|
+
* Added support for complex types on parameters, in addition to return values;
|
17
|
+
* Request handling for very simple cases.
|
18
|
+
|
19
|
+
## 0.0.2
|
20
|
+
* WSDL generation code extracted to its own module;
|
21
|
+
* Added support for complex return types;
|
22
|
+
* Fixed a bug on the String#camelize extension;
|
23
|
+
* DateTime support on parameters and return values.
|
24
|
+
|
25
|
+
## 0.0.1
|
26
|
+
* Initial, experimental version
|
data/README.md
CHANGED
data/lib/shapewear/dsl.rb
CHANGED
@@ -6,7 +6,7 @@ module Shapewear::DSL
|
|
6
6
|
private
|
7
7
|
|
8
8
|
def options
|
9
|
-
@options ||= {}
|
9
|
+
@options ||= { :service_name => self.name }
|
10
10
|
end
|
11
11
|
|
12
12
|
def operations
|
@@ -17,21 +17,21 @@ module Shapewear::DSL
|
|
17
17
|
options[:namespaces] ||=
|
18
18
|
Hash.new { |_, k| raise "Namespace not defined: #{k}" } \
|
19
19
|
.merge! 'tns' => "http://services.example.com/#{self.name}",
|
20
|
-
'xsd1' => "http://schema.example.com/#{self.name}",
|
21
20
|
'wsdl' => 'http://schemas.xmlsoap.org/wsdl/',
|
22
21
|
'soap' => 'http://schemas.xmlsoap.org/wsdl/soap/',
|
22
|
+
'soap12' => 'http://schemas.xmlsoap.org/wsdl/soap12/',
|
23
23
|
'xsd' => 'http://www.w3.org/2001/XMLSchema',
|
24
24
|
'env' => 'http://schemas.xmlsoap.org/soap/envelope/'
|
25
25
|
end
|
26
26
|
|
27
27
|
protected
|
28
28
|
|
29
|
-
def
|
30
|
-
|
29
|
+
def service_name(sn)
|
30
|
+
options[:service_name] = sn
|
31
31
|
end
|
32
32
|
|
33
|
-
def
|
34
|
-
namespaces['
|
33
|
+
def wsdl_namespace(ns)
|
34
|
+
namespaces['tns'] = ns
|
35
35
|
end
|
36
36
|
|
37
37
|
def endpoint_url(url)
|
data/lib/shapewear/request.rb
CHANGED
@@ -55,7 +55,7 @@ module Shapewear::Request
|
|
55
55
|
|
56
56
|
xb.Envelope :xmlns => namespaces['env'] do |xenv|
|
57
57
|
xenv.Body do |xbody|
|
58
|
-
xbody.tag! "#{op_options[:public_name]}Response", :xmlns => namespaces['
|
58
|
+
xbody.tag! "#{op_options[:public_name]}Response", :xmlns => namespaces['tns'] do |xres|
|
59
59
|
xres.body r
|
60
60
|
end
|
61
61
|
end
|
data/lib/shapewear/version.rb
CHANGED
data/lib/shapewear/wsdl.rb
CHANGED
@@ -12,12 +12,12 @@ module Shapewear::WSDL
|
|
12
12
|
xm.definitions :name => self.name, 'targetNamespace' => namespaces['tns'],
|
13
13
|
'xmlns' => namespaces['wsdl'],
|
14
14
|
'xmlns:soap' => namespaces['soap'],
|
15
|
+
'xmlns:soap12' => namespaces['soap12'],
|
15
16
|
'xmlns:xsd' => namespaces['xsd'],
|
16
|
-
'xmlns:xsd1' => namespaces['xsd1'],
|
17
17
|
'xmlns:tns' => namespaces['tns'] do |xdef|
|
18
18
|
|
19
19
|
xdef.types do |xtypes|
|
20
|
-
xtypes.schema 'xmlns' => namespaces['xsd'], 'targetNamespace' => namespaces['
|
20
|
+
xtypes.schema 'xmlns' => namespaces['xsd'], :elementFormDefault => 'qualified', 'targetNamespace' => namespaces['tns'] do |xschema|
|
21
21
|
|
22
22
|
# define elements for each defined method
|
23
23
|
operations.each do |m, op_opts|
|
@@ -26,41 +26,47 @@ module Shapewear::WSDL
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
operations.each do |
|
30
|
-
xdef.message :name => "#{op_opts[:public_name]}
|
31
|
-
xmsg.part :name => :
|
32
|
-
end
|
33
|
-
xdef.message :name => "#{op_opts[:public_name]}
|
34
|
-
xmsg.part :name => :
|
29
|
+
operations.each do |_, op_opts|
|
30
|
+
xdef.message :name => "#{op_opts[:public_name]}SoapIn" do |xmsg|
|
31
|
+
xmsg.part :name => :parameters, :element => "tns:#{op_opts[:public_name]}"
|
32
|
+
end
|
33
|
+
xdef.message :name => "#{op_opts[:public_name]}SoapOut" do |xmsg|
|
34
|
+
xmsg.part :name => :parameters, :element => "tns:#{op_opts[:public_name]}Response"
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
xdef.portType :name => "#{
|
39
|
-
operations.each do |
|
38
|
+
xdef.portType :name => "#{options[:service_name]}Soap" do |xpt|
|
39
|
+
operations.each do |_, op_opts|
|
40
40
|
xpt.operation :name => op_opts[:public_name] do |xop|
|
41
|
-
xop.input :message => "tns:#{op_opts[:public_name]}
|
42
|
-
xop.output :message => "tns:#{op_opts[:public_name]}
|
41
|
+
xop.input :message => "tns:#{op_opts[:public_name]}SoapIn"
|
42
|
+
xop.output :message => "tns:#{op_opts[:public_name]}SoapOut"
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
xbind.
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
47
|
+
# bindings for soap 1.1 and 1.2
|
48
|
+
['', '12'].each do |sv|
|
49
|
+
xdef.binding :name => "#{options[:service_name]}Soap#{sv}", :type => "tns:#{options[:service_name]}Soap" do |xbind|
|
50
|
+
xbind.tag! "soap#{sv}:binding", :transport => 'http://schemas.xmlsoap.org/soap/http'
|
51
|
+
operations.each do |_, op_opts|
|
52
|
+
xbind.operation :name => op_opts[:public_name] do |xop|
|
53
|
+
doc = op_opts[:documentation] rescue nil
|
54
|
+
xop.documentation doc unless doc.nil?
|
55
|
+
xop.tag! "soap#{sv}:operation", :soapAction => "#{namespaces['tns']}/#{op_opts[:public_name]}", :style => 'document'
|
56
|
+
xop.input { |xin| xin.tag! "soap#{sv}:body", :use => 'literal' }
|
57
|
+
xop.output { |xin| xin.tag! "soap#{sv}:body", :use => 'literal' }
|
58
|
+
end
|
56
59
|
end
|
57
60
|
end
|
58
61
|
end
|
59
62
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
63
|
+
# service definition for soap 1.1 and 1.2
|
64
|
+
['', '12'].each do |sv|
|
65
|
+
xdef.service :name => "#{options[:service_name]}#{sv}" do |xsrv|
|
66
|
+
xsrv.documentation "WSDL auto-generated by shapewear."
|
67
|
+
xsrv.port :name => "#{options[:service_name]}Soap#{sv}", :binding => "tns:#{options[:service_name]}Soap#{sv}" do |xport|
|
68
|
+
xport.tag! "soap#{sv}:address", :location => options[:endpoint_url]
|
69
|
+
end
|
64
70
|
end
|
65
71
|
end
|
66
72
|
end
|
@@ -70,37 +76,37 @@ module Shapewear::WSDL
|
|
70
76
|
# element for method arguments
|
71
77
|
um = instance_method(m)
|
72
78
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
if
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
params = (0..um.arity).map { |i| ["arg#{i}", Object] }
|
84
|
-
end
|
79
|
+
xschema.element :name => "#{op_options[:public_name]}" do |xreq|
|
80
|
+
xreq.complexType do |xct|
|
81
|
+
xct.sequence do |xseq|
|
82
|
+
params = op_options[:parameters] rescue nil
|
83
|
+
if params.nil?
|
84
|
+
if um.respond_to?(:parameters)
|
85
|
+
# with Ruby 1.9, we can create the parameters with the correct names
|
86
|
+
params = um.parameters.select { |p| p.first == :in }.map { |p| [p.first, Object] }
|
87
|
+
else
|
88
|
+
params = (0..um.arity).map { |i| ["arg#{i}", Object] }
|
85
89
|
end
|
90
|
+
end
|
86
91
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
92
|
+
params.each do |p|
|
93
|
+
t = p.last
|
94
|
+
param_name = p.first
|
95
|
+
param_name = param_name.to_s.camelize if param_name.is_a?(Symbol)
|
96
|
+
if t.nil?
|
97
|
+
xseq.element :name => param_name, :minOccurs => 0, :maxOccurs => 1, :type => 'xsd:any'
|
98
|
+
elsif t.is_a?(Class)
|
99
|
+
xseq.element :name => param_name, :minOccurs => 0, :maxOccurs => 1, :type => to_xsd_type(t)
|
100
|
+
elsif t.is_a?(Hash)
|
101
|
+
xseq.complexType do |xct2|
|
102
|
+
xct2.sequence do |xseq2|
|
103
|
+
t.each do |name, type|
|
104
|
+
xseq2.element :name => name, :minOccurs => 0, :maxOccurs => 1, :type => to_xsd_type(type)
|
99
105
|
end
|
100
106
|
end
|
101
|
-
else
|
102
|
-
raise "Could not interpret #{t.inspect} as a return type definition"
|
103
107
|
end
|
108
|
+
else
|
109
|
+
raise "Could not interpret #{t.inspect} as a return type definition"
|
104
110
|
end
|
105
111
|
end
|
106
112
|
end
|
@@ -108,24 +114,34 @@ module Shapewear::WSDL
|
|
108
114
|
end
|
109
115
|
|
110
116
|
# element for method result
|
117
|
+
ret = op_options[:returns] rescue nil
|
118
|
+
|
111
119
|
xschema.element :name => "#{op_options[:public_name]}Response" do |xreq|
|
112
120
|
xreq.complexType do |xct|
|
113
|
-
xct.
|
114
|
-
ret = op_options[:returns] rescue nil
|
121
|
+
xct.sequence do |xseq|
|
115
122
|
if ret.nil?
|
116
|
-
|
123
|
+
xseq.element :name => "#{op_options[:public_name]}Result", :minOccurs => 0, :maxOccurs => 1, :type => 'xsd:any'
|
117
124
|
elsif ret.is_a?(Class)
|
118
|
-
|
125
|
+
xseq.element :name => "#{op_options[:public_name]}Result", :minOccurs => 0, :maxOccurs => 1, :type => to_xsd_type(ret)
|
119
126
|
elsif ret.is_a?(Hash)
|
120
|
-
|
121
|
-
xall.element :name => name, :type => to_xsd_type(type)
|
122
|
-
end
|
127
|
+
xseq.element :name => "#{op_options[:public_name]}Result", :minOccurs => 0, :maxOccurs => 1, :type => "tns:#{op_options[:public_name]}Struct"
|
123
128
|
else
|
124
129
|
raise "Could not interpret #{ret.inspect} as a return type definition"
|
125
130
|
end
|
126
131
|
end
|
127
132
|
end
|
128
133
|
end
|
134
|
+
|
135
|
+
if ret.is_a?(Hash)
|
136
|
+
xschema.complexType :name => "#{op_options[:public_name]}Struct" do |xctr|
|
137
|
+
xctr.sequence do |xseqr|
|
138
|
+
ret.each do |name, type|
|
139
|
+
name = name.to_s.camelize if name.is_a?(Symbol)
|
140
|
+
xseqr.element :name => name, :minOccurs => 0, :maxOccurs => 1, :type => to_xsd_type(type)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
129
145
|
end
|
130
146
|
|
131
147
|
# @param t [Class]
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shapewear
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "F\xC3\xA1bio Batista"
|
@@ -150,6 +150,7 @@ files:
|
|
150
150
|
- .rspec
|
151
151
|
- .rvmrc
|
152
152
|
- .travis.yml
|
153
|
+
- CHANGELOG.md
|
153
154
|
- Gemfile
|
154
155
|
- Gemfile.lock
|
155
156
|
- LICENSE
|