openapi_parser 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 46f9ea4e608b98aadd42d6da1ad0f3ab83f8b87c14fee89d287bf7d92d40a38a
4
- data.tar.gz: 84aadee40dbb76d7332fa222d05e447a3070c57311dc6d872267b36b68183e39
3
+ metadata.gz: 1e38224603546bc8818028b725452113a5c3b62811675e1bc7390aeb9b408a2a
4
+ data.tar.gz: 6e6b0352a64a35d2a71a001931910d7e15ea4aa3a36a5aebee68f2aa6e6b367e
5
5
  SHA512:
6
- metadata.gz: dea21c51e1744e593cd110b4b697c212e31d8834e12f148b73ff53e9777cabe83250db73b00102d3cab6f865b30b682f427adc39f7f22c71698965af76fb1cee
7
- data.tar.gz: 98e5c2e15c264918477a36c94788c9ae6c3054c0c86bc2b2b98e1eb5effec77698c00e412682065f2fc0f8538588fde298f54a4083843673de574947dc7e917f
6
+ metadata.gz: 5bc8816e1059379a014e2bfc702068edcc31b6adeddb2f3747094314c01df680cf431774d1fb1bb407497501e454ff4b7571e969f83eec19b6276b3de21d302d
7
+ data.tar.gz: e0819dbee935685d25793da062afb1dd850adeac72ba25efe917a86e46e46fb23e969f02d0402ab39a5111d765e4501ebdb93d679dc36322ddb69cae3bf6dcb8
@@ -0,0 +1,10 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "bundler"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "weekly"
7
+ - package-ecosystem: "github-actions"
8
+ directory: "/"
9
+ schedule:
10
+ interval: "weekly"
@@ -13,10 +13,11 @@ jobs:
13
13
  - "3.0"
14
14
  - "3.1"
15
15
  - "3.2"
16
+ - "3.3"
16
17
  - ruby-head
17
18
  runs-on: ${{ matrix.os }}
18
19
  steps:
19
- - uses: actions/checkout@v2
20
+ - uses: actions/checkout@v4
20
21
  - uses: ruby/setup-ruby@v1
21
22
  with:
22
23
  ruby-version: ${{ matrix.ruby }}
data/CHANGELOG.md CHANGED
@@ -1,14 +1,32 @@
1
1
  ## Unreleased
2
2
 
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
+
3
15
  ## 2.1.0 (2024-04-03)
4
16
  ### Fixed
5
17
  * Add full-date compliant date format validation #164
6
18
 
7
- ## 1.1.0 (2023-10-15)
19
+ ## 2.0.0 (2023-10-15)
20
+
8
21
  ### Added
22
+
9
23
  * Support for uniqueItems in array #154
10
24
  * Fix nullable field does not work with allOf, anyOf and oneOf keyword #128
11
25
 
26
+ ### Other
27
+
28
+ * Drop Ruby 2.6 Support #158
29
+
12
30
  ## 1.0.0 (2021-02-03)
13
31
  ### Added
14
32
  * Add date-time format validation #126
@@ -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? && !parent_all_of && !schema.additional_properties
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
- # match? method is good performance.
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(/[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}/)
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module OpenAPIParser
2
- VERSION = '2.1.0'.freeze
2
+ VERSION = '2.2.0'.freeze
3
3
  end
@@ -81,14 +81,11 @@ module OpenAPIParser
81
81
  end
82
82
 
83
83
  def parse_yaml(content)
84
- # FIXME: when drop ruby 2.5, we should use permitted_classes
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
 
@@ -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
- # https://github.com/soutaro/steep/issues/466
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.1.0
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: 2024-04-04 00:00:00.000000000 Z
11
+ date: 2024-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,34 +38,6 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: pry
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: 0.12.0
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: 0.12.0
55
- - !ruby/object:Gem::Dependency
56
- name: pry-byebug
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
41
  - !ruby/object:Gem::Dependency
70
42
  name: rake
71
43
  requirement: !ruby/object:Gem::Requirement
@@ -137,19 +109,19 @@ dependencies:
137
109
  - !ruby/object:Gem::Version
138
110
  version: '0'
139
111
  - !ruby/object:Gem::Dependency
140
- name: activesupport
112
+ name: base64
141
113
  requirement: !ruby/object:Gem::Requirement
142
114
  requirements:
143
115
  - - "~>"
144
116
  - !ruby/object:Gem::Version
145
- version: '6.0'
117
+ version: 0.2.0
146
118
  type: :development
147
119
  prerelease: false
148
120
  version_requirements: !ruby/object:Gem::Requirement
149
121
  requirements:
150
122
  - - "~>"
151
123
  - !ruby/object:Gem::Version
152
- version: '6.0'
124
+ version: 0.2.0
153
125
  description: parser for OpenAPI 3.0 or later
154
126
  email:
155
127
  - ota42y@gmail.com
@@ -157,6 +129,7 @@ executables: []
157
129
  extensions: []
158
130
  extra_rdoc_files: []
159
131
  files:
132
+ - ".github/dependabot.yml"
160
133
  - ".github/workflows/ci.yaml"
161
134
  - ".gitignore"
162
135
  - ".rspec"
@@ -250,7 +223,7 @@ homepage: https://github.com/ota42y/openapi_parser
250
223
  licenses:
251
224
  - MIT
252
225
  metadata: {}
253
- post_install_message:
226
+ post_install_message:
254
227
  rdoc_options: []
255
228
  require_paths:
256
229
  - lib
@@ -265,8 +238,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
265
238
  - !ruby/object:Gem::Version
266
239
  version: '0'
267
240
  requirements: []
268
- rubygems_version: 3.1.2
269
- signing_key:
241
+ rubygems_version: 3.5.18
242
+ signing_key:
270
243
  specification_version: 4
271
244
  summary: OpenAPI3 parser
272
245
  test_files: []