washout_builder 2.0.0 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0f24387c3759bd5136368bba80e629f8e86c916fd42c0b97f8108cf3adc89a33
4
- data.tar.gz: 0f63bda842effeb14e2fae1847734c9ec62533589d71e58b1b8bb01761a052b3
3
+ metadata.gz: 13eb15f962ae4e1c5ee71fe3eee2acdbcbf1db246169441bea159ee0f88c9407
4
+ data.tar.gz: 4541c0c078cf08f78e31d739735e49b861a511e513d51b3457a66fe2b1668813
5
5
  SHA512:
6
- metadata.gz: 2a08d8be0d183473151a22f78d9eca0779f827d69cd6d049cb354070c1012a46015f147cf6b5dc5738e22de99c61e1fe791d5e05ba4021b38a16e01ce6c63587
7
- data.tar.gz: fe79fedbef7cafc76fdd0e11e9838c22df2f64470654e65ee367d8f4c34dbb226106ddc05dd366a07de55d68d754d41094c4d73cd37e2d84c7c42fe9a6c24635
6
+ metadata.gz: a98832565f48093348b2664bec25aa9252a4215b976e28be23f781614e66e26c6e9f4a1c4f5ba5b9324366977d80fc314956d823ae82ced695f4d7ded18dd509
7
+ data.tar.gz: 7384869be3901fe1fb340e78522aa4d86c27a1e7141212f1946d074b1f52b7928714c679be1206661d728f2344427b555ea4d300841033b8cb69d37374f462be
data/README.md CHANGED
@@ -10,6 +10,27 @@ WashOutBuilder is a Soap Service Documentation generator (extends [WashOut](http
10
10
 
11
11
  The way [WashOut](https://github.com/inossidabile/wash_out) is used is not modified, it just extends its functionality by generating html documentation to your services that you write
12
12
 
13
+ NEW Improvements in version 2.0.1
14
+ ---------------------------------
15
+ - Fix issue when trying to re-use same complex type (with same structure) multiple times inside same controller
16
+
17
+ NEW Improvements in version 2.0.0
18
+ ---------------------------------
19
+
20
+ This release tries to fix some major bugs and introduces backward incompatible changes.
21
+ - The complex type list will contain now exactly same types used when doing an actual SOAP request
22
+ - Same for when listing the soap actions ( the return type and parameters ).
23
+
24
+ Initially the way the complex types were shown on the page was not correct, because it was not reflecting
25
+ the actual way the SOAP action receives its arguments when doing an actual SOAP request to that controller
26
+
27
+ The main issue was not handling correctly the classes that are inheriting from WashOut::Type.
28
+
29
+ This release tries to fix those issues.
30
+
31
+ Note: Only internal methods have been changed. The configuration has not changed.
32
+ So in order to upgrade to this new version, just update the version in your Gemfile/gemspec file
33
+
13
34
  NEW Improvements in version 1.5.1
14
35
  ---------------------------------
15
36
 
@@ -37,21 +58,6 @@ end
37
58
 
38
59
  If you don't set them and they are left with default nil values, you will have to use the old way, by manually mount the engine in the Rails routes configuration file (**config/routes.rb**) by following examples below.
39
60
 
40
- NEW Improvements in version 2.0.0
41
- ---------------------------------
42
-
43
- This release tries to fix some major bugs and introduces backward incompatible changes.
44
- - The complex type list will contain now exactly same types used when doing an actual SOAP request
45
- - Same for when listing the soap actions ( the return type and parameters ).
46
-
47
- Initially the way the complex types were shown on the page was not correct, because it was not reflecting
48
- the actual way the SOAP action receives its arguments when doing an actual SOAP request to that controller
49
-
50
- The main issue was not handling correctly the classes that are inheriting from WashOut::Type.
51
-
52
- This release tries to fix those issues.
53
-
54
-
55
61
  NEW Improvements in version 1.4.0
56
62
  ---------------------------------
57
63
 
@@ -30,7 +30,7 @@ module WashoutBuilder
30
30
  # @raise [RuntimeError] Raises a runtime error if is detected a duplicate use of the complex type
31
31
  # @api public
32
32
  def check_duplicate_complex_class(classes_defined, complex_class)
33
- complex_obj_found = classes_defined.find { |hash| hash[:class] == complex_class }
33
+ complex_obj_found = classes_defined.find { |hash| hash if hash[:class] == complex_class && hash[:obj].find_param_structure.keys != self.find_param_structure.keys }
34
34
  raise "Duplicate use of `#{basic_type}` type name. Consider using classified types." if !complex_obj_found.nil? && struct? && !classified?
35
35
  end
36
36
 
@@ -197,7 +197,7 @@ module WashoutBuilder
197
197
  # @param [Array<Hash>] classes_defined An Array with all the complex types that have been detected so far
198
198
  # @return [Array<Class>] An Array of classes from which the class that is sent as parameter inherits from
199
199
  # @api public
200
- def get_class_ancestors(config, class_name, classes_defined)
200
+ def get_class_ancestors(config, class_name, classes_defined)
201
201
  ancestors = get_ancestors(class_name)
202
202
  return if ancestors.blank?
203
203
  base_param_class = WashoutBuilder::Type.base_param_class
@@ -12,7 +12,7 @@ module WashoutBuilder
12
12
  # the minor version of the gem
13
13
  MINOR = 0
14
14
  # the tiny version of the gem
15
- TINY = 0
15
+ TINY = 2
16
16
  # if the version should be a prerelease
17
17
  PRE = nil
18
18
 
@@ -14,29 +14,29 @@ describe WashoutBuilder::Document::ComplexType do
14
14
  let(:namespaced_object) { get_wash_out_param(Api::TestType) }
15
15
 
16
16
  it 'returns the complex class name' do
17
- expect(subject.find_complex_class_name).to eq('ProjectType')
17
+ expect(subject.find_complex_class_name).to eq('Project')
18
18
  end
19
19
 
20
20
  it 'returns the complex class with namespace' do
21
- expect(namespaced_object.find_complex_class_name).to eq('Api::TestType')
21
+ expect(namespaced_object.find_complex_class_name).to eq('Project')
22
22
  end
23
23
 
24
- it 'returns error if classname already detected (only used for hashes)' do
24
+ it 'does not return error if classname already detected (only used for hashes) and same structure' do
25
25
  subject.stubs(:classified?).returns(false)
26
26
  subject.stubs(:basic_type).returns('ProjectType')
27
- defined = [{ class: 'ProjectType' }]
28
- expect { subject.find_complex_class_name(defined) }.to raise_error(RuntimeError, 'Duplicate use of `ProjectType` type name. Consider using classified types.')
27
+ classes_defined = [{ class: 'ProjectType', obj: get_wash_out_param(ProjectType), ancestors: [] }]
28
+ expect { subject.find_complex_class_name(classes_defined) }.to_not raise_error(RuntimeError, 'Duplicate use of `ProjectType` type name. Consider using classified types.')
29
29
  end
30
30
 
31
- it 'returns the param structure' do
32
- expect(subject.find_param_structure).to eq("project"=>"struct")
31
+ it 'returns error if classname already detected (only used for hashes)' do
32
+ subject.stubs(:classified?).returns(false)
33
+ subject.stubs(:basic_type).returns('ProjectType')
34
+ classes_defined = [{ class: 'ProjectType', obj: get_wash_out_param(Api::TestType), ancestors: [] }]
35
+ expect { subject.find_complex_class_name(classes_defined) }.to raise_error(RuntimeError, 'Duplicate use of `ProjectType` type name. Consider using classified types.')
33
36
  end
34
37
 
35
- it 'fixes the first descendant ' do
36
- descendant = get_wash_out_param(ProjectType.wash_out_param_map)
37
- subject.fix_descendant_wash_out_type(soap_config, ProjectType)
38
- expect(subject.name).to eq(descendant.name)
39
- expect(subject.map[0].find_param_structure).to eq(descendant.map[0].find_param_structure)
38
+ it 'returns the param structure' do
39
+ expect(subject.find_param_structure).to eq("description"=>"string", "name"=>"string", "users"=>"struct")
40
40
  end
41
41
 
42
42
  it 'same as ancestor' do
@@ -75,18 +75,18 @@ describe WashoutBuilder::Document::ComplexType do
75
75
 
76
76
  describe '#complex_type_descendants' do
77
77
  it 'returns empty array if not struct?' do
78
- defined = []
78
+ classes_defined = []
79
79
  subject.stubs(:struct?).returns(false)
80
- expect(subject.complex_type_descendants(soap_config, defined)).to eq(defined)
80
+ expect(subject.complex_type_descendants(soap_config, classes_defined)).to eq(classes_defined)
81
81
  end
82
82
 
83
83
  it 'returns the descendants if struct?' do
84
- defined = []
84
+ classes_defined = []
85
85
  subject.map.each do |obj|
86
- obj.expects(:get_nested_complex_types).with(soap_config, defined).returns([obj.name])
86
+ obj.expects(:get_nested_complex_types).with(soap_config, classes_defined).returns([obj.name])
87
87
  end
88
88
  subject.stubs(:struct?).returns(true)
89
- expect(subject.complex_type_descendants(soap_config, defined)).to eq(subject.map.map(&:name))
89
+ expect(subject.complex_type_descendants(soap_config, classes_defined)).to eq(subject.map.map(&:name))
90
90
  end
91
91
  end
92
92
 
@@ -97,21 +97,20 @@ describe WashoutBuilder::Document::ComplexType do
97
97
  let(:expected) { [complex_type_hash] }
98
98
 
99
99
  it 'returns the complex class ancestors' do
100
- defined = []
101
- subject.expects(:find_complex_class_name).with(defined).returns(complex_class)
102
- subject.expects(:fix_descendant_wash_out_type).with(soap_config, complex_class).returns(true)
103
- subject.expects(:complex_type_ancestors).with(soap_config, complex_class, defined).returns(ancestors)
100
+ classes_defined = []
101
+ subject.expects(:find_complex_class_name).with(classes_defined).returns(complex_class)
102
+ subject.expects(:find_class_from_string).with(complex_class).returns(nil)
103
+ subject.expects(:complex_type_ancestors).with(soap_config, complex_class, classes_defined).returns(ancestors)
104
104
  subject.expects(:complex_type_hash).with(complex_class, subject, ancestors).returns(complex_type_hash)
105
105
  subject.expects(:complex_type_descendants).with(soap_config, [complex_type_hash]).returns(expected)
106
- expect(subject.get_nested_complex_types(soap_config, defined)).to eq(expected)
106
+ expect(subject.get_nested_complex_types(soap_config, classes_defined)).to eq(expected)
107
107
  end
108
108
 
109
109
  it 'returns the the descendants' do
110
- defined = nil
110
+ classes_defined = nil
111
111
  subject.expects(:find_complex_class_name).with([]).returns(nil)
112
- subject.expects(:fix_descendant_wash_out_type).with(soap_config, nil).returns(true)
113
112
  subject.expects(:complex_type_descendants).with(soap_config, []).returns(expected)
114
- expect(subject.get_nested_complex_types(soap_config, defined)).to eq(expected)
113
+ expect(subject.get_nested_complex_types(soap_config, classes_defined)).to eq(expected)
115
114
  end
116
115
  end
117
116
 
@@ -135,7 +134,7 @@ describe WashoutBuilder::Document::ComplexType do
135
134
 
136
135
  describe '#get_class_ancestors' do
137
136
  let(:class_name) { 'ProjectType' }
138
- let(:defined) { [] }
137
+ let(:classes_defined) { [] }
139
138
  let(:ancestors) { ['SomeInexistentClass'] }
140
139
  let(:ancestor_structure) { { ancestors[0].to_s.downcase => 'bla' } }
141
140
  let(:top_ancestors) {}
@@ -143,7 +142,7 @@ describe WashoutBuilder::Document::ComplexType do
143
142
 
144
143
  it 'returns nil if no ancestors' do
145
144
  subject.expects(:get_ancestors).with(class_name).returns(nil)
146
- expect(subject.get_class_ancestors(soap_config, class_name, defined)).to eq(nil)
145
+ expect(subject.get_class_ancestors(soap_config, class_name, classes_defined)).to eq(nil)
147
146
  end
148
147
 
149
148
  it 'returns the ancestors and the top ones' do
@@ -153,15 +152,16 @@ describe WashoutBuilder::Document::ComplexType do
153
152
  WashOut::Param.stubs(:parse_def).returns([namespaced_object])
154
153
  subject.expects(:same_structure_as_ancestor?).with(namespaced_object).returns(false)
155
154
  subject.expects(:complex_type_hash).returns(complex_type_hash)
156
- expect(subject.get_class_ancestors(soap_config, class_name, defined)).to eq([complex_type_hash])
155
+ expect(subject.get_class_ancestors(soap_config, class_name, classes_defined)).to eq([complex_type_hash])
157
156
  end
158
157
 
159
158
  it 'returns nil if same structure as ancestor' do
159
+ namespaced_object
160
160
  subject.expects(:get_ancestors).with(class_name).returns(ancestors)
161
161
  subject.expects(:ancestor_structure).with(ancestors).returns(ancestor_structure)
162
- WashOut::Param.stubs(:parse_def).returns([namespaced_object])
162
+ WashOut::Param.stubs(:parse_def).with(soap_config, ancestor_structure).returns([namespaced_object])
163
163
  subject.expects(:same_structure_as_ancestor?).with(namespaced_object).returns(true)
164
- expect(subject.get_class_ancestors(soap_config, class_name, defined)).to eq(nil)
164
+ expect(subject.get_class_ancestors(soap_config, class_name, classes_defined)).to eq(nil)
165
165
  end
166
166
  end
167
167
  end
data/spec/spec_helper.rb CHANGED
@@ -102,7 +102,7 @@ def get_wash_out_param(class_or_struct, soap_config = OpenStruct.new(
102
102
  camelize_wsdl: false,
103
103
  namespace: '/api/wsdl'
104
104
  ))
105
- WashOut::Param.parse_builder_def(soap_config, class_or_struct)[0]
105
+ WashOut::Param.parse_def(soap_config, class_or_struct)[0]
106
106
  end
107
107
 
108
108
  class Hash
@@ -2,9 +2,8 @@ module Api
2
2
  class TestType < WashOut::Type
3
3
  map project: {
4
4
  name: :string,
5
- description: :string,
5
+ title: :string,
6
6
  users: [{ mail: :string }],
7
- # 'dada' => [Project]
8
7
  }
9
8
  end
10
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: washout_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - bogdanRada