openapi_ipify 4.0.0 → 5.1.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: 9c5eda89a756f4fdcbe5c9b8117b1fa36d607bfa44c946c8830fca7b639b443b
4
- data.tar.gz: 220a0edc6c6ce1bd95a8e5eb1e7a669beaca81bdc83ed1d125af1ec0983ed590
3
+ metadata.gz: f38a1b17d7ddec87c8a64d2864c7423540bb41fe341686459f49748c25c0ea7c
4
+ data.tar.gz: e6ca89a27a5449e1695bf7858e1ba8413f5a1a25f8043f4cdb626594c7d7aead
5
5
  SHA512:
6
- metadata.gz: 1168ecdaabf9f51dfbfd2d18aa9f8f38c7a820e17269cb73da2d67308847896d848c9b239ad6002c24cd04dcf52b26c4dd9a91760192e7f6e99a6754d37aef64
7
- data.tar.gz: 3aa98ef500c14728772eaf9ae298ddc45ccd14b24c04a1c3261a08550e058ec2872b8f20bacd1f49ac198474e2f0ee9e7ddc46befa8d20210f6218b87849d6ca
6
+ metadata.gz: 52e858c0bf2c093c36e0f07e5f692ad955e4832d80c2b90bc21a1b691862358e9bfc23019260bb0a8fc279e24414a05796f96fd9e06c48f1ac6f0b81721c6b0a
7
+ data.tar.gz: 4a379b5cc3ae2e12e253d7670f8c5e21452a70e2f2cb7d22e00e5cacb2fcc207986fd1de6f6236b5fbed2184925662b276695564dee8ae1788a9894368218735
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openapi_ipify (4.0.0)
4
+ openapi_ipify (5.1.0)
5
5
  typhoeus (~> 1.0, >= 1.0.1)
6
6
 
7
7
  GEM
@@ -13,11 +13,11 @@ GEM
13
13
  diff-lcs (1.5.0)
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.1)
21
21
  ast (~> 2.4.1)
22
22
  racc
23
23
  pry (0.14.2)
@@ -26,9 +26,9 @@ 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
34
  rspec (3.12.0)
@@ -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.7)
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.20
data/README.md CHANGED
@@ -6,8 +6,8 @@ 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: 4.0.0
10
- - Package version: 4.0.0
9
+ - API version: 5.1.0
10
+ - Package version: 5.1.0
11
11
  - Build package: org.openapitools.codegen.languages.RubyClientCodegen
