openapi_ipify 5.0.0 → 5.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d937a87a75d0ab25b418e5c5ad0de28f9945ebab36a37e8c9f9d1ec7efc300ff
4
- data.tar.gz: b14dfe2945348cc284b411fc52d38789f5d63c1198a00ec38700fa0739d544f4
3
+ metadata.gz: f488d240ad2fc32ea5e79d78c365cb267030e4d48b77a03dfdd036fbab3a8259
4
+ data.tar.gz: 055a639341b5ebeaa83683d13008592fb3d1ad113ffa65ab71d74afe78260394
5
5
  SHA512:
6
- metadata.gz: 547d0644a692924bff2e8ac525f67e5615ef5524453c83b5647f42d0528c94974ca10598bf7857f004ae485c2818e5c71d8e48e4a9bd84433f4dea939903e22a
7
- data.tar.gz: 9274e85742ecb796991ff9df9b8b94c2a570b3e2f596542bbfe0d53bfba7c9213097f54c56673993336c38c12b805fc6dc77f88a47ee200b21afed3c9cbb48e8
6
+ metadata.gz: ec52c51c64889c39ae52958a931e01f47d9cbd1ca27a8352d00d9d5a63d5dc1d0afe540d1e8dd0df8a6d8640818c89feffe552ff156d75696004309744cb1193
7
+ data.tar.gz: 9e148ecb09bc727595cbb9ac53a9fde42a191419cc5373af8dd25404c0521807391702a827cc17835fd7554ff84dcc7a3c93103aa72ed837cb0f4722b802ddb3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openapi_ipify (5.0.0)
4
+ openapi_ipify (5.2.0)
5
5
  typhoeus (~> 1.0, >= 1.0.1)
6
6
 
7
7
  GEM
@@ -10,14 +10,14 @@ GEM
10
10
  ast (2.4.2)
11
11
  byebug (11.1.3)
12
12
  coderay (1.1.3)
13
- diff-lcs (1.5.0)
13
+ diff-lcs (1.5.1)
14
14
  ethon (0.16.0)
15
15
  ffi (>= 1.15.0)
16
- ffi (1.15.5)
16
+ ffi (1.16.3)
17
17
  jaro_winkler (1.5.6)
18
18
  method_source (1.0.0)
19
- parallel (1.23.0)
20
- parser (3.2.2.3)
19
+ parallel (1.24.0)
20
+ parser (3.3.0.5)
21
21
  ast (~> 2.4.1)
22
22
  racc
23
23
  pry (0.14.2)
@@ -26,24 +26,24 @@ GEM
26
26
  pry-byebug (3.10.1)
27
27
  byebug (~> 11.0)
28
28
  pry (>= 0.13, < 0.15)
29
- psych (5.1.0)
29
+ psych (5.1.2)
30
30
  stringio
31
- racc (1.7.1)
31
+ racc (1.7.3)
32
32
  rainbow (3.1.1)
33
33
  rake (13.0.6)
34
- rspec (3.12.0)
35
- rspec-core (~> 3.12.0)
36
- rspec-expectations (~> 3.12.0)
37
- rspec-mocks (~> 3.12.0)
38
- rspec-core (3.12.2)
39
- rspec-support (~> 3.12.0)
40
- rspec-expectations (3.12.3)
34
+ rspec (3.13.0)
35
+ rspec-core (~> 3.13.0)
36
+ rspec-expectations (~> 3.13.0)
37
+ rspec-mocks (~> 3.13.0)
38
+ rspec-core (3.13.0)
39
+ rspec-support (~> 3.13.0)
40
+ rspec-expectations (3.13.0)
41
41
  diff-lcs (>= 1.2.0, < 2.0)
42
- rspec-support (~> 3.12.0)
43
- rspec-mocks (3.12.6)
42
+ rspec-support (~> 3.13.0)
43
+ rspec-mocks (3.13.0)
44
44
  diff-lcs (>= 1.2.0, < 2.0)
