openapi_parser 2.2.5 → 2.3.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/.github/workflows/ci.yaml +1 -1
- data/CHANGELOG.md +8 -0
- data/lib/openapi_parser/schema_validator/all_of_validator.rb +2 -2
- data/lib/openapi_parser/schema_validator/object_validator.rb +6 -3
- data/lib/openapi_parser/schema_validator/options.rb +3 -2
- data/lib/openapi_parser/schemas/response.rb +1 -1
- data/lib/openapi_parser/version.rb +1 -1
- data/openapi_parser.gemspec +1 -1
- metadata +5 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7f08706ff7f3eeb957f73f1352879e4234c0c2cb5a2906a12ace5e75c0517d3
|
4
|
+
data.tar.gz: 9267f25fcfa1cb600b0373980a011086b2b70ceefba042658b4a20d80c57b851
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a9213679b51be326c333e040f3de339d6aec2e1c74de0efa685f685da8846ca1b09926829177c62c4ebdc5a877b528919ad2a9a293179fe20d45cfd5f01e3c4
|
7
|
+
data.tar.gz: f9e3d895124ccfeb70fabc1a0ee22395fc38ff2c1447b6529d996adb5cedaa87b924028db4b07ee1e1aeabaab799906dfc488126e3cb8ac4439152ac34f4ff8d
|
data/.github/workflows/ci.yaml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
## Unreleased
|
2
2
|
|
3
|
+
## 2.3.0 (2025-10-01)
|
4
|
+
* bump base64 dep
|
5
|
+
* bump actions checkout dep
|
6
|
+
* improvements for additionalProperties validation #187
|
7
|
+
|
8
|
+
## 2.2.6 (2025-04-07)
|
9
|
+
* support validator options and allow_empty_date_and_datetime for response validate options #183
|
10
|
+
|
3
11
|
## 2.2.5 (2025-04-05)
|
4
12
|
* add allow_empty_date_and_datetime option for more lenient format parsing #182
|
5
13
|
|
@@ -9,7 +9,7 @@ class OpenAPIParser::SchemaValidator
|
|
9
9
|
return [value, nil]
|
10
10
|
end
|
11
11
|
|
12
|
-
# if any schema return error, it's not
|
12
|
+
# if any schema return error, it's not a valid all_of
|
13
13
|
remaining_keys = value.kind_of?(Hash) ? value.keys : []
|
14
14
|
nested_additional_properties = false
|
15
15
|
schema.all_of.each do |s|
|
@@ -32,7 +32,7 @@ class OpenAPIParser::SchemaValidator
|
|
32
32
|
return [nil, err] if err
|
33
33
|
end
|
34
34
|
|
35
|
-
# If there are nested
|
35
|
+
# If there are nested additionalProperties, we allow not defined extra properties and lean on the specific
|
36
36
|
# additionalProperties validation
|
37
37
|
if !nested_additional_properties && !remaining_keys.empty?
|
38
38
|
return [nil, OpenAPIParser::NotExistPropertyDefinition.new(remaining_keys, schema.object_reference)]
|
@@ -10,6 +10,7 @@ class OpenAPIParser::SchemaValidator
|
|
10
10
|
return OpenAPIParser::ValidateError.build_error_result(value, schema) unless value.kind_of?(Hash)
|
11
11
|
|
12
12
|
properties = schema.properties || {}
|
13
|
+
additional_properties = schema.additional_properties
|
13
14
|
|
14
15
|
required_set = schema.required ? schema.required.to_set : Set.new
|
15
16
|
remaining_keys = value.keys
|
@@ -29,9 +30,11 @@ class OpenAPIParser::SchemaValidator
|
|
29
30
|
coerced, err = if s
|
30
31
|
remaining_keys.delete(name)
|
31
32
|
validatable.validate_schema(v, s)
|
33
|
+
# TODO: better handling for parent_all_of with additional_properties
|
34
|
+
elsif !parent_all_of && additional_properties.is_a?(OpenAPIParser::Schemas::Schema)
|
35
|
+
remaining_keys.delete(name)
|
36
|
+
validatable.validate_schema(v, additional_properties)
|
32
37
|
else
|
33
|
-
# TODO: we need to perform a validation based on schema.additional_properties here, if
|
34
|
-
# additionalProperties are defined
|
35
38
|
[v, nil]
|
36
39
|
end
|
37
40
|
|
@@ -43,7 +46,7 @@ class OpenAPIParser::SchemaValidator
|
|
43
46
|
|
44
47
|
remaining_keys.delete(discriminator_property_name) if discriminator_property_name
|
45
48
|
|
46
|
-
if !remaining_keys.empty? && !parent_all_of && !
|
49
|
+
if !remaining_keys.empty? && !parent_all_of && !additional_properties
|
47
50
|
# If object is nested in all of, the validation is already done in allOf validator. Or if
|
48
51
|
# additionalProperties are defined, we will validate using that
|
49
52
|
return [nil, OpenAPIParser::NotExistPropertyDefinition.new(remaining_keys, schema.object_reference)]
|
@@ -22,9 +22,10 @@ class OpenAPIParser::SchemaValidator
|
|
22
22
|
class ResponseValidateOptions
|
23
23
|
# @!attribute [r] strict
|
24
24
|
# @return [Boolean] validate by strict (when not exist definition, raise error)
|
25
|
-
attr_reader :strict, :validate_header
|
25
|
+
attr_reader :strict, :validate_header, :validator_options
|
26
26
|
|
27
|
-
def initialize(strict: false, validate_header: true)
|
27
|
+
def initialize(strict: false, validate_header: true, **validator_options)
|
28
|
+
@validator_options = validator_options
|
28
29
|
@strict = strict
|
29
30
|
@validate_header = validate_header
|
30
31
|
end
|
@@ -28,7 +28,7 @@ module OpenAPIParser::Schemas
|
|
28
28
|
return true
|
29
29
|
end
|
30
30
|
|
31
|
-
options = ::OpenAPIParser::SchemaValidator::Options.new
|
31
|
+
options = ::OpenAPIParser::SchemaValidator::Options.new(**response_validate_options.validator_options)
|
32
32
|
media_type.validate_parameter(response_body.response_data, options)
|
33
33
|
end
|
34
34
|
|
data/openapi_parser.gemspec
CHANGED
@@ -36,5 +36,5 @@ Gem::Specification.new do |spec|
|
|
36
36
|
spec.add_development_dependency 'simplecov'
|
37
37
|
spec.add_development_dependency "steep"
|
38
38
|
# for steep + ruby-head
|
39
|
-
spec.add_development_dependency 'base64', '~> 0.
|
39
|
+
spec.add_development_dependency 'base64', '~> 0.3.0'
|
40
40
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openapi_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ota42y
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: bundler
|
@@ -114,14 +113,14 @@ dependencies:
|
|
114
113
|
requirements:
|
115
114
|
- - "~>"
|
116
115
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0.
|
116
|
+
version: 0.3.0
|
118
117
|
type: :development
|
119
118
|
prerelease: false
|
120
119
|
version_requirements: !ruby/object:Gem::Requirement
|
121
120
|
requirements:
|
122
121
|
- - "~>"
|
123
122
|
- !ruby/object:Gem::Version
|
124
|
-
version: 0.
|
123
|
+
version: 0.3.0
|
125
124
|
description: parser for OpenAPI 3.0 or later
|
126
125
|
email:
|
127
126
|
- ota42y@gmail.com
|
@@ -225,7 +224,6 @@ homepage: https://github.com/ota42y/openapi_parser
|
|
225
224
|
licenses:
|
226
225
|
- MIT
|
227
226
|
metadata: {}
|
228
|
-
post_install_message:
|
229
227
|
rdoc_options: []
|
230
228
|
require_paths:
|
231
229
|
- lib
|
@@ -240,8 +238,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
240
238
|
- !ruby/object:Gem::Version
|
241
239
|
version: '0'
|
242
240
|
requirements: []
|
243
|
-
rubygems_version: 3.
|
244
|
-
signing_key:
|
241
|
+
rubygems_version: 3.6.9
|
245
242
|
specification_version: 4
|
246
243
|
summary: OpenAPI3 parser
|
247
244
|
test_files: []
|