apia 3.9.0 → 3.10.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/lib/apia/cors.rb +5 -5
- data/lib/apia/definitions/field.rb +14 -2
- data/lib/apia/dsls/concerns/has_fields.rb +1 -0
- data/lib/apia/dsls/field.rb +4 -0
- data/lib/apia/schema/field_schema_type.rb +3 -0
- data/lib/apia/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3aacd55e16d85ac583d7b03ecf16a404174b41cc39c9ddd836157845b7ff5b44
|
|
4
|
+
data.tar.gz: de3681316508f67bc6a605b99a2cc2d3024daa94de7f99859aba55b326dfb78b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a19a5124b419464ba1e7577df5fc7b8b68d149233e55a20bc5e8230bff989c5eeb8a861c2f39dcebea76e2e6d6dd9a05ba31006bfd92370b10ab9093676f4534
|
|
7
|
+
data.tar.gz: 5a921f878a7586db2ba33d525390297f23e6e5b97b9a66809c127d1c30f1c050ae2bbcc06e0b865292679db6145f01d820de497fa9f33bada643ac1e014e050c
|
data/lib/apia/cors.rb
CHANGED
|
@@ -17,18 +17,18 @@ module Apia
|
|
|
17
17
|
return {} if @origin.nil?
|
|
18
18
|
|
|
19
19
|
headers = {}
|
|
20
|
-
headers['
|
|
20
|
+
headers['access-control-allow-origin'] = @origin
|
|
21
21
|
|
|
22
22
|
if @methods.is_a?(String)
|
|
23
|
-
headers['
|
|
23
|
+
headers['access-control-allow-methods'] = @methods
|
|
24
24
|
elsif @methods.is_a?(Array) && @methods.any?
|
|
25
|
-
headers['
|
|
25
|
+
headers['access-control-allow-methods'] = @methods.map(&:upcase).join(', ')
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
if @headers.is_a?(String)
|
|
29
|
-
headers['
|
|
29
|
+
headers['access-control-allow-headers'] = @headers
|
|
30
30
|
elsif @headers.is_a?(Array) && @headers.any?
|
|
31
|
-
headers['
|
|
31
|
+
headers['access-control-allow-headers'] = @headers.join(', ')
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
headers
|
|
@@ -15,6 +15,7 @@ module Apia
|
|
|
15
15
|
attr_accessor :backend
|
|
16
16
|
attr_accessor :array
|
|
17
17
|
attr_accessor :null
|
|
18
|
+
attr_accessor :skip_if_null
|
|
18
19
|
attr_accessor :condition
|
|
19
20
|
attr_writer :type
|
|
20
21
|
attr_accessor :include
|
|
@@ -38,6 +39,13 @@ module Apia
|
|
|
38
39
|
@null == true
|
|
39
40
|
end
|
|
40
41
|
|
|
42
|
+
# Should this field be skipped if the value is null?
|
|
43
|
+
#
|
|
44
|
+
# @return [Boolean]
|
|
45
|
+
def skip_if_null?
|
|
46
|
+
@skip_if_null == true
|
|
47
|
+
end
|
|
48
|
+
|
|
41
49
|
# Is the result from this field expected to be an array?
|
|
42
50
|
#
|
|
43
51
|
# @return [Boolean]
|
|
@@ -83,8 +91,12 @@ module Apia
|
|
|
83
91
|
def value(object, request: nil, path: [])
|
|
84
92
|
raw_value = raw_value_from_object(object)
|
|
85
93
|
|
|
86
|
-
|
|
87
|
-
|
|
94
|
+
if raw_value.nil?
|
|
95
|
+
return :skip if skip_if_null?
|
|
96
|
+
return nil if null?
|
|
97
|
+
|
|
98
|
+
raise Apia::NullFieldValueError.new(self, object)
|
|
99
|
+
end
|
|
88
100
|
|
|
89
101
|
if array? && raw_value.is_a?(Array)
|
|
90
102
|
raw_value.map { |v| type.cast(v, request: request, path: path) }
|
|
@@ -22,6 +22,7 @@ module Apia
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
field.null = options[:null] if options.key?(:null)
|
|
25
|
+
field.skip_if_null = options[:skip_if_null] if options.key?(:skip_if_null)
|
|
25
26
|
field.array = options[:array] if options.key?(:array)
|
|
26
27
|
field.include = options[:include] if options.key?(:include)
|
|
27
28
|
field.backend = options[:backend] if options.key?(:backend)
|
data/lib/apia/dsls/field.rb
CHANGED
data/lib/apia/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: apia
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.10.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Adam Cooke
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-03-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: base64
|