openapi_parser 2.2.0 → 2.2.1
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5bbbc0335472ed4352c767db92dc1ed0259548e6d49ece1f5b5da3836fbdbc5
|
4
|
+
data.tar.gz: bb600e479aff2c4b7ac0314215f49d3058491e93fde59240cd47339853a8ecf8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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?
|