swagger_aem 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,237 @@
1
+ =begin
2
+ #Adobe Experience Manager (AEM) API
3
+
4
+ #Swagger AEM is an OpenAPI specification for Adobe Experience Manager (AEM) API
5
+
6
+ OpenAPI spec version: 1.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.
21
+
22
+ =end
23
+
24
+ require 'spec_helper'
25
+
26
+ describe SwaggerAemClient::ApiClient do
27
+ context 'initialization' do
28
+ context 'URL stuff' do
29
+ context 'host' do
30
+ it 'removes http from host' do
31
+ SwaggerAemClient.configure { |c| c.host = 'http://example.com' }
32
+ expect(SwaggerAemClient::Configuration.default.host).to eq('example.com')
33
+ end
34
+
35
+ it 'removes https from host' do
36
+ SwaggerAemClient.configure { |c| c.host = 'https://wookiee.com' }
37
+ expect(SwaggerAemClient::ApiClient.default.config.host).to eq('wookiee.com')
38
+ end
39
+
40
+ it 'removes trailing path from host' do
41
+ SwaggerAemClient.configure { |c| c.host = 'hobo.com/v4' }
42
+ expect(SwaggerAemClient::Configuration.default.host).to eq('hobo.com')
43
+ end
44
+ end
45
+
46
+ context 'base_path' do
47
+ it "prepends a slash to base_path" do
48
+ SwaggerAemClient.configure { |c| c.base_path = 'v4/dog' }
49
+ expect(SwaggerAemClient::Configuration.default.base_path).to eq('/v4/dog')
50
+ end
51
+
52
+ it "doesn't prepend a slash if one is already there" do
53
+ SwaggerAemClient.configure { |c| c.base_path = '/v4/dog' }
54
+ expect(SwaggerAemClient::Configuration.default.base_path).to eq('/v4/dog')
55
+ end
56
+
57
+ it "ends up as a blank string if nil" do
58
+ SwaggerAemClient.configure { |c| c.base_path = nil }
59
+ expect(SwaggerAemClient::Configuration.default.base_path).to eq('')
60
+ end
61
+ end
62
+ end
63
+ end
64
+
65
+ describe "params_encoding in #build_request" do
66
+ let(:config) { SwaggerAemClient::Configuration.new }
67
+ let(:api_client) { SwaggerAemClient::ApiClient.new(config) }
68
+
69
+ it "defaults to nil" do
70
+ expect(SwaggerAemClient::Configuration.default.params_encoding).to eq(nil)
71
+ expect(config.params_encoding).to eq(nil)
72
+
73
+ request = api_client.build_request(:get, '/test')
74
+ expect(request.options[:params_encoding]).to eq(nil)
75
+ end
76
+
77
+ it "can be customized" do
78
+ config.params_encoding = :multi
79
+ request = api_client.build_request(:get, '/test')
80
+ expect(request.options[:params_encoding]).to eq(:multi)
81
+ end
82
+ end
83
+
84
+ describe "timeout in #build_request" do
85
+ let(:config) { SwaggerAemClient::Configuration.new }
86
+ let(:api_client) { SwaggerAemClient::ApiClient.new(config) }
87
+
88
+ it "defaults to 0" do
89
+ expect(SwaggerAemClient::Configuration.default.timeout).to eq(0)
90
+ expect(config.timeout).to eq(0)
91
+
92
+ request = api_client.build_request(:get, '/test')
93
+ expect(request.options[:timeout]).to eq(0)
94
+ end
95
+
96
+ it "can be customized" do
97
+ config.timeout = 100
98
+ request = api_client.build_request(:get, '/test')
99
+ expect(request.options[:timeout]).to eq(100)
100
+ end
101
+ end
102
+
103
+ describe "#deserialize" do
104
+ it "handles Array<Integer>" do
105
+ api_client = SwaggerAemClient::ApiClient.new
106
+ headers = {'Content-Type' => 'application/json'}
107
+ response = double('response', headers: headers, body: '[12, 34]')
108
+ data = api_client.deserialize(response, 'Array<Integer>')
109
+ expect(data).to be_instance_of(Array)
110
+ expect(data).to eq([12, 34])
111
+ end
112
+
113
+ it "handles Array<Array<Integer>>" do
114
+ api_client = SwaggerAemClient::ApiClient.new
115
+ headers = {'Content-Type' => 'application/json'}
116
+ response = double('response', headers: headers, body: '[[12, 34], [56]]')
117
+ data = api_client.deserialize(response, 'Array<Array<Integer>>')
118
+ expect(data).to be_instance_of(Array)
119
+ expect(data).to eq([[12, 34], [56]])
120
+ end
121
+
122
+ it "handles Hash<String, String>" do
123
+ api_client = SwaggerAemClient::ApiClient.new
124
+ headers = {'Content-Type' => 'application/json'}
125
+ response = double('response', headers: headers, body: '{"message": "Hello"}')
126
+ data = api_client.deserialize(response, 'Hash<String, String>')
127
+ expect(data).to be_instance_of(Hash)
128
+ expect(data).to eq({:message => 'Hello'})
129
+ end
130
+ end
131
+
132
+ describe "#object_to_hash" do
133
+ it "ignores nils and includes empty arrays" do
134
+ # uncomment below to test object_to_hash for model
135
+ #api_client = SwaggerAemClient::ApiClient.new
136
+ #_model = SwaggerAemClient::ModelName.new
137
+ # update the model attribute below
138
+ #_model.id = 1
139
+ # update the expected value (hash) below
140
+ #expected = {id: 1, name: '', tags: []}
141
+ #expect(api_client.object_to_hash(_model)).to eq(expected)
142
+ end
143
+ end
144
+
145
+ describe "#build_collection_param" do
146
+ let(:param) { ['aa', 'bb', 'cc'] }
147
+ let(:api_client) { SwaggerAemClient::ApiClient.new }
148
+
149
+ it "works for csv" do
150
+ expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc')
151
+ end
152
+
153
+ it "works for ssv" do
154
+ expect(api_client.build_collection_param(param, :ssv)).to eq('aa bb cc')
155
+ end
156
+
157
+ it "works for tsv" do
158
+ expect(api_client.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc")
159
+ end
160
+
161
+ it "works for pipes" do
162
+ expect(api_client.build_collection_param(param, :pipes)).to eq('aa|bb|cc')
163
+ end
164
+
165
+ it "works for multi" do
166
+ expect(api_client.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc'])
167
+ end
168
+
169
+ it "fails for invalid collection format" do
170
+ expect(proc { api_client.build_collection_param(param, :INVALID) }).to raise_error(RuntimeError, 'unknown collection format: :INVALID')
171
+ end
172
+ end
173
+
174
+ describe "#json_mime?" do
175
+ let(:api_client) { SwaggerAemClient::ApiClient.new }
176
+
177
+ it "works" do
178
+ expect(api_client.json_mime?(nil)).to eq false
179
+ expect(api_client.json_mime?('')).to eq false
180
+
181
+ expect(api_client.json_mime?('application/json')).to eq true
182
+ expect(api_client.json_mime?('application/json; charset=UTF8')).to eq true
183
+ expect(api_client.json_mime?('APPLICATION/JSON')).to eq true
184
+
185
+ expect(api_client.json_mime?('application/xml')).to eq false
186
+ expect(api_client.json_mime?('text/plain')).to eq false
187
+ expect(api_client.json_mime?('application/jsonp')).to eq false
188
+ end
189
+ end
190
+
191
+ describe "#select_header_accept" do
192
+ let(:api_client) { SwaggerAemClient::ApiClient.new }
193
+
194
+ it "works" do
195
+ expect(api_client.select_header_accept(nil)).to be_nil
196
+ expect(api_client.select_header_accept([])).to be_nil
197
+
198
+ expect(api_client.select_header_accept(['application/json'])).to eq('application/json')
199
+ expect(api_client.select_header_accept(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
200
+ expect(api_client.select_header_accept(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
201
+
202
+ expect(api_client.select_header_accept(['application/xml'])).to eq('application/xml')
203
+ expect(api_client.select_header_accept(['text/html', 'application/xml'])).to eq('text/html,application/xml')
204
+ end
205
+ end
206
+
207
+ describe "#select_header_content_type" do
208
+ let(:api_client) { SwaggerAemClient::ApiClient.new }
209
+
210
+ it "works" do
211
+ expect(api_client.select_header_content_type(nil)).to eq('application/json')
212
+ expect(api_client.select_header_content_type([])).to eq('application/json')
213
+
214
+ expect(api_client.select_header_content_type(['application/json'])).to eq('application/json')
215
+ expect(api_client.select_header_content_type(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
216
+ expect(api_client.select_header_content_type(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
217
+ expect(api_client.select_header_content_type(['application/xml'])).to eq('application/xml')
218
+ expect(api_client.select_header_content_type(['text/plain', 'application/xml'])).to eq('text/plain')
219
+ end
220
+ end
221
+
222
+ describe "#sanitize_filename" do
223
+ let(:api_client) { SwaggerAemClient::ApiClient.new }
224
+
225
+ it "works" do
226
+ expect(api_client.sanitize_filename('sun')).to eq('sun')
227
+ expect(api_client.sanitize_filename('sun.gif')).to eq('sun.gif')
228
+ expect(api_client.sanitize_filename('../sun.gif')).to eq('sun.gif')
229
+ expect(api_client.sanitize_filename('/var/tmp/sun.gif')).to eq('sun.gif')
230
+ expect(api_client.sanitize_filename('./sun.gif')).to eq('sun.gif')
231
+ expect(api_client.sanitize_filename('..\sun.gif')).to eq('sun.gif')
232
+ expect(api_client.sanitize_filename('\var\tmp\sun.gif')).to eq('sun.gif')
233
+ expect(api_client.sanitize_filename('c:\var\tmp\sun.gif')).to eq('sun.gif')
234
+ expect(api_client.sanitize_filename('.\sun.gif')).to eq('sun.gif')
235
+ end
236
+ end
237
+ end
@@ -0,0 +1,53 @@
1
+ =begin
2
+ #Adobe Experience Manager (AEM) API
3
+
4
+ #Swagger AEM is an OpenAPI specification for Adobe Experience Manager (AEM) API
5
+
6
+ OpenAPI spec version: 1.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.
21
+
22
+ =end
23
+
24
+ require 'spec_helper'
25
+
26
+ describe SwaggerAemClient::Configuration do
27
+ let(:config) { SwaggerAemClient::Configuration.default }
28
+
29
+ before(:each) do
30
+ # uncomment below to setup host and base_path
31
+ #require 'URI'
32
+ #uri = URI.parse("http://localhost/")
33
+ #SwaggerAemClient.configure do |c|
34
+ # c.host = uri.host
35
+ # c.base_path = uri.path
36
+ #end
37
+ end
38
+
39
+ describe '#base_url' do
40
+ it 'should have the default value' do
41
+ # uncomment below to test default value of the base path
42
+ #expect(config.base_url).to eq("http://localhost/")
43
+ end
44
+
45
+ it 'should remove trailing slashes' do
46
+ [nil, '', '/', '//'].each do |base_path|
47
+ config.base_path = base_path
48
+ # uncomment below to test trailing slashes
49
+ #expect(config.base_url).to eq("http://localhost/")
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,122 @@
1
+ =begin
2
+ #Adobe Experience Manager (AEM) API
3
+
4
+ #Swagger AEM is an OpenAPI specification for Adobe Experience Manager (AEM) API
5
+
6
+ OpenAPI spec version: 1.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ Licensed under the Apache License, Version 2.0 (the "License");
11
+ you may not use this file except in compliance with the License.
12
+ You may obtain a copy of the License at
13
+
14
+ http://www.apache.org/licenses/LICENSE-2.0
15
+
16
+ Unless required by applicable law or agreed to in writing, software
17
+ distributed under the License is distributed on an "AS IS" BASIS,
18
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
+ See the License for the specific language governing permissions and
20
+ limitations under the License.
21
+
22
+ =end
23
+
24
+ # load the gem
25
+ require 'swagger_aem'
26
+
27
+ # The following was generated by the `rspec --init` command. Conventionally, all
28
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
29
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
30
+ # this file to always be loaded, without a need to explicitly require it in any
31
+ # files.
32
+ #
33
+ # Given that it is always loaded, you are encouraged to keep this file as
34
+ # light-weight as possible. Requiring heavyweight dependencies from this file
35
+ # will add to the boot time of your test suite on EVERY test run, even for an
36
+ # individual file that may not need all of that loaded. Instead, consider making
37
+ # a separate helper file that requires the additional dependencies and performs
38
+ # the additional setup, and require it from the spec files that actually need
39
+ # it.
40
+ #
41
+ # The `.rspec` file also contains a few flags that are not defaults but that
42
+ # users commonly want.
43
+ #
44
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
45
+ RSpec.configure do |config|
46
+ # rspec-expectations config goes here. You can use an alternate
47
+ # assertion/expectation library such as wrong or the stdlib/minitest
48
+ # assertions if you prefer.
49
+ config.expect_with :rspec do |expectations|
50
+ # This option will default to `true` in RSpec 4. It makes the `description`
51
+ # and `failure_message` of custom matchers include text for helper methods
52
+ # defined using `chain`, e.g.:
53
+ # be_bigger_than(2).and_smaller_than(4).description
54
+ # # => "be bigger than 2 and smaller than 4"
55
+ # ...rather than:
56
+ # # => "be bigger than 2"
57
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
58
+ end
59
+
60
+ # rspec-mocks config goes here. You can use an alternate test double
61
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
62
+ config.mock_with :rspec do |mocks|
63
+ # Prevents you from mocking or stubbing a method that does not exist on
64
+ # a real object. This is generally recommended, and will default to
65
+ # `true` in RSpec 4.
66
+ mocks.verify_partial_doubles = true
67
+ end
68
+
69
+ # The settings below are suggested to provide a good initial experience
70
+ # with RSpec, but feel free to customize to your heart's content.
71
+ =begin
72
+ # These two settings work together to allow you to limit a spec run
73
+ # to individual examples or groups you care about by tagging them with
74
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
75
+ # get run.
76
+ config.filter_run :focus
77
+ config.run_all_when_everything_filtered = true
78
+
79
+ # Allows RSpec to persist some state between runs in order to support
80
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
81
+ # you configure your source control system to ignore this file.
82
+ config.example_status_persistence_file_path = "spec/examples.txt"
83
+
84
+ # Limits the available syntax to the non-monkey patched syntax that is
85
+ # recommended. For more details, see:
86
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
87
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
88
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
89
+ config.disable_monkey_patching!
90
+
91
+ # This setting enables warnings. It's recommended, but in some cases may
92
+ # be too noisy due to issues in dependencies.
93
+ config.warnings = true
94
+
95
+ # Many RSpec users commonly either run the entire suite or an individual
96
+ # file, and it's useful to allow more verbose output when running an
97
+ # individual spec file.
98
+ if config.files_to_run.one?
99
+ # Use the documentation formatter for detailed output,
100
+ # unless a formatter has already been configured
101
+ # (e.g. via a command-line flag).
102
+ config.default_formatter = 'doc'
103
+ end
104
+
105
+ # Print the 10 slowest examples and example groups at the
106
+ # end of the spec run, to help surface which specs are running
107
+ # particularly slow.
108
+ config.profile_examples = 10
109
+
110
+ # Run specs in random order to surface order dependencies. If you find an
111
+ # order dependency and want to debug it, you can fix the order by providing
112
+ # the seed, which is printed after each run.
113
+ # --seed 1234
114
+ config.order = :random
115
+
116
+ # Seed global randomization in this process using the `--seed` CLI option.
117
+ # Setting this allows you to use `--seed` to deterministically reproduce
118
+ # test failures related to randomization by passing the same `--seed` value
119
+ # as the one that triggered the failure.
120
+ Kernel.srand config.seed
121
+ =end
122
+ end
@@ -0,0 +1,56 @@
1
+ # -*- encoding: utf-8 -*-
2
+ #
3
+ =begin
4
+ #Adobe Experience Manager (AEM) API
5
+
6
+ #Swagger AEM is an OpenAPI specification for Adobe Experience Manager (AEM) API
7
+
8
+ OpenAPI spec version: 1.0
9
+
10
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
11
+
12
+ Licensed under the Apache License, Version 2.0 (the "License");
13
+ you may not use this file except in compliance with the License.
14
+ You may obtain a copy of the License at
15
+
16
+ http://www.apache.org/licenses/LICENSE-2.0
17
+
18
+ Unless required by applicable law or agreed to in writing, software
19
+ distributed under the License is distributed on an "AS IS" BASIS,
20
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
+ See the License for the specific language governing permissions and
22
+ limitations under the License.
23
+
24
+ =end
25
+
26
+ $:.push File.expand_path("../lib", __FILE__)
27
+ require "swagger_aem/version"
28
+
29
+ Gem::Specification.new do |s|
30
+ s.name = "swagger_aem"
31
+ s.version = SwaggerAemClient::VERSION
32
+ s.platform = Gem::Platform::RUBY
33
+ s.authors = ["Shine Solutions"]
34
+ s.email = ["opensource@shinesolutions.com"]
35
+ s.homepage = "https://github.com/shinesolutions/swagger-aem/tree/master/ruby"
36
+ s.summary = "Adobe Experience Manager (AEM) API Ruby Gem"
37
+ s.description = "Swagger AEM is an OpenAPI specification for Adobe Experience Manager (AEM) API"
38
+ s.license = "Apache 2.0"
39
+ s.required_ruby_version = ">= 1.9"
40
+
41
+ s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
42
+ s.add_runtime_dependency 'json', '~> 1.8', '>= 1.8.3'
43
+
44
+ s.add_development_dependency 'rspec', '~> 3.4', '>= 3.4.0'
45
+ s.add_development_dependency 'vcr', '~> 3.0', '>= 3.0.1'
46
+ s.add_development_dependency 'webmock', '~> 1.24', '>= 1.24.3'
47
+ s.add_development_dependency 'autotest', '~> 4.4', '>= 4.4.6'
48
+ s.add_development_dependency 'autotest-rails-pure', '~> 4.1', '>= 4.1.2'
49
+ s.add_development_dependency 'autotest-growl', '~> 0.2', '>= 0.2.16'
50
+ s.add_development_dependency 'autotest-fsevent', '~> 0.2', '>= 0.2.11'
51
+
52
+ s.files = `find *`.split("\n").uniq.sort.select{|f| !f.empty? }
53
+ s.test_files = `find spec/*`.split("\n")
54
+ s.executables = []
55
+ s.require_paths = ["lib"]
56
+ end