openapi_parser 2.0.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +10 -0
- data/.github/workflows/ci.yaml +2 -1
- data/CHANGELOG.md +23 -2
- data/lib/openapi_parser/schema_validator/all_of_validator.rb +0 -17
- data/lib/openapi_parser/schema_validator/object_validator.rb +3 -5
- data/lib/openapi_parser/schema_validator/string_validator.rb +7 -6
- data/lib/openapi_parser/schemas/schema.rb +1 -0
- data/lib/openapi_parser/version.rb +1 -1
- data/lib/openapi_parser.rb +2 -5
- data/openapi_parser.gemspec +2 -3
- metadata +10 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e38224603546bc8818028b725452113a5c3b62811675e1bc7390aeb9b408a2a
|
4
|
+
data.tar.gz: 6e6b0352a64a35d2a71a001931910d7e15ea4aa3a36a5aebee68f2aa6e6b367e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bc8816e1059379a014e2bfc702068edcc31b6adeddb2f3747094314c01df680cf431774d1fb1bb407497501e454ff4b7571e969f83eec19b6276b3de21d302d
|
7
|
+
data.tar.gz: e0819dbee935685d25793da062afb1dd850adeac72ba25efe917a86e46e46fb23e969f02d0402ab39a5111d765e4501ebdb93d679dc36322ddb69cae3bf6dcb8
|
data/.github/workflows/ci.yaml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,31 @@
|
|
1
1
|
## Unreleased
|
2
2
|
|
3
|
-
##
|
3
|
+
## 2.2.0 (2024-10-23)
|
4
|
+
### Fixed
|
5
|
+
* support schemas validation in additionalProperties and remove additionalProperties logic from allof
|
6
|
+
* suppress method redefined warning
|
7
|
+
* add base64 dev dependency for ruby-head compatibility
|
8
|
+
* remove no longer needed activesupport dev dep thanks to a fix upstream
|
9
|
+
* add dependabot config
|
10
|
+
* remove no longer used code for old rubies
|
11
|
+
* bump actions/checkout
|
12
|
+
* add ruby 3.3 to test matrix
|
13
|
+
* fix uuid validation logic (make it more strict)
|
14
|
+
|
15
|
+
## 2.1.0 (2024-04-03)
|
16
|
+
### Fixed
|
17
|
+
* Add full-date compliant date format validation #164
|
18
|
+
|
19
|
+
## 2.0.0 (2023-10-15)
|
20
|
+
|
4
21
|
### Added
|
22
|
+
|
5
23
|
* Support for uniqueItems in array #154
|
6
24
|
* Fix nullable field does not work with allOf, anyOf and oneOf keyword #128
|
7
|
-
|
25
|
+
|
26
|
+
### Other
|
27
|
+
|
28
|
+
* Drop Ruby 2.6 Support #158
|
8
29
|
|
9
30
|
## 1.0.0 (2021-02-03)
|
10
31
|
### Added
|
@@ -10,8 +10,6 @@ class OpenAPIParser::SchemaValidator
|
|
10
10
|
end
|
11
11
|
|
12
12
|
# if any schema return error, it's not valida all of value
|
13
|
-
remaining_keys = value.kind_of?(Hash) ? value.keys : []
|
14
|
-
nested_additional_properties = false
|
15
13
|
schema.all_of.each do |s|
|
16
14
|
# We need to store the reference to all of, so we can perform strict check on allowed properties
|
17
15
|
_coerced, err = validatable.validate_schema(
|
@@ -20,24 +18,9 @@ class OpenAPIParser::SchemaValidator
|
|
20
18
|
:parent_all_of => true,
|
21
19
|
parent_discriminator_schemas: keyword_args[:parent_discriminator_schemas]
|
22
20
|
)
|
23
|
-
|
24
|
-
if s.type == "object"
|
25
|
-
remaining_keys -= (s.properties || {}).keys
|
26
|
-
nested_additional_properties = true if s.additional_properties
|
27
|
-
else
|
28
|
-
# If this is not allOf having array of objects inside, but e.g. having another anyOf/oneOf nested
|
29
|
-
remaining_keys.clear
|
30
|
-
end
|
31
|
-
|
32
21
|
return [nil, err] if err
|
33
22
|
end
|
34
23
|
|
35
|
-
# If there are nested additionalProperites, we allow not defined extra properties and lean on the specific
|
36
|
-
# additionalProperties validation
|
37
|
-
if !nested_additional_properties && !remaining_keys.empty?
|
38
|
-
return [nil, OpenAPIParser::NotExistPropertyDefinition.new(remaining_keys, schema.object_reference)]
|
39
|
-
end
|
40
|
-
|
41
24
|
[value, nil]
|
42
25
|
end
|
43
26
|
end
|
@@ -27,9 +27,9 @@ class OpenAPIParser::SchemaValidator
|
|
27
27
|
coerced, err = if s
|
28
28
|
remaining_keys.delete(name)
|
29
29
|
validatable.validate_schema(v, s)
|
30
|
+
elsif schema.additional_properties != true && schema.additional_properties != false
|
31
|
+
validatable.validate_schema(v, schema.additional_properties)
|
30
32
|
else
|
31
|
-
# TODO: we need to perform a validation based on schema.additional_properties here, if
|
32
|
-
# additionalProperties are defined
|
33
33
|
[v, nil]
|
34
34
|
end
|
35
35
|
|
@@ -41,9 +41,7 @@ class OpenAPIParser::SchemaValidator
|
|
41
41
|
|
42
42
|
remaining_keys.delete(discriminator_property_name) if discriminator_property_name
|
43
43
|
|
44
|
-
if !remaining_keys.empty? && !
|
45
|
-
# If object is nested in all of, the validation is already done in allOf validator. Or if
|
46
|
-
# additionalProperties are defined, we will validate using that
|
44
|
+
if !remaining_keys.empty? && !schema.additional_properties
|
47
45
|
return [nil, OpenAPIParser::NotExistPropertyDefinition.new(remaining_keys, schema.object_reference)]
|
48
46
|
end
|
49
47
|
return [nil, OpenAPIParser::NotExistRequiredKey.new(required_set.to_a, schema.object_reference)] unless required_set.empty?
|
@@ -55,10 +55,7 @@ class OpenAPIParser::SchemaValidator
|
|
55
55
|
def validate_email_format(value, schema)
|
56
56
|
return [value, nil] unless schema.format == 'email'
|
57
57
|
|
58
|
-
|
59
|
-
# So when we drop ruby 2.3 support we use match? method because this method add ruby 2.4
|
60
|
-
#return [value, nil] if value.match?(URI::MailTo::EMAIL_REGEXP)
|
61
|
-
return [value, nil] if value.match(URI::MailTo::EMAIL_REGEXP)
|
58
|
+
return [value, nil] if value.match?(URI::MailTo::EMAIL_REGEXP)
|
62
59
|
|
63
60
|
return [nil, OpenAPIParser::InvalidEmailFormat.new(value, schema.object_reference)]
|
64
61
|
end
|
@@ -66,7 +63,7 @@ class OpenAPIParser::SchemaValidator
|
|
66
63
|
def validate_uuid_format(value, schema)
|
67
64
|
return [value, nil] unless schema.format == 'uuid'
|
68
65
|
|
69
|
-
return [value, nil] if value.match(
|
66
|
+
return [value, nil] if value.match(/^[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}$/)
|
70
67
|
|
71
68
|
return [nil, OpenAPIParser::InvalidUUIDFormat.new(value, schema.object_reference)]
|
72
69
|
end
|
@@ -75,11 +72,15 @@ class OpenAPIParser::SchemaValidator
|
|
75
72
|
return [value, nil] unless schema.format == 'date'
|
76
73
|
|
77
74
|
begin
|
78
|
-
Date.
|
75
|
+
parsed_date = Date.iso8601(value)
|
79
76
|
rescue ArgumentError
|
80
77
|
return [nil, OpenAPIParser::InvalidDateFormat.new(value, schema.object_reference)]
|
81
78
|
end
|
82
79
|
|
80
|
+
unless parsed_date.strftime('%Y-%m-%d') == value
|
81
|
+
return [nil, OpenAPIParser::InvalidDateFormat.new(value, schema.object_reference)]
|
82
|
+
end
|
83
|
+
|
83
84
|
return [value, nil]
|
84
85
|
end
|
85
86
|
|
@@ -110,6 +110,7 @@ module OpenAPIParser::Schemas
|
|
110
110
|
openapi_attr_object :additional_properties, Schema, reference: true, allow_data_type: true, schema_key: :additionalProperties
|
111
111
|
# additional_properties have default value
|
112
112
|
# we should add default value feature in openapi_attr_object method, but we need temporary fix so override attr_reader
|
113
|
+
remove_method :additional_properties
|
113
114
|
def additional_properties
|
114
115
|
@additional_properties.nil? ? true : @additional_properties
|
115
116
|
end
|
data/lib/openapi_parser.rb
CHANGED
@@ -81,14 +81,11 @@ module OpenAPIParser
|
|
81
81
|
end
|
82
82
|
|
83
83
|
def parse_yaml(content)
|
84
|
-
|
85
|
-
(Gem::Version.create(RUBY_VERSION) < Gem::Version.create("2.6.0")) ?
|
86
|
-
Psych.safe_load(content, [Date, Time]) :
|
87
|
-
Psych.safe_load(content, permitted_classes: [Date, Time])
|
84
|
+
Psych.safe_load(content, permitted_classes: [Date, Time])
|
88
85
|
end
|
89
86
|
|
90
87
|
def parse_json(content)
|
91
|
-
raise "json content is nil" unless content
|
88
|
+
raise "json content is nil" unless content
|
92
89
|
JSON.parse(content)
|
93
90
|
end
|
94
91
|
|
data/openapi_parser.gemspec
CHANGED
@@ -35,7 +35,6 @@ Gem::Specification.new do |spec|
|
|
35
35
|
spec.add_development_dependency 'rspec-parameterized'
|
36
36
|
spec.add_development_dependency 'simplecov'
|
37
37
|
spec.add_development_dependency "steep"
|
38
|
-
# for steep
|
39
|
-
|
40
|
-
spec.add_development_dependency "activesupport", '~> 6.0'
|
38
|
+
# for steep + ruby-head
|
39
|
+
spec.add_development_dependency 'base64', '~> 0.2.0'
|
41
40
|
end
|
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.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ota42y
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -109,19 +109,19 @@ dependencies:
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: base64
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: 0.2.0
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
124
|
+
version: 0.2.0
|
125
125
|
description: parser for OpenAPI 3.0 or later
|
126
126
|
email:
|
127
127
|
- ota42y@gmail.com
|
@@ -129,6 +129,7 @@ executables: []
|
|
129
129
|
extensions: []
|
130
130
|
extra_rdoc_files: []
|
131
131
|
files:
|
132
|
+
- ".github/dependabot.yml"
|
132
133
|
- ".github/workflows/ci.yaml"
|
133
134
|
- ".gitignore"
|
134
135
|
- ".rspec"
|
@@ -222,7 +223,7 @@ homepage: https://github.com/ota42y/openapi_parser
|
|
222
223
|
licenses:
|
223
224
|
- MIT
|
224
225
|
metadata: {}
|
225
|
-
post_install_message:
|
226
|
+
post_install_message:
|
226
227
|
rdoc_options: []
|
227
228
|
require_paths:
|
228
229
|
- lib
|
@@ -237,8 +238,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
237
238
|
- !ruby/object:Gem::Version
|
238
239
|
version: '0'
|
239
240
|
requirements: []
|
240
|
-
rubygems_version: 3.
|
241
|
-
signing_key:
|
241
|
+
rubygems_version: 3.5.18
|
242
|
+
signing_key:
|
242
243
|
specification_version: 4
|
243
244
|
summary: OpenAPI3 parser
|
244
245
|
test_files: []
|