45
- rspec-support (~> 3.12.0)
46
- rspec-support (3.12.1)
45
+ rspec-support (~> 3.13.0)
46
+ rspec-support (3.13.1)
47
47
  rubocop (0.66.0)
48
48
  jaro_winkler (~> 1.5.1)
49
49
  parallel (~> 1.10)
@@ -53,8 +53,8 @@ GEM
53
53
  ruby-progressbar (~> 1.7)
54
54
  unicode-display_width (>= 1.4.0, < 1.6)
55
55
  ruby-progressbar (1.13.0)
56
- stringio (3.0.8)
57
- typhoeus (1.4.0)
56
+ stringio (3.1.0)
57
+ typhoeus (1.4.1)
58
58
  ethon (>= 0.9.0)
59
59
  unicode-display_width (1.5.0)
60
60
 
@@ -69,4 +69,4 @@ DEPENDENCIES
69
69
  rubocop (~> 0.66.0)
70
70
 
71
71
  BUNDLED WITH
72
- 2.4.17
72
+ 2.4.22
data/README.md CHANGED
@@ -6,10 +6,11 @@ OpenAPI client for ipify, a simple public IP address API
6
6
 
7
7
  This SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
8
8
 
9
- - API version: 5.0.0
10
- - Package version: 5.0.0
9
+ - API version: 5.2.0
10
+ - Package version: 5.2.0
11
+ - Generator version: 7.4.0
11
12
  - Build package: org.openapitools.codegen.languages.RubyClientCodegen