12
12
  For more information, please visit [https://github.com/cliffano/openapi-ipify](https://github.com/cliffano/openapi-ipify)
13
13
 
@@ -24,22 +24,22 @@ gem build openapi_ipify.gemspec
24
24
  Then either install the gem locally:
25
25
 
26
26
  ```shell
27
- gem install ./openapi_ipify-4.0.0.gem
27
+ gem install ./openapi_ipify-5.1.0.gem
28
28
  ```
29
29
 
30
- (for development, run `gem install --dev ./openapi_ipify-4.0.0.gem` to install the development dependencies)
30
+ (for development, run `gem install --dev ./openapi_ipify-5.1.0.gem` to install the development dependencies)
31
31
 
32
32
  or publish the gem to a gem hosting service, e.g. [RubyGems](https://rubygems.org/).
33
33
 
34
34
  Finally add this to the Gemfile:
35
35
 
36
- gem 'openapi_ipify', '~> 4.0.0'
36
+ gem 'openapi_ipify', '~> 5.1.0'
37
37
 
38
38
  ### Install from Git
39
39
 
40
- If the Ruby gem is hosted at a git repository: https://github.com/GIT_USER_ID/GIT_REPO_ID, then add the following in the Gemfile:
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
41
 
42
- gem 'openapi_ipify', :git => 'https://github.com/GIT_USER_ID/GIT_REPO_ID.git'
42
+ gem 'openapi_ipify', :git => 'https://github.com/cliffano/openapi-ipify.git'
43
43
 
44
44
  ### Include the Ruby code directly
45
45
 
data/git_push.sh CHANGED
@@ -14,12 +14,12 @@ if [ "$git_host" = "" ]; then
14
14
  fi
15
15
 
16
16
  if [ "$git_user_id" = "" ]; then
17
- git_user_id="GIT_USER_ID"
17
+ git_user_id="cliffano"
18
18
  echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
19
19
  fi
20
20
 
21
21
  if [ "$git_repo_id" = "" ]; then
22
- git_repo_id="GIT_REPO_ID"
22
+ git_repo_id="openapi-ipify"
23
23
  echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
24
24
  fi
25
25
 
@@ -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: 4.0.0
6
+ The version of the OpenAPI document: 5.1.0
7
7
  Contact: blah@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.6.0
9
+ OpenAPI Generator version: 7.2.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: 4.0.0
6
+ The version of the OpenAPI document: 5.1.0
7
7
  Contact: blah@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.6.0
9
+ OpenAPI Generator version: 7.2.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: 4.0.0
6
+ The version of the OpenAPI document: 5.1.0
7
7
  Contact: blah@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.6.0
9
+ OpenAPI Generator version: 7.2.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: 4.0.0
6
+ The version of the OpenAPI document: 5.1.0
7
7
  Contact: blah@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.6.0
9
+ OpenAPI Generator version: 7.2.0
10
10
 
11
11
  =end
12
12
 
@@ -152,7 +152,7 @@ module OpenApiIpifyClient
152
152
  @scheme = 'https'
153
153
  @host = 'api.ipify.org'
154
154
  @base_path = ''
155
- @server_index = 0
155
+ @server_index = nil
156
156
  @server_operation_index = {}
157
157
  @server_variables = {}
158
158
  @server_operation_variables = {}
@@ -200,10 +200,12 @@ module OpenApiIpifyClient
200
200
 
201
201
  # Returns base URL for specified operation based on server settings
202
202
  def base_url(operation = nil)
203
- index = server_operation_index[operation]
204
- return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if index == nil
205
-
206
- server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
203
+ if operation_server_settings.key?(operation) then
204
+ index = server_operation_index.fetch(operation, server_index)
205
+ server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
206
+ else
207
+ server_index.nil? ? "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') : server_url(server_index, server_variables, nil)
208
+ end
207
209
  end
208
210
 
209
211
  # Gets API key (with prefix if set).
@@ -220,8 +222,8 @@ module OpenApiIpifyClient
220
222
 
221
223
  # Gets access_token using access_token_getter or uses the static access_token
222
224
  def access_token_with_refresh
223
- return access_token if access_token_getter.nil?
224
- access_token_getter.call
225
+ return access_token if access_token_getter.nil?
226
+ access_token_getter.call
225
227
  end
226
228
 
227
229
  # Gets Basic Auth token string
@@ -258,8 +260,8 @@ module OpenApiIpifyClient
258
260
  servers = server_settings if servers == nil
259
261
 
260
262
  # check array index out of bound
261
- if (index < 0 || index >= servers.size)
262
- fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
263
+ if (index.nil? || index < 0 || index >= servers.size)
264
+ fail ArgumentError, "Invalid index #{index} when selecting the server. Must not be nil and must be less than #{servers.size}"
263
265
  end
264
266
 
265
267
  server = servers[index]
@@ -284,5 +286,6 @@ module OpenApiIpifyClient
284
286
  url
285
287
  end
286
288
 
289
+
287
290
  end
288
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: 4.0.0
6
+ The version of the OpenAPI document: 5.1.0
7
7
  Contact: blah@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.6.0
9
+ OpenAPI Generator version: 7.2.0
10
10
 
11
11
  =end
12
12
 
@@ -59,12 +59,15 @@ module OpenApiIpifyClient
59
59
 
60
60
  if attributes.key?(:'ip')
61
61
  self.ip = attributes[:'ip']
62
+ else
63
+ self.ip = nil
62
64
  end
63
65
  end
64
66
 
65
67
  # Show invalid properties with the reasons. Usually used together with valid?
66
68
  # @return Array for valid properties with the reasons
67
69
  def list_invalid_properties
70
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
68
71
  invalid_properties = Array.new
69
72
  if @ip.nil?
70
73
  invalid_properties.push('invalid value for "ip", ip cannot be nil.')
@@ -76,6 +79,7 @@ module OpenApiIpifyClient
76
79
  # Check to see if the all the properties in the model are valid
77
80
  # @return true if the model is valid
78
81
  def valid?
82
+ warn '[DEPRECATED] the `valid?` method is obsolete'
79
83
  return false if @ip.nil?
80
84
  true
81
85
  end
@@ -104,37 +108,30 @@ module OpenApiIpifyClient
104
108
  # @param [Hash] attributes Model attributes in the form of hash
105
109
  # @return [Object] Returns the model itself
106
110
  def self.build_from_hash(attributes)
107
- new.build_from_hash(attributes)
108
- end
109
-
110
- # Builds the object from hash
111
- # @param [Hash] attributes Model attributes in the form of hash
112
- # @return [Object] Returns the model itself
113
- def build_from_hash(attributes)
114
111
  return nil unless attributes.is_a?(Hash)
115
112
  attributes = attributes.transform_keys(&:to_sym)
116
- self.class.openapi_types.each_pair do |key, type|
117
- if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
118
- self.send("#{key}=", nil)
113
+ transformed_hash = {}
114
+ openapi_types.each_pair do |key, type|
115
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
116
+ transformed_hash["#{key}"] = nil
119
117
  elsif type =~ /\AArray<(.*)>/i
120
118
  # check to ensure the input is an array given that the attribute
121
119
  # is documented as an array but the input is not
122
- if attributes[self.class.attribute_map[key]].is_a?(Array)
123
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
120
+ if attributes[attribute_map[key]].is_a?(Array)
121
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
124
122
  end
125
- elsif !attributes[self.class.attribute_map[key]].nil?
126
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
123
+ elsif !attributes[attribute_map[key]].nil?
124
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
127
125
  end
128
126
  end
129
-
130
- self
127
+ new(transformed_hash)
131
128
  end
132
129
 
133
130
  # Deserializes the data based on type
134
131
  # @param string type Data type
135
132
  # @param string value Value to be deserialized
136
133
  # @return [Object] Deserialized data
137
- def _deserialize(type, value)
134
+ def self._deserialize(type, value)
138
135
  case type.to_sym
139
136
  when :Time
140
137
  Time.parse(value)
@@ -169,7 +166,7 @@ module OpenApiIpifyClient
169
166
  else # model
170
167
  # models (e.g. Pet) or oneOf
171
168
  klass = OpenApiIpifyClient.const_get(type)
172
- 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)
173
170
  end
174
171
  end
175
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: 4.0.0
6
+ The version of the OpenAPI document: 5.1.0
7
7
  Contact: blah@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.6.0
9
+ OpenAPI Generator version: 7.2.0
10
10
 
11
11
  =end
12
12
 
13
13
  module OpenApiIpifyClient
14
- VERSION = '4.0.0'
14
+ VERSION = '5.1.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: 4.0.0
6
+ The version of the OpenAPI document: 5.1.0
7
7
  Contact: blah@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.6.0
9
+ OpenAPI Generator version: 7.2.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: 4.0.0
8
+ The version of the OpenAPI document: 5.1.0
9
9
  Contact: blah@cliffano.com
10
10
  Generated by: https://openapi-generator.tech
11
- OpenAPI Generator version: 6.6.0
11
+ OpenAPI Generator version: 7.2.0
12
12
 
13
13
  =end
14
14
 
@@ -26,6 +26,7 @@ Gem::Specification.new do |s|
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: 4.0.0
6
+ The version of the OpenAPI document: 5.1.0
7
7
  Contact: blah@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.6.0
9
+ OpenAPI Generator version: 7.2.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: 4.0.0
6
+ The version of the OpenAPI document: 5.1.0
7
7
  Contact: blah@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.6.0
9
+ OpenAPI Generator version: 7.2.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: 4.0.0
6
+ The version of the OpenAPI document: 5.1.0
7
7
  Contact: blah@cliffano.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.6.0
9
+ OpenAPI Generator version: 7.2.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: 4.0.0
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cliffano Subagio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-05 00:00:00.000000000 Z
11
+ date: 2024-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus
@@ -85,8 +85,6 @@ 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
90
  homepage: https://github.com/cliffano/openapi-ipify
@@ -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: 4.0.0
7
- Contact: blah@cliffano.com
8
- Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.6.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: 4.0.0
7
- Contact: blah@cliffano.com
8
- Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.6.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