haveapi 0.27.1 → 0.27.2
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/haveapi.gemspec +1 -1
- data/lib/haveapi/parameters/typed.rb +5 -0
- data/lib/haveapi/version.rb +1 -1
- data/spec/parameters/typed_spec.rb +15 -3
- data/test_support/client_test_api.rb +48 -0
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 33a06b199d36331bf03d273d528e62fad7a0fa96e78667afa3d8411734e8d966
|
|
4
|
+
data.tar.gz: 94c99822c1b06670ea2623b9faa8c9d22bc7fdfd1be9e3a7d4fb09928f812395
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e473cd23de9122f5e817bafbaf24147a2c67b5d311a37c690d7b474d09647e7b4b0ea6f7104f99377ca8534e352b274dcaa7403a67b3dce2dfd510a7ab75fe7a
|
|
7
|
+
data.tar.gz: c7f8b6f1ffbcf9b8f299e8ce487b8959cc631b98ac3c7b53e508ada38a3191d687b5772c8fd84eac0a14359b70ac182c98859976d81e0cacebfb2a5c436e6b5e
|
data/haveapi.gemspec
CHANGED
|
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
|
|
|
15
15
|
s.required_ruby_version = ">= #{File.read('../../.ruby-version').strip}"
|
|
16
16
|
|
|
17
17
|
s.add_dependency 'activesupport', '>= 7.1'
|
|
18
|
-
s.add_dependency 'haveapi-client', '~> 0.27.
|
|
18
|
+
s.add_dependency 'haveapi-client', '~> 0.27.2'
|
|
19
19
|
s.add_dependency 'json'
|
|
20
20
|
s.add_dependency 'mail'
|
|
21
21
|
s.add_dependency 'nesty', '~> 1.0'
|
data/lib/haveapi/version.rb
CHANGED
|
@@ -78,22 +78,28 @@ describe 'Parameters::Typed' do
|
|
|
78
78
|
expect(p.clean(12.0)).to eq(12)
|
|
79
79
|
expect { p.clean('abc') }.to raise_error(HaveAPI::ValidationError)
|
|
80
80
|
expect { p.clean('12abc') }.to raise_error(HaveAPI::ValidationError)
|
|
81
|
-
expect
|
|
81
|
+
expect(p.clean('')).to be_nil
|
|
82
82
|
expect { p.clean('12.0') }.to raise_error(HaveAPI::ValidationError)
|
|
83
83
|
expect { p.clean(12.3) }.to raise_error(HaveAPI::ValidationError)
|
|
84
84
|
expect { p.clean(true) }.to raise_error(HaveAPI::ValidationError)
|
|
85
85
|
|
|
86
|
+
p = p_arg(type: Integer, required: true)
|
|
87
|
+
expect { p.clean('') }.to raise_error(HaveAPI::ValidationError)
|
|
88
|
+
|
|
86
89
|
# Float
|
|
87
90
|
p = p_type(Float)
|
|
88
91
|
expect(p.clean('3.1456')).to eq(3.1456)
|
|
89
92
|
expect(p.clean('1e3')).to eq(1000.0)
|
|
90
93
|
expect(p.clean(3)).to eq(3.0)
|
|
91
94
|
expect { p.clean('abc') }.to raise_error(HaveAPI::ValidationError)
|
|
92
|
-
expect
|
|
95
|
+
expect(p.clean('')).to be_nil
|
|
93
96
|
expect { p.clean('NaN') }.to raise_error(HaveAPI::ValidationError)
|
|
94
97
|
expect { p.clean(Float::NAN) }.to raise_error(HaveAPI::ValidationError)
|
|
95
98
|
expect { p.clean(Float::INFINITY) }.to raise_error(HaveAPI::ValidationError)
|
|
96
99
|
|
|
100
|
+
p = p_arg(type: Float, required: true)
|
|
101
|
+
expect { p.clean('') }.to raise_error(HaveAPI::ValidationError)
|
|
102
|
+
|
|
97
103
|
# Boolean
|
|
98
104
|
p = p_type(Boolean)
|
|
99
105
|
|
|
@@ -109,9 +115,12 @@ describe 'Parameters::Typed' do
|
|
|
109
115
|
expect(p.clean(1)).to be true
|
|
110
116
|
expect(p.clean(' YES ')).to be true
|
|
111
117
|
expect { p.clean('maybe') }.to raise_error(HaveAPI::ValidationError)
|
|
112
|
-
expect
|
|
118
|
+
expect(p.clean('')).to be_nil
|
|
113
119
|
expect { p.clean(2) }.to raise_error(HaveAPI::ValidationError)
|
|
114
120
|
|
|
121
|
+
p = p_arg(type: Boolean, required: true)
|
|
122
|
+
expect { p.clean('') }.to raise_error(HaveAPI::ValidationError)
|
|
123
|
+
|
|
115
124
|
# Datetime
|
|
116
125
|
p = p_type(Datetime)
|
|
117
126
|
t = Time.now
|
|
@@ -119,6 +128,9 @@ describe 'Parameters::Typed' do
|
|
|
119
128
|
|
|
120
129
|
expect(p.clean(t.iso8601)).to eq(t2)
|
|
121
130
|
expect { p.clean('bzz') }.to raise_error(HaveAPI::ValidationError)
|
|
131
|
+
expect(p.clean('')).to be_nil
|
|
132
|
+
|
|
133
|
+
p = p_arg(type: Datetime, required: true)
|
|
122
134
|
expect { p.clean('') }.to raise_error(HaveAPI::ValidationError)
|
|
123
135
|
|
|
124
136
|
# String, Text
|
|
@@ -457,6 +457,54 @@ module HaveAPI
|
|
|
457
457
|
end
|
|
458
458
|
end
|
|
459
459
|
|
|
460
|
+
define_action(:EchoOptional) do
|
|
461
|
+
extend DocFilter
|
|
462
|
+
route 'echo_optional'
|
|
463
|
+
http_method :post
|
|
464
|
+
input(:hash) do
|
|
465
|
+
datetime :dt, required: false
|
|
466
|
+
end
|
|
467
|
+
output(:hash) do
|
|
468
|
+
bool :dt_provided, required: true
|
|
469
|
+
bool :dt_nil, required: true
|
|
470
|
+
datetime :dt
|
|
471
|
+
end
|
|
472
|
+
authorize { allow }
|
|
473
|
+
|
|
474
|
+
def exec
|
|
475
|
+
ret = {
|
|
476
|
+
dt_provided: input.has_key?(:dt),
|
|
477
|
+
dt_nil: input[:dt].nil?
|
|
478
|
+
}
|
|
479
|
+
ret[:dt] = input[:dt] unless input[:dt].nil?
|
|
480
|
+
ret
|
|
481
|
+
end
|
|
482
|
+
end
|
|
483
|
+
|
|
484
|
+
define_action(:EchoOptionalGet) do
|
|
485
|
+
extend DocFilter
|
|
486
|
+
route 'echo_optional_get'
|
|
487
|
+
http_method :get
|
|
488
|
+
input(:hash) do
|
|
489
|
+
datetime :dt, required: false
|
|
490
|
+
end
|
|
491
|
+
output(:hash) do
|
|
492
|
+
bool :dt_provided, required: true
|
|
493
|
+
bool :dt_nil, required: true
|
|
494
|
+
datetime :dt
|
|
495
|
+
end
|
|
496
|
+
authorize { allow }
|
|
497
|
+
|
|
498
|
+
def exec
|
|
499
|
+
ret = {
|
|
500
|
+
dt_provided: input.has_key?(:dt),
|
|
501
|
+
dt_nil: input[:dt].nil?
|
|
502
|
+
}
|
|
503
|
+
ret[:dt] = input[:dt] unless input[:dt].nil?
|
|
504
|
+
ret
|
|
505
|
+
end
|
|
506
|
+
end
|
|
507
|
+
|
|
460
508
|
define_action(:EchoResource) do
|
|
461
509
|
extend DocFilter
|
|
462
510
|
route 'echo_resource'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: haveapi
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.27.
|
|
4
|
+
version: 0.27.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jakub Skokan
|
|
@@ -29,14 +29,14 @@ dependencies:
|
|
|
29
29
|
requirements:
|
|
30
30
|
- - "~>"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: 0.27.
|
|
32
|
+
version: 0.27.2
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: 0.27.
|
|
39
|
+
version: 0.27.2
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
41
|
name: json
|
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|