12
- For more information, please visit [https://github.com/cliffano/openapi-ipify](https://github.com/cliffano/openapi-ipify)
13
+ For more information, please visit [https://github.com/oapicf/openapi-ipify](https://github.com/oapicf/openapi-ipify)
13
14
 
14
15
  ## Installation
15
16
 
@@ -24,22 +25,22 @@ gem build openapi_ipify.gemspec
24
25
  Then either install the gem locally:
25
26
 
26
27
  ```shell
27
- gem install ./openapi_ipify-5.0.0.gem
28
+ gem install ./openapi_ipify-5.2.0.gem
28
29
  ```
29
30
 
30
- (for development, run `gem install --dev ./openapi_ipify-5.0.0.gem` to install the development dependencies)
31
+ (for development, run `gem install --dev ./openapi_ipify-5.2.0.gem` to install the development dependencies)
31
32
 
32
33
  or publish the gem to a gem hosting service, e.g. [RubyGems](https://rubygems.org/).
33
34
 
34
35
  Finally add this to the Gemfile:
35
36
 
36
- gem 'openapi_ipify', '~> 5.0.0'
37
+ gem 'openapi_ipify', '~> 5.2.0'
37
38
 
38
39
  ### Install from Git
39
40
 
40
- If the Ruby gem is hosted at a git repository: https://github.com/cliffano/openapi-ipify, then add the following in the Gemfile:
41
+ If the Ruby gem is hosted at a git repository: https://github.com/oapicf/openapi-ipify, then add the following in the Gemfile:
41
42
 
42
- gem 'openapi_ipify', :git => 'https://github.com/cliffano/openapi-ipify.git'
43
+ gem 'openapi_ipify', :git => 'https://github.com/oapicf/openapi-ipify.git'
43
44
 
44
45
  ### Include the Ruby code directly
45
46
 
data/git_push.sh CHANGED
@@ -14,7 +14,7 @@ if [ "$git_host" = "" ]; then
14
14
  fi
15
15
 
16
16
  if [ "$git_user_id" = "" ]; then
17
- git_user_id="cliffano"
17
+ git_user_id="oapicf"
18
18
  echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
19
19
  fi
20
20
 
@@ -3,10 +3,10 @@
3
3
 
4
4
  #OpenAPI client for ipify, a simple public IP address API
5
5
 
6
- The version of the OpenAPI document: 5.0.0
7
- Contact: blah@cliffano.com
6
+ The version of the OpenAPI document: 5.2.0
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 7.0.0
9
+ Generator version: 7.4.0
10
10
 
11
11
  =end
12
12
 
@@ -3,10 +3,10 @@
3
3
 
4
4
  #OpenAPI client for ipify, a simple public IP address API
5
5
 
6
- The version of the OpenAPI document: 5.0.0
7
- Contact: blah@cliffano.com
6
+ The version of the OpenAPI document: 5.2.0
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 7.0.0
9
+ Generator version: 7.4.0
10
10
 
11
11
  =end
12
12
 
@@ -17,6 +17,7 @@ require 'tempfile'
17
17
  require 'time'
18
18
  require 'typhoeus'
19
19
 
20
+
20
21
  module OpenApiIpifyClient
21
22
  class ApiClient
22
23
  # The Configuration object holding settings to be used in the API client.
@@ -45,9 +46,10 @@ module OpenApiIpifyClient
45
46
  # Call an API with given options.
46
47
  #
47
48
  # @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
48
- # the data deserialized from response body (could be nil), response status code and response headers.
49
+ # the data deserialized from response body (may be a Tempfile or nil), response status code and response headers.
49
50
  def call_api(http_method, path, opts = {})
50
51
  request = build_request(http_method, path, opts)
52
+ tempfile = download_file(request) if opts[:return_type] == 'File'
51
53
  response = request.run
52
54
 
53
55
  if @config.debugging
@@ -69,7 +71,9 @@ module OpenApiIpifyClient
69
71
  end
70
72
  end
71
73
 
72
- if opts[:return_type]
74
+ if opts[:return_type] == 'File'
75
+ data = tempfile
76
+ elsif opts[:return_type]
73
77
  data = deserialize(response, opts[:return_type])
74
78
  else
75
79
  data = nil
@@ -124,9 +128,7 @@ module OpenApiIpifyClient
124
128
  end
125
129
  end
126
130
 
127
- request = Typhoeus::Request.new(url, req_opts)
128
- download_file(request) if opts[:return_type] == 'File'
129
- request
131
+ Typhoeus::Request.new(url, req_opts)
130
132
  end
131
133
 
132
134
  # Builds the HTTP request body
@@ -164,6 +166,8 @@ module OpenApiIpifyClient
164
166
  # process can use.
165
167
  #
166
168
  # @see Configuration#temp_folder_path
169
+ #
170
+ # @return [Tempfile] the tempfile generated
167
171
  def download_file(request)
168
172
  tempfile = nil
169
173
  encoding = nil
@@ -178,21 +182,24 @@ module OpenApiIpifyClient
178
182
  prefix = prefix + '-' unless prefix.end_with?('-')
179
183
  encoding = response.body.encoding
180
184
  tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
181
- @tempfile = tempfile
182
185
  end
183
186
  request.on_body do |chunk|
184
187
  chunk.force_encoding(encoding)
185
188
  tempfile.write(chunk)
186
189
  end
187
- request.on_complete do |response|
188
- if tempfile
189
- tempfile.close
190
- @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
191
- "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
192
- "will be deleted automatically with GC. It's also recommended to delete the temp file "\
193
- "explicitly with `tempfile.delete`"
194
- end
190
+ # run the request to ensure the tempfile is created successfully before returning it
191
+ request.run
192
+ if tempfile
193
+ tempfile.close
194
+ @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
195
+ "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
196
+ "will be deleted automatically with GC. It's also recommended to delete the temp file "\
197
+ "explicitly with `tempfile.delete`"
198
+ else
199
+ fail ApiError.new("Failed to create the tempfile based on the HTTP response from the server: #{request.inspect}")
195
200
  end
201
+
202
+ tempfile
196
203
  end
197
204
 
198
205
  # Check if the given MIME is a JSON MIME.
@@ -213,15 +220,10 @@ module OpenApiIpifyClient
213
220
  # @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
214
221
  def deserialize(response, return_type)
215
222
  body = response.body
216
-
217
- # handle file downloading - return the File instance processed in request callbacks
218
- # note that response body is empty when the file is written in chunks in request on_body callback
219
- return @tempfile if return_type == 'File'
220
-
221
223
  return nil if body.nil? || body.empty?
222
224
 
223
225
  # return response body directly for String return type
224
- return body if return_type == 'String'
226
+ return body.to_s if return_type == 'String'
225
227
 
226
228
  # ensuring a default content type
227
229
  content_type = response.headers['Content-Type'] || 'application/json'
@@ -3,10 +3,10 @@
3
3
 
4
4
  #OpenAPI client for ipify, a simple public IP address API
5
5
 
6
- The version of the OpenAPI document: 5.0.0
7
- Contact: blah@cliffano.com
6
+ The version of the OpenAPI document: 5.2.0
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 7.0.0
9
+ Generator version: 7.4.0
10
10
 
11
11
  =end
12
12
 
@@ -3,10 +3,10 @@
3
3
 
4
4
  #OpenAPI client for ipify, a simple public IP address API
5
5
 
6
- The version of the OpenAPI document: 5.0.0
7
- Contact: blah@cliffano.com
6
+ The version of the OpenAPI document: 5.2.0
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 7.0.0
9
+ Generator version: 7.4.0
10
10
 
11
11
  =end
12
12
 
@@ -222,8 +222,8 @@ module OpenApiIpifyClient
222
222
 
223
223
  # Gets access_token using access_token_getter or uses the static access_token
224
224
  def access_token_with_refresh
225
- return access_token if access_token_getter.nil?
226
- access_token_getter.call
225
+ return access_token if access_token_getter.nil?
226
+ access_token_getter.call
227
227
  end
228
228
 
229
229
  # Gets Basic Auth token string
@@ -286,5 +286,6 @@ module OpenApiIpifyClient
286
286
  url
287
287
  end
288
288
 
289
+
289
290
  end
290
291
  end
@@ -3,10 +3,10 @@
3
3
 
4
4
  #OpenAPI client for ipify, a simple public IP address API
5
5
 
6
- The version of the OpenAPI document: 5.0.0
7
- Contact: blah@cliffano.com
6
+ The version of the OpenAPI document: 5.2.0
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 7.0.0
9
+ Generator version: 7.4.0
10
10
 
11
11
  =end
12
12
 
@@ -166,7 +166,7 @@ module OpenApiIpifyClient
166
166
  else # model
167
167
  # models (e.g. Pet) or oneOf
168
168
  klass = OpenApiIpifyClient.const_get(type)
169
- klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
169
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
170
170
  end
171
171
  end
172
172
 
@@ -3,13 +3,13 @@
3
3
 
4
4
  #OpenAPI client for ipify, a simple public IP address API
5
5
 
6
- The version of the OpenAPI document: 5.0.0
7
- Contact: blah@cliffano.com
6
+ The version of the OpenAPI document: 5.2.0
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 7.0.0
9
+ Generator version: 7.4.0
10
10
 
11
11
  =end
12
12
 
13
13
  module OpenApiIpifyClient
14
- VERSION = '5.0.0'
14
+ VERSION = '5.2.0'
15
15
  end
data/lib/openapi_ipify.rb CHANGED
@@ -3,10 +3,10 @@
3
3
 
4
4
  #OpenAPI client for ipify, a simple public IP address API
5
5
 
6
- The version of the OpenAPI document: 5.0.0
7
- Contact: blah@cliffano.com
6
+ The version of the OpenAPI document: 5.2.0
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 7.0.0
9
+ Generator version: 7.4.0
10
10
 
11
11
  =end
12
12
 
@@ -5,10 +5,10 @@
5
5
 
6
6
  #OpenAPI client for ipify, a simple public IP address API
7
7
 
8
- The version of the OpenAPI document: 5.0.0
9
- Contact: blah@cliffano.com
8
+ The version of the OpenAPI document: 5.2.0
9
+ Contact: blah+oapicf@cliffano.com
10
10
  Generated by: https://openapi-generator.tech
11
- OpenAPI Generator version: 7.0.0
11
+ Generator version: 7.4.0
12
12
 
13
13
  =end
14
14
 
@@ -19,13 +19,14 @@ Gem::Specification.new do |s|
19
19
  s.name = "openapi_ipify"
20
20
  s.version = OpenApiIpifyClient::VERSION
21
21
  s.platform = Gem::Platform::RUBY
22
- s.authors = ["Cliffano Subagio"]
23
- s.email = ["blah@cliffano.com"]
24
- s.homepage = "https://github.com/cliffano/openapi-ipify"
22
+ s.authors = ["OpenAPI Clients Factory"]
23
+ s.email = ["blah+oapicf@cliffano.com"]
24
+ s.homepage = "https://github.com/oapicf/openapi-ipify"
25
25
  s.summary = "openapi-ipify Ruby Gem"
26
26
  s.description = "OpenAPI client for ipify, a simple public IP address API"
27
27
  s.license = "MIT"
28
28
  s.required_ruby_version = ">= 2.0"
29
+ s.metadata = {}
29
30
 
30
31
  s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
31
32
 
@@ -3,10 +3,10 @@
3
3
 
4
4
  #OpenAPI client for ipify, a simple public IP address API
5
5
 
6
- The version of the OpenAPI document: 5.0.0
7
- Contact: blah@cliffano.com
6
+ The version of the OpenAPI document: 5.2.0
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 7.0.0
9
+ Generator version: 7.4.0
10
10
 
11
11
  =end
12
12
 
@@ -3,10 +3,10 @@
3
3
 
4
4
  #OpenAPI client for ipify, a simple public IP address API
5
5
 
6
- The version of the OpenAPI document: 5.0.0
7
- Contact: blah@cliffano.com
6
+ The version of the OpenAPI document: 5.2.0
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 7.0.0
9
+ Generator version: 7.4.0
10
10
 
11
11
  =end
12
12
 
@@ -22,9 +22,11 @@ describe OpenApiIpifyClient::Ip do
22
22
 
23
23
  describe 'test an instance of Ip' do
24
24
  it 'should create an instance of Ip' do
25
- expect(instance).to be_instance_of(OpenApiIpifyClient::Ip)
25
+ # uncomment below to test the instance creation
26
+ #expect(instance).to be_instance_of(OpenApiIpifyClient::Ip)
26
27
  end
27
28
  end
29
+
28
30
  describe 'test attribute "ip"' do
29
31
  it 'should work' do
30
32
  # assertion here. ref: https://rspec.info/features/3-12/rspec-expectations/built-in-matchers/
data/spec/spec_helper.rb CHANGED
@@ -3,10 +3,10 @@
3
3
 
4
4
  #OpenAPI client for ipify, a simple public IP address API
5
5
 
6
- The version of the OpenAPI document: 5.0.0
7
- Contact: blah@cliffano.com
6
+ The version of the OpenAPI document: 5.2.0
7
+ Contact: blah+oapicf@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 7.0.0
9
+ Generator version: 7.4.0
10
10
 
11
11
  =end
12
12
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openapi_ipify
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 5.2.0
5
5
  platform: ruby
6
6
  authors:
7
- - Cliffano Subagio
7
+ - OpenAPI Clients Factory
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-09 00:00:00.000000000 Z
11
+ date: 2024-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus
@@ -52,7 +52,7 @@ dependencies:
52
52
  version: 3.6.0
53
53
  description: OpenAPI client for ipify, a simple public IP address API
54
54
  email:
55
- - blah@cliffano.com
55
+ - blah+oapicf@cliffano.com
56
56
  executables: []
57
57
  extensions: []
58
58
  extra_rdoc_files: []
@@ -85,11 +85,9 @@ files:
85
85
  - lib/openapi_ipify/version.rb
86
86
  - openapi_ipify.gemspec
87
87
  - spec/api/default_api_spec.rb
88
- - spec/api_client_spec.rb
89
- - spec/configuration_spec.rb
90
88
  - spec/models/ip_spec.rb
91
89
  - spec/spec_helper.rb
92
- homepage: https://github.com/cliffano/openapi-ipify
90
+ homepage: https://github.com/oapicf/openapi-ipify
93
91
  licenses:
94
92
  - MIT
95
93
  metadata: {}
@@ -114,7 +112,5 @@ specification_version: 4
114
112
  summary: openapi-ipify Ruby Gem
115
113
  test_files:
116
114
  - spec/api/default_api_spec.rb
117
- - spec/api_client_spec.rb
118
- - spec/configuration_spec.rb
119
115
  - spec/models/ip_spec.rb
120
116
  - spec/spec_helper.rb
@@ -1,228 +0,0 @@
1
- =begin
2
- #openapi-ipify
3
-
4
- #OpenAPI client for ipify, a simple public IP address API
5
-
6
- The version of the OpenAPI document: 5.0.0
7
- Contact: blah@cliffano.com
8
- Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 7.0.0
10
-
11
- =end
12
-
13
- require 'spec_helper'
14
-
15
- describe OpenApiIpifyClient::ApiClient do
16
- context 'initialization' do
17
- context 'URL stuff' do
18
- context 'host' do
19
- it 'removes http from host' do
20
- OpenApiIpifyClient.configure { |c| c.host = 'http://example.com' }
21
- expect(OpenApiIpifyClient::Configuration.default.host).to eq('example.com')
22
- end
23
-
24
- it 'removes https from host' do
25
- OpenApiIpifyClient.configure { |c| c.host = 'https://wookiee.com' }
26
- expect(OpenApiIpifyClient::ApiClient.default.config.host).to eq('wookiee.com')
27
- end
28
-
29
- it 'removes trailing path from host' do
30
- OpenApiIpifyClient.configure { |c| c.host = 'hobo.com/v4' }
31
- expect(OpenApiIpifyClient::Configuration.default.host).to eq('hobo.com')
32
- end
33
- end
34
-
35
- context 'base_path' do
36
- it "prepends a slash to base_path" do
37
- OpenApiIpifyClient.configure { |c| c.base_path = 'v4/dog' }
38
- expect(OpenApiIpifyClient::Configuration.default.base_path).to eq('/v4/dog')
39
- end
40
-
41
- it "doesn't prepend a slash if one is already there" do
42
- OpenApiIpifyClient.configure { |c| c.base_path = '/v4/dog' }
43
- expect(OpenApiIpifyClient::Configuration.default.base_path).to eq('/v4/dog')
44
- end
45
-
46
- it "ends up as a blank string if nil" do
47
- OpenApiIpifyClient.configure { |c| c.base_path = nil }
48
- expect(OpenApiIpifyClient::Configuration.default.base_path).to eq('')
49
- end
50
- end
51
- end
52
- end
53
-
54
- describe 'params_encoding in #build_request' do
55
- let(:config) { OpenApiIpifyClient::Configuration.new }
56
- let(:api_client) { OpenApiIpifyClient::ApiClient.new(config) }
57
-
58
- it 'defaults to nil' do
59
- expect(OpenApiIpifyClient::Configuration.default.params_encoding).to eq(nil)
60
- expect(config.params_encoding).to eq(nil)
61
-
62
- request = api_client.build_request(:get, '/test')
63
- expect(request.options[:params_encoding]).to eq(nil)
64
- end
65
-
66
- it 'can be customized' do
67
- config.params_encoding = :multi
68
- request = api_client.build_request(:get, '/test')
69
- expect(request.options[:params_encoding]).to eq(:multi)
70
- end
71
- end
72
-
73
- describe 'timeout in #build_request' do
74
- let(:config) { OpenApiIpifyClient::Configuration.new }
75
- let(:api_client) { OpenApiIpifyClient::ApiClient.new(config) }
76
-
77
- it 'defaults to 0' do
78
- expect(OpenApiIpifyClient::Configuration.default.timeout).to eq(0)
79
- expect(config.timeout).to eq(0)
80
-
81
- request = api_client.build_request(:get, '/test')
82
- expect(request.options[:timeout]).to eq(0)
83
- end
84
-
85
- it 'can be customized' do
86
- config.timeout = 100
87
- request = api_client.build_request(:get, '/test')
88
- expect(request.options[:timeout]).to eq(100)
89
- end
90
- end
91
-
92
-
93
-
94
- describe '#deserialize' do
95
- it "handles Array<Integer>" do
96
- api_client = OpenApiIpifyClient::ApiClient.new
97
- headers = { 'Content-Type' => 'application/json' }
98
- response = double('response', headers: headers, body: '[12, 34]')
99
- data = api_client.deserialize(response, 'Array<Integer>')
100
- expect(data).to be_instance_of(Array)
101
- expect(data).to eq([12, 34])
102
- end
103
-
104
- it 'handles Array<Array<Integer>>' do
105
- api_client = OpenApiIpifyClient::ApiClient.new
106
- headers = { 'Content-Type' => 'application/json' }
107
- response = double('response', headers: headers, body: '[[12, 34], [56]]')
108
- data = api_client.deserialize(response, 'Array<Array<Integer>>')
109
- expect(data).to be_instance_of(Array)
110
- expect(data).to eq([[12, 34], [56]])
111
- end
112
-
113
- it 'handles Hash<String, String>' do
114
- api_client = OpenApiIpifyClient::ApiClient.new
115
- headers = { 'Content-Type' => 'application/json' }
116
- response = double('response', headers: headers, body: '{"message": "Hello"}')
117
- data = api_client.deserialize(response, 'Hash<String, String>')
118
- expect(data).to be_instance_of(Hash)
119
- expect(data).to eq(:message => 'Hello')
120
- end
121
- end
122
-
123
- describe "#object_to_hash" do
124
- it 'ignores nils and includes empty arrays' do
125
- # uncomment below to test object_to_hash for model
126
- # api_client = OpenApiIpifyClient::ApiClient.new
127
- # _model = OpenApiIpifyClient::ModelName.new
128
- # update the model attribute below
129
- # _model.id = 1
130
- # update the expected value (hash) below
131
- # expected = {id: 1, name: '', tags: []}
132
- # expect(api_client.object_to_hash(_model)).to eq(expected)
133
- end
134
- end
135
-
136
- describe '#build_collection_param' do
137
- let(:param) { ['aa', 'bb', 'cc'] }
138
- let(:api_client) { OpenApiIpifyClient::ApiClient.new }
139
-
140
- it 'works for csv' do
141
- expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc')
142
- end
143
-
144
- it 'works for ssv' do
145
- expect(api_client.build_collection_param(param, :ssv)).to eq('aa bb cc')
146
- end
147
-
148
- it 'works for tsv' do
149
- expect(api_client.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc")
150
- end
151
-
152
- it 'works for pipes' do
153
- expect(api_client.build_collection_param(param, :pipes)).to eq('aa|bb|cc')
154
- end
155
-
156
- it 'works for multi' do
157
- expect(api_client.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc'])
158
- end
159
-
160
- it 'fails for invalid collection format' do
161
- expect { api_client.build_collection_param(param, :INVALID) }.to raise_error(RuntimeError, 'unknown collection format: :INVALID')
162
- end
163
- end
164
-
165
- describe '#json_mime?' do
166
- let(:api_client) { OpenApiIpifyClient::ApiClient.new }
167
-
168
- it 'works' do
169
- expect(api_client.json_mime?(nil)).to eq false
170
- expect(api_client.json_mime?('')).to eq false
171
-
172
- expect(api_client.json_mime?('application/json')).to eq true
173
- expect(api_client.json_mime?('application/json; charset=UTF8')).to eq true
174
- expect(api_client.json_mime?('APPLICATION/JSON')).to eq true
175
-
176
- expect(api_client.json_mime?('application/xml')).to eq false
177
- expect(api_client.json_mime?('text/plain')).to eq false
178
- expect(api_client.json_mime?('application/jsonp')).to eq false
179
- end
180
- end
181
-
182
- describe '#select_header_accept' do
183
- let(:api_client) { OpenApiIpifyClient::ApiClient.new }
184
-
185
- it 'works' do
186
- expect(api_client.select_header_accept(nil)).to be_nil
187
- expect(api_client.select_header_accept([])).to be_nil
188
-
189
- expect(api_client.select_header_accept(['application/json'])).to eq('application/json')
190
- expect(api_client.select_header_accept(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
191
- expect(api_client.select_header_accept(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
192
-
193
- expect(api_client.select_header_accept(['application/xml'])).to eq('application/xml')
194
- expect(api_client.select_header_accept(['text/html', 'application/xml'])).to eq('text/html,application/xml')
195
- end
196
- end
197
-
198
- describe '#select_header_content_type' do
199
- let(:api_client) { OpenApiIpifyClient::ApiClient.new }
200
-
201
- it 'works' do
202
- expect(api_client.select_header_content_type(nil)).to be_nil
203
- expect(api_client.select_header_content_type([])).to be_nil
204
-
205
- expect(api_client.select_header_content_type(['application/json'])).to eq('application/json')
206
- expect(api_client.select_header_content_type(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
207
- expect(api_client.select_header_content_type(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
208
- expect(api_client.select_header_content_type(['application/xml'])).to eq('application/xml')
209
- expect(api_client.select_header_content_type(['text/plain', 'application/xml'])).to eq('text/plain')
210
- end
211
- end
212
-
213
- describe '#sanitize_filename' do
214
- let(:api_client) { OpenApiIpifyClient::ApiClient.new }
215
-
216
- it 'works' do
217
- expect(api_client.sanitize_filename('sun')).to eq('sun')
218
- expect(api_client.sanitize_filename('sun.gif')).to eq('sun.gif')
219
- expect(api_client.sanitize_filename('../sun.gif')).to eq('sun.gif')
220
- expect(api_client.sanitize_filename('/var/tmp/sun.gif')).to eq('sun.gif')
221
- expect(api_client.sanitize_filename('./sun.gif')).to eq('sun.gif')
222
- expect(api_client.sanitize_filename('..\sun.gif')).to eq('sun.gif')
223
- expect(api_client.sanitize_filename('\var\tmp\sun.gif')).to eq('sun.gif')
224
- expect(api_client.sanitize_filename('c:\var\tmp\sun.gif')).to eq('sun.gif')
225
- expect(api_client.sanitize_filename('.\sun.gif')).to eq('sun.gif')
226
- end
227
- end
228
- end
@@ -1,42 +0,0 @@
1
- =begin
2
- #openapi-ipify
3
-
4
- #OpenAPI client for ipify, a simple public IP address API
5
-
6
- The version of the OpenAPI document: 5.0.0
7
- Contact: blah@cliffano.com
8
- Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 7.0.0
10
-
11
- =end
12
-
13
- require 'spec_helper'
14
-
15
- describe OpenApiIpifyClient::Configuration do
16
- let(:config) { OpenApiIpifyClient::Configuration.default }
17
-
18
- before(:each) do
19
- # uncomment below to setup host and base_path
20
- # require 'URI'
21
- # uri = URI.parse("https://api.ipify.org")
22
- # OpenApiIpifyClient.configure do |c|
23
- # c.host = uri.host
24
- # c.base_path = uri.path
25
- # end
26
- end
27
-
28
- describe '#base_url' do
29
- it 'should have the default value' do
30
- # uncomment below to test default value of the base path
31
- # expect(config.base_url).to eq("https://api.ipify.org")
32
- end
33
-
34
- it 'should remove trailing slashes' do
35
- [nil, '', '/', '//'].each do |base_path|
36
- config.base_path = base_path
37
- # uncomment below to test trailing slashes
38
- # expect(config.base_url).to eq("https://api.ipify.org")
39
- end
40
- end
41
- end
42
- end