openapi_parser 2.2.0 → 2.2.1

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: 1e38224603546bc8818028b725452113a5c3b62811675e1bc7390aeb9b408a2a
4
- data.tar.gz: 6e6b0352a64a35d2a71a001931910d7e15ea4aa3a36a5aebee68f2aa6e6b367e
3
+ metadata.gz: e5bbbc0335472ed4352c767db92dc1ed0259548e6d49ece1f5b5da3836fbdbc5
4
+ data.tar.gz: bb600e479aff2c4b7ac0314215f49d3058491e93fde59240cd47339853a8ecf8
5
5
  SHA512:
6
- metadata.gz: 5bc8816e1059379a014e2bfc702068edcc31b6adeddb2f3747094314c01df680cf431774d1fb1bb407497501e454ff4b7571e969f83eec19b6276b3de21d302d
7
- data.tar.gz: e0819dbee935685d25793da062afb1dd850adeac72ba25efe917a86e46e46fb23e969f02d0402ab39a5111d765e4501ebdb93d679dc36322ddb69cae3bf6dcb8
6
+ metadata.gz: 53f5d120721d58ae47a555a036ac037fbb5460cbf315f918b7f881bb1a5f4fffee5bad46118dfd085441fcd65c01f133bb84834e728582a8008aaeb46a943a3e
7
+ data.tar.gz: 6ed888572b972db4ca33daffbfdef569de6f41153c5e798f42ee68badbe8154c1e206ec01300522d15aff56be1ecb5e4b4bd1209e99fc4da789e78ea4d1ba88f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  ## Unreleased
2
2
 
3
+ ## 2.2.1 (2024-10-23)
4
+ * revert schemas validation in additionalProperties and remove additionalProperties logic from allof (breaking things for me, will revisit)
5
+
3
6
  ## 2.2.0 (2024-10-23)
4
7
  ### Fixed
5
8
  * support schemas validation in additionalProperties and remove additionalProperties logic from allof
@@ -10,6 +10,8 @@ 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
13
15
  schema.all_of.each do |s|
14
16
  # We need to store the reference to all of, so we can perform strict check on allowed properties
15
17
  _coerced, err = validatable.validate_schema(
@@ -18,9 +20,24 @@ class OpenAPIParser::SchemaValidator
18
20
  :parent_all_of => true,
19
21
  parent_discriminator_schemas: keyword_args[:parent_discriminator_schemas]
20
22
  )
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
+
21
32
  return [nil, err] if err
22
33
  end
23
34
 
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
+
24
41
  [value, nil]
25
42
  end
26
43
  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)
32
30
  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,7 +41,9 @@ class OpenAPIParser::SchemaValidator
41
41
 
42
42
  remaining_keys.delete(discriminator_property_name) if discriminator_property_name
43
43
 
44
- if !remaining_keys.empty? && !schema.additional_properties
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
45
47
  return [nil, OpenAPIParser::NotExistPropertyDefinition.new(remaining_keys, schema.object_reference)]
46
48
  end
47
49
  return [nil, OpenAPIParser::NotExistRequiredKey.new(required_set.to_a, schema.object_reference)] unless required_set.empty?
@@ -1,3 +1,3 @@
1
1
  module OpenAPIParser
2
- VERSION = '2.2.0'.freeze
2
+ VERSION = '2.2.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openapi_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ota42y