openapi_ipify 5.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 +4 -4
- data/Gemfile.lock +9 -9
- data/README.md +5 -5
- data/lib/openapi_ipify/api/default_api.rb +2 -2
- data/lib/openapi_ipify/api_client.rb +24 -22
- data/lib/openapi_ipify/api_error.rb +2 -2
- data/lib/openapi_ipify/configuration.rb +5 -4
- data/lib/openapi_ipify/models/ip.rb +3 -3
- data/lib/openapi_ipify/version.rb +3 -3
- data/lib/openapi_ipify.rb +2 -2
- data/openapi_ipify.gemspec +3 -2
- data/spec/api/default_api_spec.rb +2 -2
- data/spec/models/ip_spec.rb +5 -3
- data/spec/spec_helper.rb +2 -2
- metadata +2 -6
- data/spec/api_client_spec.rb +0 -228
- data/spec/configuration_spec.rb +0 -42
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f38a1b17d7ddec87c8a64d2864c7423540bb41fe341686459f49748c25c0ea7c
|
4
|
+
data.tar.gz: e6ca89a27a5449e1695bf7858e1ba8413f5a1a25f8043f4cdb626594c7d7aead
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 (5.
|
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.
|
16
|
+
ffi (1.16.3)
|
17
17
|
jaro_winkler (1.5.6)
|
18
18
|
method_source (1.0.0)
|
19
|
-
parallel (1.
|
20
|
-
parser (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.
|
29
|
+
psych (5.1.2)
|
30
30
|
stringio
|
31
|
-
racc (1.7.
|
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
|
57
|
-
typhoeus (1.4.
|
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.
|
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: 5.
|
10
|
-
- Package version: 5.
|
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,16 +24,16 @@ gem build openapi_ipify.gemspec
|
|
24
24
|
Then either install the gem locally:
|
25
25
|
|
26
26
|
```shell
|
27
|
-
gem install ./openapi_ipify-5.
|
27
|
+
gem install ./openapi_ipify-5.1.0.gem
|
28
28
|
```
|
29
29
|
|
30
|
-
(for development, run `gem install --dev ./openapi_ipify-5.
|
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', '~> 5.
|
36
|
+
gem 'openapi_ipify', '~> 5.1.0'
|
37
37
|
|
38
38
|
### Install from Git
|
39
39
|
|
@@ -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.
|
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: 7.
|
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: 5.
|
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: 7.
|
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 (
|
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
|
-
|
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
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
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.
|
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: 7.
|
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: 5.
|
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: 7.
|
9
|
+
OpenAPI Generator version: 7.2.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
|
-
|
226
|
-
|
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.
|
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: 7.
|
9
|
+
OpenAPI Generator version: 7.2.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.
|
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: 7.
|
9
|
+
OpenAPI Generator version: 7.2.0
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
13
13
|
module OpenApiIpifyClient
|
14
|
-
VERSION = '5.
|
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: 5.
|
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: 7.
|
9
|
+
OpenAPI Generator version: 7.2.0
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
data/openapi_ipify.gemspec
CHANGED
@@ -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.
|
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: 7.
|
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: 5.
|
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: 7.
|
9
|
+
OpenAPI Generator version: 7.2.0
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
data/spec/models/ip_spec.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.
|
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: 7.
|
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
|
-
|
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.
|
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: 7.
|
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: 5.
|
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:
|
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
|
data/spec/api_client_spec.rb
DELETED
@@ -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
|
data/spec/configuration_spec.rb
DELETED
@@ -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
|