openapi_parser 2.2.4 → 2.2.5
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/CHANGELOG.md +3 -0
- data/lib/openapi_parser/config.rb +6 -1
- data/lib/openapi_parser/schema_validator/options.rb +5 -2
- data/lib/openapi_parser/schema_validator/string_validator.rb +10 -1
- data/lib/openapi_parser/schema_validator.rb +2 -1
- data/lib/openapi_parser/version.rb +1 -1
- data/sig/openapi_parser/config.rbs +2 -0
- data/sig/openapi_parser/schema_validators/options.rbs +2 -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: 4016d11ce844002642120ada572812240bb8565b587af7126666ddc430504a7e
|
4
|
+
data.tar.gz: 4cafef840728490fe310f925220309ce955f81aae5561be19ddd3805e291d6fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78a563d3b37e7b3c1be1930320d24bd12598205d2e4952e19b2af4dc349dd3c91ff887dfb83450cb4dcd9af9667adde554a82d90ee5af67467ec8de54d2a2db1
|
7
|
+
data.tar.gz: 92993b410aa4a2092fea00a8e37ed4724304f5742abb8c9fcf41eb5d094aaace7d0d7aac73766120bac14d502853f43dffc5e005a9470422f09037e4f996fe1b
|
data/CHANGELOG.md
CHANGED
@@ -11,6 +11,10 @@ class OpenAPIParser::Config
|
|
11
11
|
@config = config
|
12
12
|
end
|
13
13
|
|
14
|
+
def allow_empty_date_and_datetime
|
15
|
+
@config.fetch(:allow_empty_date_and_datetime, false)
|
16
|
+
end
|
17
|
+
|
14
18
|
def datetime_coerce_class
|
15
19
|
@config[:datetime_coerce_class]
|
16
20
|
end
|
@@ -39,7 +43,8 @@ class OpenAPIParser::Config
|
|
39
43
|
|
40
44
|
# @return [OpenAPIParser::SchemaValidator::Options]
|
41
45
|
def request_validator_options
|
42
|
-
@request_validator_options ||= OpenAPIParser::SchemaValidator::Options.new(
|
46
|
+
@request_validator_options ||= OpenAPIParser::SchemaValidator::Options.new(allow_empty_date_and_datetime: allow_empty_date_and_datetime,
|
47
|
+
coerce_value: coerce_value,
|
43
48
|
datetime_coerce_class: datetime_coerce_class,
|
44
49
|
validate_header: validate_header)
|
45
50
|
end
|
@@ -1,14 +1,17 @@
|
|
1
1
|
class OpenAPIParser::SchemaValidator
|
2
2
|
class Options
|
3
|
+
# @!attribute [r] allow_empty_date_and_datetime
|
4
|
+
# @return [Boolean] allow empty date and datetime values option on/off
|
3
5
|
# @!attribute [r] coerce_value
|
4
6
|
# @return [Boolean] coerce value option on/off
|
5
7
|
# @!attribute [r] datetime_coerce_class
|
6
8
|
# @return [Object, nil] coerce datetime string by this Object class
|
7
9
|
# @!attribute [r] validate_header
|
8
10
|
# @return [Boolean] validate header or not
|
9
|
-
attr_reader :coerce_value, :datetime_coerce_class, :validate_header
|
11
|
+
attr_reader :allow_empty_date_and_datetime, :coerce_value, :datetime_coerce_class, :validate_header
|
10
12
|
|
11
|
-
def initialize(coerce_value: nil, datetime_coerce_class: nil, validate_header: true)
|
13
|
+
def initialize(allow_empty_date_and_datetime: false, coerce_value: nil, datetime_coerce_class: nil, validate_header: true)
|
14
|
+
@allow_empty_date_and_datetime = allow_empty_date_and_datetime
|
12
15
|
@coerce_value = coerce_value
|
13
16
|
@datetime_coerce_class = datetime_coerce_class
|
14
17
|
@validate_header = validate_header
|
@@ -2,8 +2,9 @@ class OpenAPIParser::SchemaValidator
|
|
2
2
|
class StringValidator < Base
|
3
3
|
include ::OpenAPIParser::SchemaValidator::Enumable
|
4
4
|
|
5
|
-
def initialize(validator, coerce_value, datetime_coerce_class)
|
5
|
+
def initialize(validator, allow_empty_date_and_datetime, coerce_value, datetime_coerce_class)
|
6
6
|
super(validator, coerce_value)
|
7
|
+
@allow_empty_date_and_datetime = allow_empty_date_and_datetime
|
7
8
|
@datetime_coerce_class = datetime_coerce_class
|
8
9
|
end
|
9
10
|
|
@@ -80,6 +81,10 @@ class OpenAPIParser::SchemaValidator
|
|
80
81
|
end
|
81
82
|
|
82
83
|
def validate_date_format(value, schema)
|
84
|
+
if @allow_empty_date_and_datetime && value.to_s.empty?
|
85
|
+
return [value, nil] if schema.format == 'date'
|
86
|
+
end
|
87
|
+
|
83
88
|
return [value, nil] unless schema.format == 'date'
|
84
89
|
|
85
90
|
return [nil, OpenAPIParser::InvalidDateFormat.new(value, schema.object_reference)] unless value =~ /^\d{4}-\d{2}-\d{2}$/
|
@@ -98,6 +103,10 @@ class OpenAPIParser::SchemaValidator
|
|
98
103
|
end
|
99
104
|
|
100
105
|
def validate_datetime_format(value, schema)
|
106
|
+
if @allow_empty_date_and_datetime && value.to_s.empty?
|
107
|
+
return [value, nil] if schema.format == 'date-time'
|
108
|
+
end
|
109
|
+
|
101
110
|
return [value, nil] unless schema.format == 'date-time'
|
102
111
|
|
103
112
|
begin
|
@@ -53,6 +53,7 @@ class OpenAPIParser::SchemaValidator
|
|
53
53
|
def initialize(value, schema, options)
|
54
54
|
@value = value
|
55
55
|
@schema = schema
|
56
|
+
@allow_empty_date_and_datetime = options.allow_empty_date_and_datetime
|
56
57
|
@coerce_value = options.coerce_value
|
57
58
|
@datetime_coerce_class = options.datetime_coerce_class
|
58
59
|
end
|
@@ -120,7 +121,7 @@ class OpenAPIParser::SchemaValidator
|
|
120
121
|
end
|
121
122
|
|
122
123
|
def string_validator
|
123
|
-
@string_validator ||= OpenAPIParser::SchemaValidator::StringValidator.new(self, @coerce_value, @datetime_coerce_class)
|
124
|
+
@string_validator ||= OpenAPIParser::SchemaValidator::StringValidator.new(self, @allow_empty_date_and_datetime, @coerce_value, @datetime_coerce_class)
|
124
125
|
end
|
125
126
|
|
126
127
|
def integer_validator
|
@@ -8,10 +8,12 @@ module OpenAPIParser
|
|
8
8
|
alias path_params_options request_validator_options
|
9
9
|
|
10
10
|
def initialize: (untyped config) -> untyped
|
11
|
+
def allow_empty_date_and_datetime: -> bool
|
11
12
|
def datetime_coerce_class: -> (singleton(Object) | nil)
|
12
13
|
def coerce_value: -> bool
|
13
14
|
def expand_reference: -> bool
|
14
15
|
def strict_response_validation: -> bool
|
16
|
+
def strict_reference_validation: -> bool
|
15
17
|
def validate_header: -> bool
|
16
18
|
def request_validator_options: -> OpenAPIParser::SchemaValidator::Options
|
17
19
|
def response_validate_options: -> OpenAPIParser::SchemaValidator::ResponseValidateOptions
|
@@ -2,10 +2,11 @@
|
|
2
2
|
module OpenAPIParser
|
3
3
|
class SchemaValidator
|
4
4
|
class Options
|
5
|
+
attr_reader allow_empty_date_and_datetime: bool | nil
|
5
6
|
attr_reader coerce_value: bool | nil
|
6
7
|
attr_reader datetime_coerce_class: singleton(Object) | nil
|
7
8
|
attr_reader validate_header: bool
|
8
|
-
def initialize: (?coerce_value: bool | nil, ?datetime_coerce_class: singleton(Object) | nil, ?validate_header: bool) -> untyped
|
9
|
+
def initialize: (?allow_empty_date_and_datetime: bool | nil, ?coerce_value: bool | nil, ?datetime_coerce_class: singleton(Object) | nil, ?validate_header: bool) -> untyped
|
9
10
|
end
|
10
11
|
|
11
12
|
class ResponseValidateOptions
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openapi_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ota42y
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|